Merge commit 'release-4-0-0alpha1' into v4-0-test
[kai/samba.git] / source / main.mk
1 default: all
2
3 include dynconfig.mk
4 include heimdal_build/config.mk
5 include config.mk
6 include dsdb/config.mk
7 include smbd/config.mk
8 include cluster/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
35 DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
36                   $(srcdir)/version.h
37
38 binaries: $(BINARIES)
39 libraries: $(STATIC_LIBS) $(SHARED_LIBS)
40 modules: $(SHARED_MODULES)
41 headers: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
42 manpages: $(MANPAGES)
43 all: showflags $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries modules
44 everything: all libraries headers
45
46 # 'make testsuite' creates all binaries which are
47 # needed by samba3's 'make test' and the build-farm
48 # scripts use that it as fallback in case
49 # 'make everything' fails
50 testsuite: bin/smbclient bin/cifsdd bin/smbtorture bin/nmblookup
51
52 showlayout: 
53         @echo 'Samba will be installed into:'
54         @echo '  basedir:     $(BASEDIR)'
55         @echo '  bindir:      $(BINDIR)'
56         @echo '  sbindir:     $(SBINDIR)'
57         @echo '  libdir:      $(LIBDIR)'
58         @echo '  modulesdir:  $(MODULESDIR)'
59         @echo '  includedir:  $(INCLUDEDIR)'
60         @echo '  vardir:      $(VARDIR)'
61         @echo '  privatedir:  $(PRIVATEDIR)'
62         @echo '  piddir:      $(PIDDIR)'
63         @echo '  lockdir:     $(LOCKDIR)'
64         @echo '  logfilebase: $(LOGFILEBASE)'
65         @echo '  setupdir:    $(SETUPDIR)'
66         @echo '  jsdir:       $(JSDIR)'
67         @echo '  swatdir:     $(SWATDIR)'
68         @echo '  mandir:      $(MANDIR)'
69         @echo '  torturedir:  $(TORTUREDIR)'
70         @echo '  datadir:     $(DATADIR)'
71         @echo '  winbindd_socket_dir:  $(WINBINDD_SOCKET_DIR)'
72
73 showflags:
74         @echo 'Samba will be compiled with flags:'
75         @echo '  CPP        = $(CPP)'
76         @echo '  CPPFLAGS   = $(CPPFLAGS)'
77         @echo '  CC         = $(CC)'
78         @echo '  CFLAGS     = $(CFLAGS)'
79         @echo '  PICFLAG    = $(PICFLAG)'
80         @echo '  LD         = $(LD)'
81         @echo '  LDFLAGS    = $(LDFLAGS)'
82         @echo '  STLD       = $(STLD)'
83         @echo '  STLD_FLAGS = $(STLD_FLAGS)'
84         @echo '  SHLD       = $(SHLD)'
85         @echo '  SHLD_FLAGS = $(SHLD_FLAGS)'
86         @echo '  SHLIBEXT   = $(SHLIBEXT)'
87         @echo '  srcdir     = $(srcdir)'
88         @echo '  builddir   = $(builddir)'
89         @echo '  pwd        = '`/bin/pwd`
90
91 # The permissions to give the executables
92 INSTALLPERMS = 0755
93
94 install: showlayout everything 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         @srcdir=$(srcdir) builddir=$(builddir) $(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
158 installman: manpages installdirs
159         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
160
161 installmisc: installdirs
162         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
163
164 installpc: installdirs
165         @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
166
167 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
168         uninstallplugins
169
170 uninstallmisc:
171         #FIXME
172
173 uninstallbin:
174         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
175         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
176         @$(SHELL) $(srcdir)/script/uninstalltorture.sh $(DESTDIR)$(TORTUREDIR) $(TORTURE_PROGS)
177
178 uninstalllib:
179         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
180         #@$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS) 
181
182 uninstallheader:
183         @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
184
185 uninstallman:
186         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
187
188 Makefile: config.status $(MK_FILES)
189         ./config.status
190
191 etags:
192         etags `find $(srcdir) -name "*.[ch]"`
193
194 ctags:
195         ctags `find $(srcdir) -name "*.[ch]"`
196
197 pidl/Makefile: pidl/Makefile.PL
198         cd pidl && $(PERL) Makefile.PL 
199
200 testcov-html:: pidl-testcov
201
202 pidl-testcov: pidl/Makefile
203         cd pidl && cover -test
204
205 installpidl: pidl/Makefile
206         $(MAKE) -C pidl install
207
208 uninstallpidl: pidl/Makefile
209         $(MAKE) -C pidl uninstall
210
211 $(IDL_HEADER_FILES) \
212         $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
213         $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
214         $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
215         $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES): idl
216
217 idl_full: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm 
218         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL
219
220 idl: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm 
221         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL 
222
223 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
224         -$(YAPP) -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\
225                 touch pidl/lib/Parse/Pidl/IDL.pm 
226
227 pidl/lib/Parse/Pidl/Expr.pm: pidl/idl.yp
228         -$(YAPP) -m 'Parse::Pidl::Expr' -o pidl/lib/Parse/Pidl/Expr.pm pidl/expr.yp ||\
229                 touch pidl/lib/Parse/Pidl/Expr.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/static/*.a bin/shared/*.$(SHLIBEXT)
258         @echo Removing modules
259         @-rm -f bin/modules/*/*.$(SHLIBEXT)
260         @-rm -f bin/*_init_module.c
261         @echo Removing dummy targets
262         @-rm -f bin/.*_*
263         @echo Removing generated files
264         @-rm -f bin/*_init_module.c
265         @-rm -rf librpc/gen_* 
266         @echo Removing proto headers
267         @-rm -f $(PROTO_HEADERS)
268
269 distclean: clean
270         -rm -f include/config.h include/config_tmp.h include/build.h
271         -rm -f Makefile 
272         -rm -f config.status
273         -rm -f config.log config.cache
274         -rm -f config.pm config.mk
275         -rm -f $(PC_FILES)
276
277 removebackup:
278         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
279
280 realdistclean: distclean removebackup
281         -rm -f include/config_tmp.h.in
282         -rm -f version.h
283         -rm -f configure
284         -rm -f $(MANPAGES)
285
286 check:: test
287
288 SELFTEST = $(PERL) $(srcdir)/selftest/selftest.pl --prefix=${selftest_prefix} \
289     --builddir=$(builddir) --srcdir=$(srcdir) \
290     --expected-failures=$(srcdir)/samba4-knownfail \
291     --skip=$(srcdir)/samba4-skip \
292     $(TEST_OPTIONS) 
293
294 htmltest: everything
295         $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --format=html $(TESTS)
296
297 test: everything
298         $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS)
299
300 testone: everything
301         $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS)
302
303 test-swrap: everything
304         $(SELFTEST) --socket-wrapper --immediate $(TESTS)
305
306 test-noswrap: everything
307         $(SELFTEST) --immediate $(TESTS)
308
309 quicktest: all
310         $(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
311
312 htmlquicktest: all
313         $(SELFTEST) --quick --socket-wrapper --format=html --immediate $(TESTS)
314
315 quicktestone: all
316         $(SELFTEST) --quick --socket-wrapper --one $(TESTS)
317
318 testenv: everything
319         $(SELFTEST) --socket-wrapper --testenv
320
321 valgrindtest: valgrindtest-all
322
323 valgrindtest-quick: all
324         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
325         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
326         $(SELFTEST) --quick --immediate --socket-wrapper $(TESTS)
327
328 valgrindtest-all: everything
329         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
330         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
331         $(SELFTEST) --immediate --socket-wrapper $(TESTS)
332
333 valgrindtest-env: everything
334         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
335         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
336         $(SELFTEST) --socket-wrapper --testenv
337
338 gdbtest: gdbtest-all
339
340 gdbtest-quick: all
341         SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \
342         $(SELFTEST) --immediate --quick --socket-wrapper $(TESTS)
343
344 gdbtest-all: everything
345         SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \
346         $(SELFTEST) --immediate --socket-wrapper $(TESTS)
347
348 gdbtest-env: everything
349         SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \
350         $(SELFTEST) --socket-wrapper --testenv
351
352 wintest: all
353         $(SELFTEST) win
354
355 unused_macros:
356         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
357
358 ###############################################################################
359 # File types
360 ###############################################################################
361
362 .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
363
364 .c.d:
365         @echo "Generating dependencies for $<"
366         @$(DEPENDS)
367
368 .c.hd:
369         @echo "Generating host-compiler dependencies for $<"
370         @$(HDEPENDS)
371
372 include/includes.d: include/includes.h
373         @echo "Generating dependencies for $<"
374         @$(PCHDEPENDS)
375
376 .c.o:
377         @if test -n "$(CC_CHECKER)"; then \
378                 echo "Checking  $< with '$(CC_CHECKER)'"; \
379                 $(CHECK) ; \
380         fi
381         @echo "Compiling $<"
382         @-mkdir -p `dirname $@`
383         @$(COMPILE) && exit 0 ; \
384                 echo "The following command failed:" 1>&2;\
385                 echo "$(COMPILE)" 1>&2;\
386                 $(COMPILE) >/dev/null 2>&1
387
388 .c.ho:
389         @echo "Compiling $< with host compiler"
390         @-mkdir -p `dirname $@`
391         @$(HCOMPILE) && exit 0;\
392                 echo "The following command failed:" 1>&2;\
393                 echo "$(HCOMPILE)" 1>&2;\
394                 $(HCOMPILE) >/dev/null 2>&1
395
396 .h.h.gch:
397         @echo "Precompiling $<"
398         @$(PCHCOMPILE)
399
400 .y.c:
401         @echo "Building $< with $(YACC)"
402         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
403
404 .l.c:
405         @echo "Building $< with $(LEX)"
406         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
407
408 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
409
410 .1.xml.1:
411         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
412
413 .3.xml.3:
414         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
415
416 .5.xml.5:
417         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
418
419 .7.xml.7:
420         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
421
422 .8.xml.8:
423         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
424
425 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
426                    include/includes.d
427
428 dist:: idl_full manpages configure distclean 
429
430 configure: 
431         ./autogen.sh