r19538: This is getting silly, but I needed an easy way to run 'make testenv'
[kai/samba.git] / source4 / main.mk
1 all: showflags $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries libraries modules
2
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
35
36 DEFAULT_HEADERS = $(srcdir)/include/core.h \
37                                   $(srcdir)/lib/util/dlinklist.h \
38                                   $(srcdir)/version.h
39
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
46
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 '  servicesdir: $(SERVICESDIR)'
64         @echo '  mandir:      $(MANDIR)'
65         @echo '  torturedir:  $(TORTUREDIR)'
66         @echo '  datadir:     $(DATADIR)'
67         @echo '  winbindd_socket_dir:  $(WINBINDD_SOCKET_DIR)'
68
69 showflags:
70         @echo 'Samba will be compiled with flags:'
71         @echo '  CPP        = $(CPP)'
72         @echo '  CPPFLAGS   = $(CPPFLAGS)'
73         @echo '  CC         = $(CC)'
74         @echo '  CFLAGS     = $(CFLAGS)'
75         @echo '  PICFLAG    = $(PICFLAG)'
76         @echo '  LD         = $(LD)'
77         @echo '  LDFLAGS    = $(LDFLAGS)'
78         @echo '  STLD       = $(STLD)'
79         @echo '  STLD_FLAGS = $(STLD_FLAGS)'
80         @echo '  SHLD       = $(SHLD)'
81         @echo '  SHLD_FLAGS = $(SHLD_FLAGS)'
82         @echo '  SHLIBEXT   = $(SHLIBEXT)'
83
84 # The permissions to give the executables
85 INSTALLPERMS = 0755
86
87 # set these to where to find various files
88 # These can be overridden by command line switches (see smbd(8))
89 # or in smb.conf (see smb.conf(5))
90 CONFIGFILE = $(CONFIGDIR)/smb.conf
91 PKGCONFIGDIR = $(LIBDIR)/pkgconfig
92 LMHOSTSFILE = $(CONFIGDIR)/lmhosts
93
94 install: showlayout installbin installdat installswat installmisc installlib \
95         installheader installpc installplugins
96
97 # DESTDIR is used here to prevent packagers wasting their time
98 # duplicating the Makefile. Remove it and you will have the privilege
99 # of packaging each samba release for multiple versions of multiple
100 # distributions and operating systems, or at least supplying patches
101 # to all the packaging files required for this, prior to committing
102 # the removal of DESTDIR. Do not remove it even though you think it
103 # is not used.
104
105 installdirs:
106         @$(SHELL) $(srcdir)/script/installdirs.sh \
107                 $(DESTDIR)$(BASEDIR) \
108                 $(DESTDIR)$(BINDIR) \
109                 $(DESTDIR)$(SBINDIR) \
110                 $(DESTDIR)$(TORTUREDIR) \
111                 $(DESTDIR)$(LIBDIR) \
112                 $(DESTDIR)$(MODULESDIR) \
113                 $(DESTDIR)$(MANDIR) \
114                 $(DESTDIR)$(VARDIR) \
115                 $(DESTDIR)$(PRIVATEDIR) \
116                 $(DESTDIR)$(DATADIR) \
117                 $(DESTDIR)$(PIDDIR) \
118                 $(DESTDIR)$(LOCKDIR) \
119                 $(DESTDIR)$(LOGFILEBASE) \
120                 $(DESTDIR)$(PRIVATEDIR)/tls \
121                 $(DESTDIR)$(INCLUDEDIR) \
122                 $(DESTDIR)$(PKGCONFIGDIR) \
123                 $(DESTDIR)$(CONFIGDIR) \
124
125 installbin: $(SBIN_PROGS) $(BIN_PROGS) $(TORTURE_PROGS) installdirs
126         @$(SHELL) $(srcdir)/script/installbin.sh \
127                 $(INSTALLPERMS) \
128                 $(DESTDIR)$(BASEDIR) \
129                 $(DESTDIR)$(SBINDIR) \
130                 $(DESTDIR)$(LIBDIR) \
131                 $(DESTDIR)$(VARDIR) \
132                 $(SBIN_PROGS)
133         @$(SHELL) $(srcdir)/script/installbin.sh \
134                 $(INSTALLPERMS) \
135                 $(DESTDIR)$(BASEDIR) \
136                 $(DESTDIR)$(BINDIR) \
137                 $(DESTDIR)$(LIBDIR) \
138                 $(DESTDIR)$(VARDIR) \
139                 $(BIN_PROGS)
140         @$(SHELL) $(srcdir)/script/installtorture.sh \
141                 $(INSTALLPERMS) \
142                 $(DESTDIR)$(TORTUREDIR) \
143                 $(TORTURE_PROGS)
144
145 installlib: $(INSTALLABLE_SHARED_LIBS) $(STATIC_LIBS) installdirs
146         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(SHLIBEXT)" $(INSTALLABLE_SHARED_LIBS) 
147         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(STLIBEXT)" $(STATIC_LIBS)
148
149 installheader: headers installdirs
150         @$(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
151
152 installdat: installdirs
153         @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
154
155 installswat: installdirs
156         @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
157         @$(SHELL) $(srcdir)/script/installjsonrpc.sh $(DESTDIR)$(SERVICESDIR) $(srcdir)
158
159 installman: manpages installdirs
160         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
161
162 installmisc: installdirs
163         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
164
165 installpc: installdirs
166         @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
167
168 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
169         uninstallplugins
170
171 uninstallmisc:
172         #FIXME
173
174 uninstallbin:
175         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
176         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
177         @$(SHELL) $(srcdir)/script/uninstalltorture.sh $(DESTDIR)$(TORTUREDIR) $(TORTURE_PROGS)
178
179 uninstalllib:
180         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
181         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS) 
182
183 uninstallheader:
184         @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
185
186 uninstallman:
187         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
188
189 Makefile: config.status $(MK_FILES)
190         ./config.status
191
192 etags:
193         etags `find $(srcdir) -name "*.[ch]"`
194
195 ctags:
196         ctags `find $(srcdir) -name "*.[ch]"`
197
198 pidl/Makefile: pidl/Makefile.PL
199         cd pidl && $(PERL) Makefile.PL 
200
201 installpidl: pidl/Makefile
202         $(MAKE) -C pidl install
203
204 uninstallpidl: pidl/Makefile
205         $(MAKE) -C pidl uninstall
206
207 $(IDL_HEADER_FILES) \
208         $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
209         $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
210         $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
211         $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES): idl
212
213 idl_full: pidl/lib/Parse/Pidl/IDL.pm
214         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL $(PIDL_ARGS)
215
216 idl: pidl/lib/Parse/Pidl/IDL.pm
217         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL $(PIDL_ARGS)
218
219 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
220         -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\
221                 touch pidl/lib/Parse/Pidl/IDL.pm
222
223 smb_interfaces: pidl/smb_interfaces.pm
224         $(PERL) -Ipidl $(srcdir)/script/build_smb_interfaces.pl \
225                 include/smb_interfaces.h
226
227 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
228         -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp ||\
229                 touch pidl/smb_interfaces.pm
230
231 include/config.h:
232         @echo "include/config.h not present"
233         @echo "You need to rerun ./autogen.sh and ./configure"
234         @/bin/false
235
236 $(srcdir)/version.h: $(srcdir)/VERSION
237         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
238
239 regen_version:
240         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
241
242 clean_pch:
243         @echo "Removing precompiled headers"
244         @-rm -f include/includes.h.gch
245
246 pch: clean_pch include/includes.h.gch
247
248 clean:: clean_pch
249         @echo Removing objects
250         @-find . -name '*.o' -exec rm -f '{}' \;
251         @echo Removing hostcc objects
252         @-find . -name '*.ho' -exec rm -f '{}' \;
253         @echo Removing binaries
254         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
255         @echo Removing libraries
256         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
257         @-rm -f bin/*.$(SHLIBEXT)*
258         @-rm -f bin/*.a
259         @echo Removing modules
260         @-rm -f bin/modules/*/*.$(SHLIBEXT)
261         @-rm -f bin/*_init_module.c
262         @echo Removing dummy targets
263         @-rm -f bin/.*_*
264         @echo Removing generated files
265         @-rm -f bin/*_init_module.c
266         @-rm -rf librpc/gen_* 
267         @echo Removing proto headers
268         @-rm -f $(PROTO_HEADERS)
269
270 distclean: clean
271         -rm -f include/config.h include/config_tmp.h include/build.h
272         -rm -f Makefile 
273         -rm -f config.status
274         -rm -f config.log config.cache
275         -rm -f config.pm config.mk
276         -rm -f $(PC_FILES)
277
278 removebackup:
279         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
280
281 realdistclean: distclean removebackup
282         -rm -f include/config_tmp.h.in
283         -rm -f version.h
284         -rm -f configure
285         -rm -f $(MANPAGES)
286
287 test: $(DEFAULT_TEST_TARGET)
288
289 test-swrap: all
290         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
291
292 test-noswrap: all
293         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all
294
295 quicktest: all
296         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
297
298 testenv: all
299         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} xterm SOCKET_WRAPPER
300
301 valgrindtest: valgrindtest-quick
302
303 valgrindtest-quick: all
304         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
305         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
306         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
307
308 valgrindtest-all: all
309         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
310         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
311         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
312
313 valgrindtest-env: all
314         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
315         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
316         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} xterm SOCKET_WRAPPER
317
318 gdbtest: gdbtest-quick
319
320 gdbtest-quick: all
321         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
322         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
323
324 gdbtest-all: all
325         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
326         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
327
328 wintest: all
329         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} win
330
331 unused_macros:
332         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
333
334 ###############################################################################
335 # File types
336 ###############################################################################
337
338 .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
339
340 .c.d:
341         @echo "Generating dependencies for $<"
342         @$(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
343
344 .c.hd:
345         @echo "Generating host-compiler dependencies for $<"
346         @$(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
347
348 include/includes.d: include/includes.h
349         @echo "Generating dependencies for $<"
350         @$(CC) -M -MG -MT include/includes.h.gch -MT $@ $(CFLAGS) $< -o $@
351
352 #
353 # $< is broken in older BSD versions:
354 # when $@ is foo/bar.o, $< could be torture/foo/bar.c
355 # if it also exists. So better use $* which is foo/bar
356 # and append .c manually to get foo/bar.c
357 #
358 .c.o:
359         @if test -n "$(CC_CHECKER)"; then \
360                 echo "Checking  $*.c with '$(CC_CHECKER)'"; \
361                 $(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@; \
362         fi
363         @echo "Compiling $*.c"
364         @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ && exit 0;\
365                 echo "The following command failed:" 1>&2;\
366                 echo "$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@" 1>&2;\
367                 $(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ >/dev/null 2>&1
368
369 .c.ho:
370         @echo "Compiling $*.c with host compiler"
371         @$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@ && exit 0;\
372                 echo "The following command failed:" 1>&2;\
373                 echo "$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@" 1>&2;\
374                 $(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@ >/dev/null 2>&1
375
376 .h.h.gch:
377         @echo "Precompiling $<"
378         @$(CC) -Ilib/replace `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
379
380 .y.c:
381         @echo "Building $< with $(YACC)"
382         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
383
384 .l.c:
385         @echo "Building $< with $(LEX)"
386         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
387
388 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
389
390 .1.xml.1:
391         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
392
393 .3.xml.3:
394         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
395
396 .5.xml.5:
397         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
398
399 .7.xml.7:
400         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
401
402 .8.xml.8:
403         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
404
405 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
406                    include/includes.d
407
408 dist:: distclean idl_full manpages configure
409
410 configure: 
411         ./autogen.sh
412
413 clean::
414         @echo Removing dependency files
415         @find . -name \*.d -o -name \*.hd | xargs rm -f