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