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