1 # Rules file for Samba 4
2 # This relies on GNU make.
5 DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
6 $(CFLAGS) $(CPPFLAGS) $< -o $@
7 # Dependencies for host objects
8 HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \
9 $(HOSTCC_FLAGS) $(CPPFLAGS) $< -o $@
10 # Dependencies for precompiled headers
11 PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \
12 $(CFLAGS) $(CPPFLAGS) $< -o $@
14 # Run a static analysis checker
15 CHECK = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) $(CPPLAGS) -c $< -o $@
17 # Run the configured compiler
18 COMPILE = $(CC) $(CFLAGS) $(PICFLAG) \
22 # Run the compiler for the build host
23 HCOMPILE = $(HOSTCC) $(HOSTCC_FLAGS) $(CPPFLAGS) -c $< -o $@
26 PCHCOMPILE = @$(CC) -Ilib/replace \
27 $(CFLAGS) $(PICFLAG) $(CPPFLAGS) -c $< -o $@
30 PARTLINK = @$(PROG_LD) -r
32 make_utility_dir = $(srcdir)/build/make/
35 @echo "include/config.h not present"
36 @echo "You need to rerun ./autogen.sh and ./configure"
42 @echo Removing objects
43 @-find . -name '*.o' -exec rm -f '{}' \;
44 @echo Removing hostcc objects
45 @-find . -name '*.ho' -exec rm -f '{}' \;
46 @echo Removing binaries
47 @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
48 @echo Removing libraries
49 @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
50 @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
51 @echo Removing modules
52 @-rm -f bin/modules/*/*.$(SHLIBEXT)
53 @-rm -f bin/*_init_module.c
54 @echo Removing dummy targets
56 @echo Removing generated files
57 @-rm -f bin/*_init_module.c
59 @echo Removing proto headers
60 @-rm -f $(PROTO_HEADERS)
63 -rm -f include/config.h include/config_tmp.h include/build.h
66 -rm -f config.log config.cache
67 -rm -f config.pm config.mk
71 -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
73 realdistclean:: distclean removebackup
74 -rm -f include/config_tmp.h.in
82 $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
84 # Create a static library
89 @$(STLD) $(STLD_FLAGS) $@ $^
91 ###############################################################################
93 ###############################################################################
96 # Arguments: target object file, source object files
97 define partial_link_template
99 @echo Partially linking $$@
101 $$(PARTLINK) -o $$@ $$^
105 # Arguments: target file, depends, flags
106 define binary_link_template
109 @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
112 # Link a host-machine binary
113 # Arguments: target file, depends, flags
114 define host_binary_link_template
117 @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
120 # Create a prototype header
121 # Arguments: header file, c files
122 define proto_header_template
125 @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --all=$$@ $$^
129 # Arguments: Target, dependencies, objects
130 define shared_module_template
135 @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
139 ###############################################################################
141 ###############################################################################
143 .SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd
146 @echo "Generating dependencies for $<"
150 @echo "Generating host-compiler dependencies for $<"
153 include/includes.d: include/includes.h
154 @echo "Generating dependencies for $<"
158 @if test -n "$(CC_CHECKER)"; then \
159 echo "Checking $< with '$(CC_CHECKER)'"; \
163 @-mkdir -p `dirname $@`
164 @$(COMPILE) && exit 0 ; \
165 echo "The following command failed:" 1>&2;\
166 $(COMPILE) >/dev/null 2>&1
169 # echo "$(COMPILE)" 1>&2;\
172 @echo "Compiling $< with host compiler"
173 @-mkdir -p `dirname $@`
174 @$(HCOMPILE) && exit 0;\
175 echo "The following command failed:" 1>&2;\
176 echo "$(HCOMPILE)" 1>&2;\
177 $(HCOMPILE) >/dev/null 2>&1
180 @echo "Precompiling $<"
184 @echo "Building $< with $(YACC)"
185 @-$(make_utility_dir)/yacc_compile.sh "$(YACC)" "$<" "$@"
188 @echo "Building $< with $(LEX)"
189 @-$(make_utility_dir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
195 @$(STLD) $(STLD_FLAGS) $@ $^
198 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
201 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
204 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
207 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
210 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
213 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
215 dist:: idl_full manpages configure distclean
221 @echo 'Samba will be compiled with flags:'
222 @echo ' CPP = $(CPP)'
223 @echo ' CPPFLAGS = $(CPPFLAGS)'
225 @echo ' CFLAGS = $(CFLAGS)'
226 @echo ' PICFLAG = $(PICFLAG)'
227 @echo ' BNLD = $(BNLD)'
228 @echo ' BNLD_FLAGS = $(BNLD_FLAGS)'
229 @echo ' STLD = $(STLD)'
230 @echo ' STLD_FLAGS = $(STLD_FLAGS)'
231 @echo ' SHLD = $(SHLD)'
232 @echo ' SHLD_FLAGS = $(SHLD_FLAGS)'
233 @echo ' MDLD = $(MDLD)'
234 @echo ' MDLD_FLAGS = $(MDLD_FLAGS)'
235 @echo ' SHLIBEXT = $(SHLIBEXT)'
238 etags `find $(srcdir) -name "*.[ch]"`
241 ctags `find $(srcdir) -name "*.[ch]"`