s4: prevent the autoconf build from removing source4/librpc/gen_ndr/README
[samba.git] / source4 / build / make / rules.mk
index bce30ffc061ab29afad32d5eb93a46044efc8b14..30622cc89b8d1be02ee622bb965aa8fbf7091938 100644 (file)
@@ -2,10 +2,10 @@
 # This relies on GNU make.
 #
 # Dependencies command
-DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
+DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ -MT : \
     $(CFLAGS) $(CPPFLAGS) $< -o $@
 # Dependencies for host objects
-HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \
+HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ -MT : \
     $(HOSTCC_FLAGS) $(CPPFLAGS) $< -o $@
 # Dependencies for precompiled headers
 PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \
@@ -43,11 +43,9 @@ clean:: clean_pch
        @-find . -name '*.o' -exec rm -f '{}' \;
        @echo Removing hostcc objects
        @-find . -name '*.ho' -exec rm -f '{}' \;
-       @echo Removing binaries
-       @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
        @echo Removing libraries
-       @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
-       @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
+       @-rm -f $(STATIC_LIBS) $(SHARED_LIBS)
+       @-rm -f bin/static/*.a $(shliboutputdir)/*.$(SHLIBEXT) bin/mergedobj/*.o
        @echo Removing modules
        @-rm -f bin/modules/*/*.$(SHLIBEXT)
        @-rm -f bin/*_init_module.c
@@ -55,9 +53,7 @@ clean:: clean_pch
        @-rm -f bin/.*_*
        @echo Removing generated files
        @-rm -f bin/*_init_module.c
-       @-rm -rf librpc/gen_* 
-       @echo Removing proto headers
-       @-rm -f $(PROTO_HEADERS)
+       @-rm -f librpc/gen_ndr/*.*
 
 distclean:: clean
        -rm -f include/config.h include/config_tmp.h include/build.h
@@ -88,69 +84,7 @@ unused_macros:
        @mkdir -p $(@D)
        @$(STLD) $(STLD_FLAGS) $@ $^
 
-###############################################################################
-# Templates
-###############################################################################
-
-# Partially link
-# Arguments: target object file, source object files
-define partial_link_template 
-$(1): $(2) ;
-       @echo Partially linking $$@
-       @mkdir -p $$(@D)
-       $$(PARTLINK) -o $$@ $$^
-endef
-
-# Link a binary
-# Arguments: target file, depends, flags
-define binary_link_template
-$(1): $(2) ;
-       @echo Linking $$@
-       @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
-endef
-
-# Link a host-machine binary
-# Arguments: target file, depends, flags
-define host_binary_link_template
-$(1): $(2) ;
-       @echo Linking $$@
-       @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
-endef
-
-# Create a prototype header
-# Arguments: header file, c files
-define proto_header_template
-$(1): $(2) ;
-       @echo "Creating $$@"
-       @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --all=$$@ $$^
-endef
-
-# Shared module
-# Arguments: Target, dependencies, objects
-define shared_module_template
-
-$(1): $(2) ;
-       @echo Linking $$@
-       @mkdir -p $$(@D)
-       @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
-
-endef
-
-# Shared alias
-# Arguments: Target, subsystem name, alias name
-define shared_module_alias_template
-bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1)
-       @ln -fs $$(<F) $$@
-
-PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
-
-uninstallplugins::
-       @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
-installplugins::
-       @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
-
-
-endef
+include $(make_utility_dir)/templates.mk
 
 ###############################################################################
 # File types
@@ -179,17 +113,15 @@ include/includes.d: include/includes.h
        @-mkdir -p `dirname $@`
        @$(COMPILE) && exit 0 ; \
                echo "The following command failed:" 1>&2;\
-               $(COMPILE) >/dev/null 2>&1
+               echo "$(subst ",\",$(COMPILE))" 1>&2 && exit 1
 
 
-#              echo "$(COMPILE)" 1>&2;\
-
 .c.ho:
        @echo "Compiling $< with host compiler"
        @-mkdir -p `dirname $@`
        @$(HCOMPILE) && exit 0;\
                echo "The following command failed:" 1>&2;\
-               echo "$(HCOMPILE)" 1>&2;\
+               echo "$(subst ",\",$(HCOMPILE))" 1>&2;\
                $(HCOMPILE) >/dev/null 2>&1
 
 .h.h.gch:
@@ -202,7 +134,7 @@ include/includes.d: include/includes.h
 
 .l.c:
        @echo "Building $< with $(LEX)"
-       @-$(make_utility_dir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
+       @-$(make_utility_dir)/lex_compile.sh "$(LEX)" "$<" "$@"
 
 %.a:
        @echo Linking $@
@@ -251,7 +183,8 @@ showflags::
        @echo '  SHLIBEXT   = $(SHLIBEXT)'
 
 etags:
-       etags `find $(srcdir) -name "*.[ch]"`
+       etags $(ETAGS_OPTIONS) `find $(base_srcdirs) -name "*.[ch]"`
 
 ctags:
-       ctags `find $(srcdir) -name "*.[ch]"`
+       ctags $(CTAGS_OPTIONS) `find $(base_srcdirs) -name "*.[ch]" | grep -v "_proto\.h"`
+