1920e047a8f62a247c96ea4c9423018c49306de0
[kai/samba-autobuild/.git] / source4 / main.mk
1 all: basics bin/asn1_compile bin/compile_et binaries
2
3 include heimdal_build/config.mk
4 include config.mk
5 include dsdb/config.mk
6 include gtk/config.mk
7 include smbd/config.mk
8 include smbd/process_model.mk
9 include libnet/config.mk
10 include auth/config.mk
11 include nsswitch/config.mk
12 include lib/basic.mk
13 include param/config.mk
14 include smb_server/config.mk
15 include rpc_server/config.mk
16 include ldap_server/config.mk
17 include web_server/config.mk
18 include winbind/config.mk
19 include nbt_server/config.mk
20 include wrepl_server/config.mk
21 include cldap_server/config.mk
22 include utils/net/config.mk
23 include utils/config.mk
24 include ntvfs/config.mk
25 include ntptr/config.mk
26 include torture/config.mk
27 include librpc/config.mk
28 include client/config.mk
29 include libcli/config.mk
30 include scripting/config.mk
31 include kdc/config.mk
32 include passdb/config.mk
33
34 DEFAULT_HEADERS = $(srcdir)/include/nt_status.h \
35                                   $(srcdir)/include/smb.h $(srcdir)/include/core.h
36
37 binaries: $(BINARIES)
38 libraries: $(STATIC_LIBS) $(SHARED_LIBS)
39 modules: $(SHARED_MODULES)
40 headers: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
41 manpages: $(MANPAGES)
42 everything: all
43
44 showlayout: 
45         @echo 'Samba will be installed into:'
46         @echo '  basedir:     $(BASEDIR)'
47         @echo '  bindir:      $(BINDIR)'
48         @echo '  sbindir:     $(SBINDIR)'
49         @echo '  libdir:      $(LIBDIR)'
50         @echo '  modulesdir:  $(MODULESDIR)'
51         @echo '  includedir:  $(INCLUDEDIR)'
52         @echo '  vardir:      $(VARDIR)'
53         @echo '  privatedir:  $(PRIVATEDIR)'
54         @echo '  piddir:      $(PIDDIR)'
55         @echo '  lockdir:     $(LOCKDIR)'
56         @echo '  logfilebase: $(LOGFILEBASE)'
57         @echo '  setupdir:    $(SETUPDIR)'
58         @echo '  jsdir:       $(JSDIR)'
59         @echo '  swatdir:     $(SWATDIR)'
60         @echo '  mandir:      $(MANDIR)'
61         @echo '  winbindd_socket_dir:  $(WINBINDD_SOCKET_DIR)'
62
63 showflags:
64         @echo 'Samba will be compiled with flags:'
65         @echo '  CFLAGS = $(CFLAGS)'
66         @echo '  LDFLAGS = $(LDFLAGS)'
67         @echo '  STLD_FLAGS = $(STLD_FLAGS)'
68         @echo '  SHLD_FLAGS = $(SHLD_FLAGS)'
69         @echo '  LIBS = $(LIBS)'
70
71 # The permissions to give the executables
72 INSTALLPERMS = 0755
73
74 # set these to where to find various files
75 # These can be overridden by command line switches (see smbd(8))
76 # or in smb.conf (see smb.conf(5))
77 CONFIGFILE = $(CONFIGDIR)/smb.conf
78 PKGCONFIGDIR = $(LIBDIR)/pkgconfig
79 LMHOSTSFILE = $(CONFIGDIR)/lmhosts
80
81 PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\"  -DSBINDIR=\"$(SBINDIR)\" \
82          -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
83          -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DLIBDIR=\"$(LIBDIR)\" \
84          -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
85          -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
86          -DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
87          -DMODULESDIR=\"$(MODULESDIR)\" -DJSDIR=\"$(JSDIR)\" \
88          -DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(WINBINDD_SOCKET_DIR)\"
89
90 install: showlayout installbin installdat installswat installmisc installlib \
91         installheader installpc
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)$(LIBDIR) \
107                 $(DESTDIR)$(VARDIR) \
108                 $(DESTDIR)$(PRIVATEDIR) \
109                 $(DESTDIR)$(PIDDIR) \
110                 $(DESTDIR)$(LOCKDIR) \
111                 $(DESTDIR)$(LOGFILEBASE) \
112                 $(DESTDIR)$(PRIVATEDIR)/tls \
113                 $(DESTDIR)$(INCLUDEDIR) \
114                 $(DESTDIR)$(PKGCONFIGDIR) \
115                 $(DESTDIR)$(CONFIGDIR) \
116
117 installbin: $(SBIN_PROGS) $(BIN_PROGS) installdirs
118         @$(SHELL) $(srcdir)/script/installbin.sh \
119                 $(INSTALLPERMS) \
120                 $(DESTDIR)$(BASEDIR) \
121                 $(DESTDIR)$(SBINDIR) \
122                 $(DESTDIR)$(LIBDIR) \
123                 $(DESTDIR)$(VARDIR) \
124                 $(SBIN_PROGS)
125         @$(SHELL) $(srcdir)/script/installbin.sh \
126                 $(INSTALLPERMS) \
127                 $(DESTDIR)$(BASEDIR) \
128                 $(DESTDIR)$(BINDIR) \
129                 $(DESTDIR)$(LIBDIR) \
130                 $(DESTDIR)$(VARDIR) \
131                 $(BIN_PROGS)
132
133 installlib: libraries installdirs
134         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS) 
135         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS)
136
137 installheader: headers installdirs
138         @$(SHELL) $(srcdir)/script/installheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
139
140 installdat: installdirs
141         @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
142
143 installswat: installdirs
144         @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) $(DESTDIR)$(LIBDIR)
145
146 installman: installdirs
147         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
148
149 installmisc: installdirs
150         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
151
152 installpc: installdirs
153         @$(SHELL) $(srcdir)/script/installpc.sh $(srcdir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
154
155 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader
156
157 uninstallmisc:
158         #FIXME
159
160 uninstallbin:
161         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
162         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
163
164 uninstalllib:
165         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
166         @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS) 
167
168 uninstallheader:
169         @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
170
171 uninstallman:
172         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
173
174 Makefile: config.status $(MK_FILES)
175         ./config.status
176
177 etags:
178         etags `find $(srcdir) -name "*.[ch]"`
179
180 ctags:
181         ctags `find $(srcdir) -name "*.[ch]"`
182
183 pidl/Makefile: pidl/Makefile.PL
184         cd pidl && $(PERL) Makefile.PL
185
186 installpidl: pidl/Makefile
187         cd pidl && $(MAKE) install
188
189 IDL_FILES = $(wildcard librpc/idl/*.idl)
190 IDL_HEADER_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/%.h,$(IDL_FILES))
191 IDL_NDR_HEADER_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.h,$(IDL_FILES))
192 IDL_NDR_PARSE_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.c,$(IDL_FILES))
193 IDL_NDR_CLIENT_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_c.c,$(IDL_FILES))
194 IDL_NDR_SERVER_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_s.c,$(IDL_FILES))
195 IDL_NDR_EJS_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_ejs.c,$(IDL_FILES))
196 IDL_NDR_EJS_H_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_ejs.h,$(IDL_FILES))
197
198 $(IDL_HEADER_FILES): idl
199 $(IDL_NDR_HEADER_FILES): idl
200 $(IDL_NDR_PARSE_C_FILES): idl
201 $(IDL_NDR_CLIENT_C_FILES): idl
202 $(IDL_NDR_SERVER_C_FILES): idl
203 $(IDL_NDR_EJS_C_FILES): idl
204 $(IDL_NDR_EJS_H_FILES): idl
205
206 idl_full: pidl/lib/Parse/Pidl/IDL.pm
207         @CPP="$(CPP)" PERL="$(PERL)" script/build_idl.sh FULL $(PIDL_ARGS)
208
209 idl: pidl/lib/Parse/Pidl/IDL.pm
210         @CPP="$(CPP)" PERL="$(PERL)" 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
215 smb_interfaces: pidl/smb_interfaces.pm
216         $(PERL) -Ipidl script/build_smb_interfaces.pl \
217                 include/smb_interfaces.h
218
219 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
220         -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp 
221
222 include/config.h:
223         @echo "include/config.h not present"
224         @echo "You need to rerun ./autogen.sh and ./configure"
225         @/bin/false
226
227 include/proto.h: $(PROTO_OBJS:.o=.c)
228         @echo "Creating include/proto.h"
229         @$(PERL) $(srcdir)/script/mkproto.pl --public-define=_PROTO_H_ \
230                 --public=include/proto.h --private=include/proto.h \
231                 $(PROTO_OBJS)
232
233 proto: include/proto.h
234
235 librpc/gen_ndr/misc.h: idl
236 librpc/ndr/libndr.h: librpc/ndr/libndr_proto.h librpc/gen_ndr/misc.h
237 librpc/rpc/dcerpc.h: librpc/rpc/dcerpc_proto.h
238 auth/credentials/credentials.h: auth/credentials/credentials_proto.h
239 libcli/nbt/libnbt.h: libcli/nbt/nbt_proto.h
240 lib/charset/charset.h: lib/charset/charset_proto.h
241
242 include/includes.h: \
243                 include/config.h \
244                 include/proto.h \
245                 librpc/ndr/libndr.h \
246                 librpc/rpc/dcerpc.h \
247                 auth/credentials/credentials_proto.h \
248                 libcli/nbt/libnbt.h \
249                 lib/util/util_proto.h \
250                 lib/charset/charset.h \
251                 param/param.h
252
253 clean_pch: 
254         -rm -f include/includes.h.gch
255
256 pch: clean_pch include/includes.h.gch
257
258 basics: include/includes.h \
259         $(PROTO_HEADERS) \
260         idl \
261         heimdal_basics
262
263 clean: heimdal_clean clean_pch
264         @echo Removing headers
265         @-rm -f include/proto.h
266         @echo Removing objects
267         @-find . -name '*.o' -exec rm -f '{}' \;
268         @echo Removing hostcc objects
269         @-find . -name '*.ho' -exec rm -f '{}' \;
270         @echo Removing binaries
271         @-rm -f $(BIN_PROGS) $(SBIN_PROGS)
272         @echo Removing libraries
273         @-rm -f bin/*.$(SHLIBEXT).*
274         @echo Removing dummy targets
275         @-rm -f bin/.*_*
276         @echo Removing generated files
277         @-rm -rf librpc/gen_* 
278         @-rm -f lib/registry/regf.h lib/registry/tdr_regf*
279         @echo Removing proto headers
280         @-rm -f $(PROTO_HEADERS)
281
282 distclean: clean
283         -rm -f include/config.h include/smb_build.h
284         -rm -f Makefile 
285         -rm -f config.status
286         -rm -f config.log config.cache
287         -rm -f samba4-deps.dot
288         -rm -f config.pm config.mk
289
290 removebackup:
291         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
292
293 realdistclean: distclean removebackup
294         -rm -f include/config.h.in
295         -rm -f include/version.h
296         -rm -f configure
297         -rm -f $(MANPAGES)
298
299 test: $(DEFAULT_TEST_TARGET)
300
301 test-swrap: all
302         ./script/tests/selftest.sh ${selftest_prefix}/st all SOCKET_WRAPPER
303
304 test-noswrap: all
305         ./script/tests/selftest.sh ${selftest_prefix}/st all
306
307 quicktest: all
308         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
309
310 valgrindtest: all
311         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
312         VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/st/valgrind.log" \
313         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
314
315 gdbtest: all
316         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
317         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
318
319 unused_macros:
320         ./script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
321
322 ###############################################################################
323 # File types
324 ###############################################################################
325
326 .c.d:
327         @echo "Generating dependencies for $<"
328         @$(CC) -MM -MG -MT $(<:.c=.o) -MF $@ $(CFLAGS) $<
329
330 .y.c:
331         @echo "Building $< with $(YACC)"
332         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
333
334 .l.c:
335         @echo "Building $< with $(LEX)"
336         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
337
338 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
339
340 .1.xml.1:
341         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
342
343 .3.xml.3:
344         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
345
346 .5.xml.5:
347         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
348
349 .7.xml.7:
350         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
351
352 .8.xml.8:
353         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<