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