build: fix the build with --enable-automatic-dependencies=yes
[jelmer/samba4-debian.git] / source / Makefile
index a5f32e19d6b2c344ac03d8a73b2e497df6fd385d..914f15826a1fad450c66bd16154322ce7215aeeb 100644 (file)
@@ -14,21 +14,50 @@ 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
 
-binaries:: $(BINARIES)
+binaries::
 libraries:: $(STATIC_LIBS) $(SHARED_LIBS)
-modules:: $(SHARED_MODULES)
+modules:: $(PLUGINS)
 headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
 manpages:: $(MANPAGES)
 all:: showflags $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries modules pythonmods
@@ -121,8 +150,10 @@ installbin:: $(SBIN_PROGS) $(BIN_PROGS) $(TORTURE_PROGS) installdirs
                $(DESTDIR)$(TORTUREDIR) \
                $(TORTURE_PROGS)
 
-installlib:: $(INSTALLABLE_SHARED_LIBS) $(STATIC_LIBS) installdirs
-       @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(SHLIBEXT)" $(INSTALLABLE_SHARED_LIBS) 
+installplugins::
+
+installlib:: $(SHARED_LIBS) $(STATIC_LIBS) installdirs
+       @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(SHLIBEXT)" $(SHARED_LIBS) 
        #@$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(STLIBEXT)" $(STATIC_LIBS)
 
 installheader:: headers installdirs
@@ -164,6 +195,8 @@ uninstallheader::
 uninstallman::
        @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(mandir) $(MANPAGES)
 
+uninstallplugins::
+
 config.status:
        @echo "config.status does not exist. Please run ./configure."
        @/bin/false
@@ -175,7 +208,6 @@ testcov-html::
 
 include pidl/config.mk
 include selftest/config.mk
-include rules.mk
 
 showflags::
        @echo '  pwd        = '`/bin/pwd`