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