r18210: - reenable autodependencies
[ira/wip.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 '  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 $(IDL_HEADER_FILES) \
192         $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
193         $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
194         $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
195         $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES): idl
196
197 idl_full: pidl/lib/Parse/Pidl/IDL.pm
198         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL $(PIDL_ARGS)
199
200 idl: pidl/lib/Parse/Pidl/IDL.pm
201         @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL $(PIDL_ARGS)
202
203 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
204         -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp 
205
206 smb_interfaces: pidl/smb_interfaces.pm
207         $(PERL) -Ipidl $(srcdir)/script/build_smb_interfaces.pl \
208                 include/smb_interfaces.h
209
210 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
211         -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp 
212
213 include/config.h:
214         @echo "include/config.h not present"
215         @echo "You need to rerun ./autogen.sh and ./configure"
216         @/bin/false
217
218 $(srcdir)/version.h: $(srcdir)/VERSION
219         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
220
221 regen_version:
222         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
223
224 clean_pch:
225         @echo "Removing precompiled headers"
226         @-rm -f include/includes.h.gch
227
228 pch: clean_pch include/includes.h.gch
229
230 clean:: clean_pch
231         @echo Removing objects
232         @-find . -name '*.o' -exec rm -f '{}' \;
233         @echo Removing hostcc objects
234         @-find . -name '*.ho' -exec rm -f '{}' \;
235         @echo Removing binaries
236         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES)
237         @echo Removing libraries
238         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
239         @-rm -f bin/*.$(SHLIBEXT)*
240         @-rm -f bin/*.a
241         @echo Removing modules
242         @-rm -f bin/modules/*/*.$(SHLIBEXT)
243         @-rm -f bin/*_init_module.c
244         @echo Removing dummy targets
245         @-rm -f bin/.*_*
246         @echo Removing generated files
247         @-rm -f bin/*_init_module.c
248         @-rm -rf librpc/gen_* 
249         @echo Removing proto headers
250         @-rm -f $(PROTO_HEADERS)
251
252 distclean: clean
253         -rm -f include/config.h include/config_tmp.h include/build.h
254         -rm -f Makefile 
255         -rm -f config.status
256         -rm -f config.log config.cache
257         -rm -f config.pm config.mk
258         -rm -f $(PC_FILES)
259
260 removebackup:
261         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
262
263 realdistclean: distclean removebackup
264         -rm -f include/config_tmp.h.in
265         -rm -f version.h
266         -rm -f configure
267         -rm -f $(MANPAGES)
268
269 test: $(DEFAULT_TEST_TARGET)
270
271 test-swrap: all
272         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
273
274 test-noswrap: all
275         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all
276
277 quicktest: all
278         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
279
280 valgrindtest: valgrindtest-quick
281
282 valgrindtest-quick: all
283         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
284         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
285         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
286
287 valgrindtest-all: all
288         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
289         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
290         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
291
292 gdbtest: gdbtest-quick
293
294 gdbtest-quick: all
295         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
296         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
297
298 gdbtest-all: all
299         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
300         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
301
302 wintest: all
303         $(srcdir)/script/tests/selftest.sh ${selftest_prefix} win
304
305 unused_macros:
306         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
307
308 ###############################################################################
309 # File types
310 ###############################################################################
311
312 .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
313
314 .c.ho:
315         @echo "Compiling $< with host compiler"
316         @$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $< -o $@
317
318 .c.d:
319         @echo "Generating dependencies for $<"
320         @$(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
321
322 .c.hd:
323         @echo "Generating host-compiler dependencies for $<"
324         @$(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
325
326 include/includes.d: include/includes.h
327         @echo "Generating dependencies for $<"
328         @$(CC) -M -MG -MT include/includes.h.gch -MT $@ $(CFLAGS) $< -o $@
329
330 .c.o:
331         @if test -n "$(CC_CHECKER)"; then \
332                 echo "Checking  $< with '$(CC_CHECKER)'"; \
333                 $(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@; \
334         fi
335         @echo "Compiling $<"
336         @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
337
338 .h.h.gch:
339         @echo "Precompiling $<"
340         @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
341
342 .y.c:
343         @echo "Building $< with $(YACC)"
344         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
345
346 .l.c:
347         @echo "Building $< with $(LEX)"
348         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
349
350 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
351
352 .1.xml.1:
353         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
354
355 .3.xml.3:
356         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
357
358 .5.xml.5:
359         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
360
361 .7.xml.7:
362         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
363
364 .8.xml.8:
365         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
366
367 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
368                    include/includes.d
369
370 dist:: distclean idl_full manpages configure
371
372 configure: 
373         ./autogen.sh
374
375 clean::
376         @echo Removing dependency files
377         @find . -name \*.d -o -name \*.hd | xargs rm -f
378