build: fix the build with --enable-automatic-dependencies=yes
[jelmer/samba4-debian.git] / source / Makefile
index ea98b5e469f522400a1a9fbb7e2da45629ed94b6..914f15826a1fad450c66bd16154322ce7215aeeb 100644 (file)
@@ -14,16 +14,44 @@ SETUPDIR = $(datadir)/setup
 NCALRPCDIR = $(localstatedir)/ncalrpc
 
 BNLD = $(LD)
-BNLD_FLAGS = $(LDFLAGS)
+BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
 
 HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS)
-HOSTLD_FLAGS = $(LDFLAGS)
+HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
 
-default: all
+.DEFAULT_GOAL := all
+
+ifneq ($(automatic_dependencies),yes)
+ALL_PREDEP = proto
+.NOTPARALLEL:
+endif
 
 include rules.mk
 include data.mk
 
+DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
+                  include/includes.d
+
+ifeq ($(automatic_dependencies),yes)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
+ifneq ($(MAKECMDGOALS),realdistclean)
+ifneq ($(SKIP_DEP_FILES),yes)
+-include $(DEP_FILES)
+endif
+endif
+endif
+endif
+
+ifneq ($(SKIP_DEP_FILES),yes)
+clean::
+       @echo Removing dependency files
+       @find . -name '*.d' -o -name '*.hd' | xargs rm -f
+endif
+else
+include $(srcdir)/static_deps.mk
+endif
+
 DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
                  $(srcdir)/version.h