42c471da80e56a705af5fdb0fe6e03ccea5643c3
[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/installbin.sh \
140                 $(INSTALLPERMS) \
141                 $(DESTDIR)$(BASEDIR) \
142                 $(DESTDIR)$(TORTUREDIR) \
143                 $(DESTDIR)$(LIBDIR) \
144                 $(DESTDIR)$(VARDIR) \
145                 $(TORTURE_PROGS)
146
147 installlib: $(INSTALLABLE_SHARED_LIBS) $(STATIC_LIBS) installdirs
148         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(SHLIBEXT)" $(INSTALLABLE_SHARED_LIBS) 
149         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(STLIBEXT)" $(STATIC_LIBS)
150
151 installheader: headers installdirs
152         @$(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
153
154 installdat: installdirs
155         @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
156
157 installswat: installdirs
158         @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
159
160 installman: manpages installdirs
161         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
162
163 installmisc: installdirs
164         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
165
166 installpc: installdirs
167         @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
168
169 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
170         uninstallplugins
171
172 uninstallmisc:
173         #FIXME
174
175 uninstallbin:
176         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
177         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
178         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(TORTUREDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(TORTURE_PROGS)
179
180 uninstalllib:
181         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
182         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS) 
183
184 uninstallheader:
185         @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
186
187 uninstallman:
188         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
189
190 Makefile: config.status $(MK_FILES)
191         ./config.status
192
193 etags:
194         etags `find $(srcdir) -name "*.[ch]"`
195
196 ctags:
197         ctags `find $(srcdir) -name "*.[ch]"`
198
199 pidl/Makefile: pidl/Makefile.PL
200         cd pidl && $(PERL) Makefile.PL 
201
202 installpidl: pidl/Makefile
203         $(MAKE) -C pidl install
204
205 uninstallpidl: pidl/Makefile
206         $(MAKE) -C pidl uninstall
207
208 $(IDL_HEADER_FILES) \
209         $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
210         $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
211         $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
212         $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES): idl
213
214 idl_full: pidl/lib/Parse/Pidl/IDL.pm
215         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL $(PIDL_ARGS)
216
217 idl: pidl/lib/Parse/Pidl/IDL.pm
218         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL $(PIDL_ARGS)
219
220 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
221         -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\
222                 touch pidl/lib/Parse/Pidl/IDL.pm
223
224 smb_interfaces: pidl/smb_interfaces.pm
225         $(PERL) -Ipidl $(srcdir)/script/build_smb_interfaces.pl \
226                 include/smb_interfaces.h
227
228 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
229         -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp ||\
230                 touch pidl/smb_interfaces.pm
231
232 include/config.h:
233         @echo "include/config.h not present"
234         @echo "You need to rerun ./autogen.sh and ./configure"
235         @/bin/false
236
237 $(srcdir)/version.h: $(srcdir)/VERSION
238         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
239
240 regen_version:
241         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
242
243 clean_pch:
244         @echo "Removing precompiled headers"
245         @-rm -f include/includes.h.gch
246
247 pch: clean_pch include/includes.h.gch
248
249 clean:: clean_pch
250         @echo Removing objects
251         @-find . -name '*.o' -exec rm -f '{}' \;
252         @echo Removing hostcc objects
253         @-find . -name '*.ho' -exec rm -f '{}' \;
254         @echo Removing binaries
255         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
256         @echo Removing libraries
257         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
258         @-rm -f bin/*.$(SHLIBEXT)*
259         @-rm -f bin/*.a
260         @echo Removing modules
261         @-rm -f bin/modules/*/*.$(SHLIBEXT)
262         @-rm -f bin/*_init_module.c
263         @echo Removing dummy targets
264         @-rm -f bin/.*_*
265         @echo Removing generated files
266         @-rm -f bin/*_init_module.c
267         @-rm -rf librpc/gen_* 
268         @echo Removing proto headers
269         @-rm -f $(PROTO_HEADERS)
270
271 distclean: clean
272         -rm -f include/config.h include/config_tmp.h include/build.h
273         -rm -f Makefile 
274         -rm -f config.status
275         -rm -f config.log config.cache
276         -rm -f config.pm config.mk
277         -rm -f $(PC_FILES)
278
279 removebackup:
280         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
281
282 realdistclean: distclean removebackup
283         -rm -f include/config_tmp.h.in
284         -rm -f version.h
285         -rm -f configure
286         -rm -f $(MANPAGES)
287
288 test: $(DEFAULT_TEST_TARGET)
289
290 test-swrap: all
291         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
292
293 test-noswrap: all
294         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all
295
296 quicktest: all
297         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
298
299 testenv: all
300         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} xterm SOCKET_WRAPPER
301
302 valgrindtest: valgrindtest-quick
303
304 valgrindtest-quick: all
305         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
306         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
307         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
308
309 valgrindtest-all: all
310         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
311         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
312         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
313
314 gdbtest: gdbtest-quick
315
316 gdbtest-quick: all
317         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
318         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
319
320 gdbtest-all: all
321         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
322         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
323
324 wintest: all
325         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} win
326
327 unused_macros:
328         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
329
330 ###############################################################################
331 # File types
332 ###############################################################################
333
334 .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
335
336 .c.d:
337         @echo "Generating dependencies for $<"
338         @$(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
339
340 .c.hd:
341         @echo "Generating host-compiler dependencies for $<"
342         @$(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
343
344 include/includes.d: include/includes.h
345         @echo "Generating dependencies for $<"
346         @$(CC) -M -MG -MT include/includes.h.gch -MT $@ $(CFLAGS) $< -o $@
347
348 #
349 # $< is broken in older BSD versions:
350 # when $@ is foo/bar.o, $< could be torture/foo/bar.c
351 # if it also exists. So better use $* which is foo/bar
352 # and append .c manually to get foo/bar.c
353 #
354 .c.o:
355         @if test -n "$(CC_CHECKER)"; then \
356                 echo "Checking  $*.c with '$(CC_CHECKER)'"; \
357                 $(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@; \
358         fi
359         @echo "Compiling $*.c"
360         @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ && exit 0;\
361                 echo "The following command failed:" 1>&2;\
362                 echo "$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@" 1>&2;\
363                 $(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ >/dev/null 2>&1
364
365 .c.ho:
366         @echo "Compiling $*.c with host compiler"
367         @$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@ && exit 0;\
368                 echo "The following command failed:" 1>&2;\
369                 echo "$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@" 1>&2;\
370                 $(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@ >/dev/null 2>&1
371
372 .h.h.gch:
373         @echo "Precompiling $<"
374         @$(CC) -Ilib/replace `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
375
376 .y.c:
377         @echo "Building $< with $(YACC)"
378         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
379
380 .l.c:
381         @echo "Building $< with $(LEX)"
382         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
383
384 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
385
386 .1.xml.1:
387         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
388
389 .3.xml.3:
390         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
391
392 .5.xml.5:
393         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
394
395 .7.xml.7:
396         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
397
398 .8.xml.8:
399         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
400
401 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
402                    include/includes.d
403
404 dist:: distclean idl_full manpages configure
405
406 configure: 
407         ./autogen.sh
408
409 clean::
410         @echo Removing dependency files
411         @find . -name \*.d -o -name \*.hd | xargs rm -f
412