r19350: Properly list LOCAL-TALLOC under the "LOCAL" header.
[samba.git] / source / 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 '  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) 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
157 installman: manpages installdirs
158         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
159
160 installmisc: installdirs
161         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
162
163 installpc: installdirs
164         @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
165
166 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
167         uninstallplugins
168
169 uninstallmisc:
170         #FIXME
171
172 uninstallbin:
173         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
174         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
175         @$(SHELL) $(srcdir)/script/uninstalltorture.sh $(DESTDIR)$(TORTUREDIR) $(TORTURE_PROGS)
176
177 uninstalllib:
178         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
179         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS) 
180
181 uninstallheader:
182         @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
183
184 uninstallman:
185         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
186
187 Makefile: config.status $(MK_FILES)
188         ./config.status
189
190 etags:
191         etags `find $(srcdir) -name "*.[ch]"`
192
193 ctags:
194         ctags `find $(srcdir) -name "*.[ch]"`
195
196 pidl/Makefile: pidl/Makefile.PL
197         cd pidl && $(PERL) Makefile.PL 
198
199 installpidl: pidl/Makefile
200         $(MAKE) -C pidl install
201
202 uninstallpidl: pidl/Makefile
203         $(MAKE) -C pidl uninstall
204
205 $(IDL_HEADER_FILES) \
206         $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
207         $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
208         $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
209         $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES): idl
210
211 idl_full: pidl/lib/Parse/Pidl/IDL.pm
212         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL $(PIDL_ARGS)
213
214 idl: pidl/lib/Parse/Pidl/IDL.pm
215         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL $(PIDL_ARGS)
216
217 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
218         -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\
219                 touch pidl/lib/Parse/Pidl/IDL.pm
220
221 smb_interfaces: pidl/smb_interfaces.pm
222         $(PERL) -Ipidl $(srcdir)/script/build_smb_interfaces.pl \
223                 include/smb_interfaces.h
224
225 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
226         -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp ||\
227                 touch pidl/smb_interfaces.pm
228
229 include/config.h:
230         @echo "include/config.h not present"
231         @echo "You need to rerun ./autogen.sh and ./configure"
232         @/bin/false
233
234 $(srcdir)/version.h: $(srcdir)/VERSION
235         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
236
237 regen_version:
238         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
239
240 clean_pch:
241         @echo "Removing precompiled headers"
242         @-rm -f include/includes.h.gch
243
244 pch: clean_pch include/includes.h.gch
245
246 clean:: clean_pch
247         @echo Removing objects
248         @-find . -name '*.o' -exec rm -f '{}' \;
249         @echo Removing hostcc objects
250         @-find . -name '*.ho' -exec rm -f '{}' \;
251         @echo Removing binaries
252         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
253         @echo Removing libraries
254         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
255         @-rm -f bin/*.$(SHLIBEXT)*
256         @-rm -f bin/*.a
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 gdbtest: gdbtest-quick
312
313 gdbtest-quick: all
314         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
315         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
316
317 gdbtest-all: all
318         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
319         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
320
321 wintest: all
322         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} win
323
324 unused_macros:
325         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
326
327 ###############################################################################
328 # File types
329 ###############################################################################
330
331 .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
332
333 .c.d:
334         @echo "Generating dependencies for $<"
335         @$(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
336
337 .c.hd:
338         @echo "Generating host-compiler dependencies for $<"
339         @$(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
340
341 include/includes.d: include/includes.h
342         @echo "Generating dependencies for $<"
343         @$(CC) -M -MG -MT include/includes.h.gch -MT $@ $(CFLAGS) $< -o $@
344
345 #
346 # $< is broken in older BSD versions:
347 # when $@ is foo/bar.o, $< could be torture/foo/bar.c
348 # if it also exists. So better use $* which is foo/bar
349 # and append .c manually to get foo/bar.c
350 #
351 .c.o:
352         @if test -n "$(CC_CHECKER)"; then \
353                 echo "Checking  $*.c with '$(CC_CHECKER)'"; \
354                 $(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@; \
355         fi
356         @echo "Compiling $*.c"
357         @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ && exit 0;\
358                 echo "The following command failed:" 1>&2;\
359                 echo "$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@" 1>&2;\
360                 $(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ >/dev/null 2>&1
361
362 .c.ho:
363         @echo "Compiling $*.c with host compiler"
364         @$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@ && exit 0;\
365                 echo "The following command failed:" 1>&2;\
366                 echo "$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@" 1>&2;\
367                 $(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@ >/dev/null 2>&1
368
369 .h.h.gch:
370         @echo "Precompiling $<"
371         @$(CC) -Ilib/replace `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
372
373 .y.c:
374         @echo "Building $< with $(YACC)"
375         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
376
377 .l.c:
378         @echo "Building $< with $(LEX)"
379         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
380
381 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
382
383 .1.xml.1:
384         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
385
386 .3.xml.3:
387         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
388
389 .5.xml.5:
390         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
391
392 .7.xml.7:
393         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
394
395 .8.xml.8:
396         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
397
398 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
399                    include/includes.d
400
401 dist:: distclean idl_full manpages configure
402
403 configure: 
404         ./autogen.sh
405
406 clean::
407         @echo Removing dependency files
408         @find . -name \*.d -o -name \*.hd | xargs rm -f
409