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