From f800cf250f079ab1e1bc1051c34d1d1061187447 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 14:51:57 +0200 Subject: Move standard make compilation rules to build/make. (This used to be commit ceda3312a98b069d0711f3cb33de3ae71e91ebaa) --- source4/build/make/rules.mk | 288 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 source4/build/make/rules.mk (limited to 'source4/build/make/rules.mk') diff --git a/source4/build/make/rules.mk b/source4/build/make/rules.mk new file mode 100644 index 0000000000..faefb4e323 --- /dev/null +++ b/source4/build/make/rules.mk @@ -0,0 +1,288 @@ +# Rules file for Samba 4 +# This relies on GNU make. +# +# Dependencies command +DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \ + $(CFLAGS) $(CPPFLAGS) $< -o $@ +# Dependencies for host objects +HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \ + $(HOSTCC_FLAGS) $(CPPFLAGS) $< -o $@ +# Dependencies for precompiled headers +PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \ + $(CFLAGS) $(CPPFLAGS) $< -o $@ + +# Run a static analysis checker +CHECK = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) $(CPPLAGS) -c $< -o $@ + +# Run the configured compiler +COMPILE = $(CC) $(CFLAGS) $(PICFLAG) \ + $(CPPFLAGS) \ + -c $< -o $@ + +# Run the compiler for the build host +HCOMPILE = $(HOSTCC) $(HOSTCC_FLAGS) $(CPPFLAGS) -c $< -o $@ + +# Precompile headers +PCHCOMPILE = @$(CC) -Ilib/replace \ + $(CFLAGS) $(PICFLAG) $(CPPFLAGS) -c $< -o $@ + +# Partial linking +PARTLINK = @$(PROG_LD) -r + +make_utility_dir = $(srcdir)/build/make/ + +include/config.h: + @echo "include/config.h not present" + @echo "You need to rerun ./autogen.sh and ./configure" + @/bin/false + +pch:: + +clean:: clean_pch + @echo Removing objects + @-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_LIBS) $(SHARED_LIBS) + @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o + @echo Removing modules + @-rm -f bin/modules/*/*.$(SHLIBEXT) + @-rm -f bin/*_init_module.c + @echo Removing dummy targets + @-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) + +distclean:: clean + -rm -f include/config.h include/config_tmp.h include/build.h + -rm -f data.mk + -rm -f config.status + -rm -f config.log config.cache + -rm -f config.pm config.mk + -rm -f $(PC_FILES) + +removebackup:: + -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~ + +realdistclean:: distclean removebackup + -rm -f include/config_tmp.h.in + -rm -f version.h + -rm -f configure + -rm -f $(MANPAGES) + +check:: test + +unused_macros: + $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort + +# Create a static library +%.a: + @echo Linking $@ + @rm -f $@ + @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) --public=/dev/null --private=$$@ $$^ +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 library +# Arguments: Target, dependencies, link flags, soname +define shared_library_template +$(1): $(2) + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \ + $(3) \ + $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4))) + +ifneq ($(notdir $(1)),$(notdir $(4))) +$(4): $(1) + @echo "Creating symbolic link for $$@" + @ln -fs $$(&2;\ + echo "$(HCOMPILE)" 1>&2;\ + $(HCOMPILE) >/dev/null 2>&1 + +.h.h.gch: + @echo "Precompiling $<" + @$(PCHCOMPILE) + +.y.c: + @echo "Building $< with $(YACC)" + @-$(make_utility_dir)/yacc_compile.sh "$(YACC)" "$<" "$@" + +.l.c: + @echo "Building $< with $(LEX)" + @-$(make_utility_dir)/script/lex_compile.sh "$(LEX)" "$<" "$@" + +%.a: + @echo Linking $@ + @rm -f $@ + @mkdir -p $(@D) + @$(STLD) $(STLD_FLAGS) $@ $^ + + +DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl + +.1.xml.1: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.3.xml.3: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.5.xml.5: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.7.xml.7: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.8.xml.8: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +dist:: idl_full manpages configure distclean + +configure: + ./autogen.sh + +showflags:: + @echo 'Samba will be compiled with flags:' + @echo ' CPP = $(CPP)' + @echo ' CPPFLAGS = $(CPPFLAGS)' + @echo ' CC = $(CC)' + @echo ' CFLAGS = $(CFLAGS)' + @echo ' PICFLAG = $(PICFLAG)' + @echo ' BNLD = $(BNLD)' + @echo ' BNLD_FLAGS = $(BNLD_FLAGS)' + @echo ' STLD = $(STLD)' + @echo ' STLD_FLAGS = $(STLD_FLAGS)' + @echo ' SHLD = $(SHLD)' + @echo ' SHLD_FLAGS = $(SHLD_FLAGS)' + @echo ' MDLD = $(MDLD)' + @echo ' MDLD_FLAGS = $(MDLD_FLAGS)' + @echo ' SHLIBEXT = $(SHLIBEXT)' + +etags: + etags `find $(srcdir) -name "*.[ch]"` + +ctags: + ctags `find $(srcdir) -name "*.[ch]"` -- cgit From 08f83c59df7a0e490da55a536b6e04a32508d2b0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Apr 2008 22:20:49 +0200 Subject: build: fix the build rule for .o files metze (This used to be commit c7f34f41c3f9f0c3f75a618dfaf566706014a6b4) --- source4/build/make/rules.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/build/make/rules.mk') diff --git a/source4/build/make/rules.mk b/source4/build/make/rules.mk index faefb4e323..541fa018db 100644 --- a/source4/build/make/rules.mk +++ b/source4/build/make/rules.mk @@ -211,7 +211,9 @@ include/includes.d: include/includes.h @echo "Compiling $<" @-mkdir -p `dirname $@` @$(COMPILE) && exit 0 ; \ - $(COMPILE) + echo "The following command failed:" 1>&2;\ + echo "$(COMPILE)" 1>&2;\ + $(COMPILE) >/dev/null 2>&1 -- cgit