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