r15061: Use $(PERL) to run cflags.pl as actual perl binary might not be in /usr/bin
[Samba/bb.git] / source4 / main.mk
blob6eba282be0cee0b8c9ca60a148e88805763aba10
1 all: $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries libraries modules
3 include dynconfig.mk
4 include heimdal_build/config.mk
5 include config.mk
6 include dsdb/config.mk
7 include gtk/config.mk
8 include smbd/config.mk
9 include smbd/process_model.mk
10 include libnet/config.mk
11 include auth/config.mk
12 include nsswitch/config.mk
13 include lib/basic.mk
14 include param/config.mk
15 include smb_server/config.mk
16 include rpc_server/config.mk
17 include ldap_server/config.mk
18 include web_server/config.mk
19 include winbind/config.mk
20 include nbt_server/config.mk
21 include wrepl_server/config.mk
22 include cldap_server/config.mk
23 include utils/net/config.mk
24 include utils/config.mk
25 include ntvfs/config.mk
26 include ntptr/config.mk
27 include torture/config.mk
28 include librpc/config.mk
29 include client/config.mk
30 include libcli/config.mk
31 include scripting/ejs/config.mk
32 include scripting/swig/config.mk
33 include kdc/config.mk
34 include passdb/config.mk
36 DEFAULT_HEADERS = $(srcdir)/include/core.h \
37 $(srcdir)/include/dlinklist.h \
38 $(srcdir)/version.h
40 binaries: $(BINARIES)
41 libraries: $(STATIC_LIBS) $(SHARED_LIBS)
42 modules: $(SHARED_MODULES)
43 headers: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
44 manpages: $(MANPAGES)
45 everything: all
47 showlayout:
48 @echo 'Samba will be installed into:'
49 @echo ' basedir: $(BASEDIR)'
50 @echo ' bindir: $(BINDIR)'
51 @echo ' sbindir: $(SBINDIR)'
52 @echo ' libdir: $(LIBDIR)'
53 @echo ' modulesdir: $(MODULESDIR)'
54 @echo ' includedir: $(INCLUDEDIR)'
55 @echo ' vardir: $(VARDIR)'
56 @echo ' privatedir: $(PRIVATEDIR)'
57 @echo ' piddir: $(PIDDIR)'
58 @echo ' lockdir: $(LOCKDIR)'
59 @echo ' logfilebase: $(LOGFILEBASE)'
60 @echo ' setupdir: $(SETUPDIR)'
61 @echo ' jsdir: $(JSDIR)'
62 @echo ' swatdir: $(SWATDIR)'
63 @echo ' mandir: $(MANDIR)'
64 @echo ' datadir: $(DATADIR)'
65 @echo ' winbindd_socket_dir: $(WINBINDD_SOCKET_DIR)'
67 showflags:
68 @echo 'Samba will be compiled with flags:'
69 @echo ' CFLAGS = $(CFLAGS)'
70 @echo ' LDFLAGS = $(LDFLAGS)'
71 @echo ' STLD_FLAGS = $(STLD_FLAGS)'
72 @echo ' SHLD_FLAGS = $(SHLD_FLAGS)'
73 @echo ' LIBS = $(LIBS)'
75 # The permissions to give the executables
76 INSTALLPERMS = 0755
78 # set these to where to find various files
79 # These can be overridden by command line switches (see smbd(8))
80 # or in smb.conf (see smb.conf(5))
81 CONFIGFILE = $(CONFIGDIR)/smb.conf
82 PKGCONFIGDIR = $(LIBDIR)/pkgconfig
83 LMHOSTSFILE = $(CONFIGDIR)/lmhosts
85 install: showlayout installbin installdat installswat installmisc installlib \
86 installheader installpc installplugins
88 # DESTDIR is used here to prevent packagers wasting their time
89 # duplicating the Makefile. Remove it and you will have the privilege
90 # of packaging each samba release for multiple versions of multiple
91 # distributions and operating systems, or at least supplying patches
92 # to all the packaging files required for this, prior to committing
93 # the removal of DESTDIR. Do not remove it even though you think it
94 # is not used.
96 installdirs:
97 @$(SHELL) $(srcdir)/script/installdirs.sh \
98 $(DESTDIR)$(BASEDIR) \
99 $(DESTDIR)$(BINDIR) \
100 $(DESTDIR)$(SBINDIR) \
101 $(DESTDIR)$(LIBDIR) \
102 $(DESTDIR)$(MODULESDIR) \
103 $(DESTDIR)$(MANDIR) \
104 $(DESTDIR)$(VARDIR) \
105 $(DESTDIR)$(PRIVATEDIR) \
106 $(DESTDIR)$(DATADIR) \
107 $(DESTDIR)$(PIDDIR) \
108 $(DESTDIR)$(LOCKDIR) \
109 $(DESTDIR)$(LOGFILEBASE) \
110 $(DESTDIR)$(PRIVATEDIR)/tls \
111 $(DESTDIR)$(INCLUDEDIR) \
112 $(DESTDIR)$(PKGCONFIGDIR) \
113 $(DESTDIR)$(CONFIGDIR) \
115 installbin: $(SBIN_PROGS) $(BIN_PROGS) installdirs
116 @$(SHELL) $(srcdir)/script/installbin.sh \
117 $(INSTALLPERMS) \
118 $(DESTDIR)$(BASEDIR) \
119 $(DESTDIR)$(SBINDIR) \
120 $(DESTDIR)$(LIBDIR) \
121 $(DESTDIR)$(VARDIR) \
122 $(SBIN_PROGS)
123 @$(SHELL) $(srcdir)/script/installbin.sh \
124 $(INSTALLPERMS) \
125 $(DESTDIR)$(BASEDIR) \
126 $(DESTDIR)$(BINDIR) \
127 $(DESTDIR)$(LIBDIR) \
128 $(DESTDIR)$(VARDIR) \
129 $(BIN_PROGS)
131 installlib: $(INSTALLABLE_SHARED_LIBS) $(STATIC_LIBS) installdirs
132 @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(SHLIBEXT)" $(INSTALLABLE_SHARED_LIBS)
133 @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(STLIBEXT)" $(STATIC_LIBS)
135 installheader: headers installdirs
136 @$(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
138 installdat: installdirs
139 @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
141 installswat: installdirs
142 @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
144 installman: manpages installdirs
145 @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
147 installmisc: installdirs
148 @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
150 installpc: installdirs
151 @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
153 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
154 uninstallplugins
156 uninstallmisc:
157 #FIXME
159 uninstallbin:
160 @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
161 @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
163 uninstalllib:
164 @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
165 @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS)
167 uninstallheader:
168 @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
170 uninstallman:
171 @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
173 Makefile: config.status $(MK_FILES)
174 ./config.status
176 etags:
177 etags `find $(srcdir) -name "*.[ch]"`
179 ctags:
180 ctags `find $(srcdir) -name "*.[ch]"`
182 pidl/Makefile: pidl/Makefile.PL
183 cd pidl && $(PERL) Makefile.PL
185 installpidl: pidl/Makefile
186 $(MAKE) -C pidl install
188 uninstallpidl: pidl/Makefile
189 $(MAKE) -C pidl uninstall
191 IDL_FILES = $(wildcard librpc/idl/*.idl)
192 IDL_HEADER_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/%.h,$(IDL_FILES))
193 IDL_NDR_HEADER_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.h,$(IDL_FILES))
194 IDL_NDR_PARSE_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.c,$(IDL_FILES))
195 IDL_NDR_CLIENT_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_c.c,$(IDL_FILES))
196 IDL_NDR_CLIENT_HEADER_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_c.h,$(IDL_FILES))
197 IDL_NDR_SERVER_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_s.c,$(IDL_FILES))
198 IDL_NDR_EJS_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_ejs.c,$(IDL_FILES))
199 IDL_NDR_EJS_H_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_ejs.h,$(IDL_FILES))
201 $(IDL_HEADER_FILES) $(IDL_NDR_HEADER_FILES) $(IDL_NDR_PARSE_C_FILES) \
202 $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
203 $(IDL_NDR_SERVER_C_FILES) $(IDL_NDR_EJS_C_FILES) \
204 $(IDL_NDR_EJS_H_FILES): idl
206 idl_full: pidl/lib/Parse/Pidl/IDL.pm
207 @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL $(PIDL_ARGS)
209 idl: pidl/lib/Parse/Pidl/IDL.pm
210 @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL $(PIDL_ARGS)
212 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
213 -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp
215 smb_interfaces: pidl/smb_interfaces.pm
216 $(PERL) -Ipidl $(srcdir)/script/build_smb_interfaces.pl \
217 include/smb_interfaces.h
219 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
220 -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp
222 include/config.h:
223 @echo "include/config.h not present"
224 @echo "You need to rerun ./autogen.sh and ./configure"
225 @/bin/false
227 clean_pch:
228 -rm -f include/includes.h.gch
230 pch: clean_pch include/includes.h.gch
232 clean:: clean_pch
233 @echo Removing objects
234 @-find . -name '*.o' -exec rm -f '{}' \;
235 @echo Removing hostcc objects
236 @-find . -name '*.ho' -exec rm -f '{}' \;
237 @echo Removing binaries
238 @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES)
239 @echo Removing libraries
240 @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
241 @-rm -f bin/*.$(SHLIBEXT)*
242 @echo Removing modules
243 @-rm -f bin/modules/*/*.$(SHLIBEXT)
244 @-rm -f bin/*_init_module.c
245 @echo Removing dummy targets
246 @-rm -f bin/.*_*
247 @echo Removing generated files
248 @-rm -f bin/*_init_module.c
249 @-rm -rf librpc/gen_*
250 @echo Removing proto headers
251 @-rm -f $(PROTO_HEADERS)
253 distclean: clean
254 -rm -f include/config.h include/config_tmp.h include/build.h
255 -rm -f Makefile
256 -rm -f config.status
257 -rm -f config.log config.cache
258 -rm -f config.pm config.mk
259 -rm -f $(PC_FILES)
261 removebackup:
262 -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
264 realdistclean: distclean removebackup
265 -rm -f include/config_tmp.h.in
266 -rm -f include/version.h
267 -rm -f configure
268 -rm -f $(MANPAGES)
270 test: $(DEFAULT_TEST_TARGET)
272 test-swrap: all
273 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
275 test-noswrap: all
276 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all
278 quicktest: all
279 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
281 valgrindtest: valgrindtest-quick
283 valgrindtest-quick: all
284 SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
285 VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
286 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
288 valgrindtest-all: all
289 SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
290 VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
291 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
293 gdbtest: gdbtest-quick
295 gdbtest-quick: all
296 SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
297 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
299 gdbtest-all: all
300 SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
301 $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
303 unused_macros:
304 $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
306 ###############################################################################
307 # File types
308 ###############################################################################
310 .SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .so .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd
312 .c.ho:
313 @echo "Compiling $< with host compiler"
314 @$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $< -o $@
316 .c.d:
317 @echo "Generating dependencies for $<"
318 @$(CC) -M -MG -MP -MT $(<:.c=.o) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
320 .c.hd:
321 @echo "Generating dependencies for $<"
322 @$(CC) -M -MG -MP -MT $(<:.c=.ho) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
324 include/includes.d: include/includes.h
325 @echo "Generating dependencies for $<"
326 @$(CC) -M -MG -MT include/includes.h.gch $(CFLAGS) $< -o $@
328 .c.o:
329 @if test -n "$(CC_CHECKER)"; then \
330 echo "Checking $< with '$(CC_CHECKER)'"; \
331 $(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@; \
333 @echo "Compiling $<"
334 @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
336 .h.h.gch:
337 @echo "Precompiling $<"
338 @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
340 .y.c:
341 @echo "Building $< with $(YACC)"
342 @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
344 .l.c:
345 @echo "Building $< with $(LEX)"
346 @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
348 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
350 .1.xml.1:
351 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
353 .3.xml.3:
354 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
356 .5.xml.5:
357 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
359 .7.xml.7:
360 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
362 .8.xml.8:
363 $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
365 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
366 include/includes.d
368 dist:: distclean idl_full manpages configure
370 configure:
371 ./autogen.sh
373 clean::
374 @echo Removing dependency files
375 @rm -f $(DEP_FILES)