r14547: Don't install pidl - it fails on the buildfarm as it doesn't obey $PREFIX...
[kai/samba.git] / source4 / main.mk
1 all: basics 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) $(INSTALLABLE_SHARED_LIBS) 
132         @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) $(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_SERVER_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_s.c,$(IDL_FILES))
196 IDL_NDR_EJS_C_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_ejs.c,$(IDL_FILES))
197 IDL_NDR_EJS_H_FILES = $(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%_ejs.h,$(IDL_FILES))
198
199 $(IDL_HEADER_FILES): idl
200 $(IDL_NDR_HEADER_FILES): idl
201 $(IDL_NDR_PARSE_C_FILES): idl
202 $(IDL_NDR_CLIENT_C_FILES): idl
203 $(IDL_NDR_SERVER_C_FILES): idl
204 $(IDL_NDR_EJS_C_FILES): idl
205 $(IDL_NDR_EJS_H_FILES): idl
206
207 idl_full: pidl/lib/Parse/Pidl/IDL.pm
208         @CPP="$(CPP)" PERL="$(PERL)" script/build_idl.sh FULL $(PIDL_ARGS)
209
210 idl: pidl/lib/Parse/Pidl/IDL.pm
211         @CPP="$(CPP)" PERL="$(PERL)" script/build_idl.sh PARTIAL $(PIDL_ARGS)
212
213 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
214         -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp 
215
216 smb_interfaces: pidl/smb_interfaces.pm
217         $(PERL) -Ipidl script/build_smb_interfaces.pl \
218                 include/smb_interfaces.h
219
220 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
221         -$(YAPP) -s -m 'smb_interfaces' -o pidl/smb_interfaces.pm pidl/smb_interfaces.yp 
222
223 include/config.h:
224         @echo "include/config.h not present"
225         @echo "You need to rerun ./autogen.sh and ./configure"
226         @/bin/false
227
228 librpc/gen_ndr/misc.h: idl
229 librpc/ndr/libndr.h: librpc/ndr/libndr_proto.h librpc/gen_ndr/misc.h
230 librpc/rpc/dcerpc.h: librpc/rpc/dcerpc_proto.h
231 auth/credentials/credentials.h: auth/credentials/credentials_proto.h
232 libcli/nbt/libnbt.h: libcli/nbt/nbt_proto.h
233 lib/charset/charset.h: lib/charset/charset_proto.h
234
235 include/includes.h: \
236                 include/config.h \
237                 lib/util/util_proto.h \
238                 lib/charset/charset.h \
239                 param/proto.h \
240                 libcli/util/proto.h \
241                 librpc/gen_ndr/misc.h
242
243 clean_pch: 
244         -rm -f include/includes.h.gch
245
246 pch: clean_pch include/includes.h.gch
247
248 proto: $(PROTO_HEADERS)
249 basics: include/includes.h \
250         proto \
251         idl \
252         heimdal_basics
253
254 clean: heimdal_clean clean_pch
255         @echo Removing objects
256         @-find . -name '*.o' -exec rm -f '{}' \;
257         @echo Removing hostcc objects
258         @-find . -name '*.ho' -exec rm -f '{}' \;
259         @echo Removing binaries
260         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES)
261         @echo Removing libraries
262         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
263         @-rm -f bin/*.$(SHLIBEXT)*
264         @echo Removing modules
265         @-rm -f $(SHARED_MODULES) $(PLUGINS)
266         @-rm -f bin/*_init_module.c
267         @echo Removing dummy targets
268         @-rm -f bin/.*_*
269         @echo Removing generated files
270         @-rm -f bin/*_init_module.c
271         @-rm -rf librpc/gen_* 
272         @-rm -f lib/registry/regf.h lib/registry/tdr_regf*
273         @echo Removing proto headers
274         @-rm -f $(PROTO_HEADERS)
275
276 distclean: clean
277         -rm -f include/config.h include/smb_build.h
278         -rm -f Makefile 
279         -rm -f config.status
280         -rm -f config.log config.cache
281         -rm -f samba4-deps.dot
282         -rm -f config.pm config.mk
283         -rm -f $(PC_FILES)
284
285 removebackup:
286         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
287
288 realdistclean: distclean removebackup
289         -rm -f include/config.h.in
290         -rm -f include/version.h
291         -rm -f configure
292         -rm -f $(MANPAGES)
293
294 test: $(DEFAULT_TEST_TARGET)
295
296 test-swrap: all
297         ./script/tests/selftest.sh ${selftest_prefix}/st all SOCKET_WRAPPER
298
299 test-noswrap: all
300         ./script/tests/selftest.sh ${selftest_prefix}/st all
301
302 quicktest: all
303         ./script/tests/selftest.sh ${selftest_prefix}/st quick 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}/st/valgrind.log" \
310         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
311
312 valgrindtest-all: all
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}/st/valgrind.log" \
315         ./script/tests/selftest.sh ${selftest_prefix}/st all SOCKET_WRAPPER
316
317 gdbtest: gdbtest-quick
318
319 gdbtest-quick: all
320         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
321         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
322
323 gdbtest-all: all
324         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
325         ./script/tests/selftest.sh ${selftest_prefix}/st all SOCKET_WRAPPER
326
327 unused_macros:
328         ./script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
329
330 ###############################################################################
331 # File types
332 ###############################################################################
333
334 .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
335
336 .c.ho:
337         @echo "Compiling $*.c with host compiler"
338         @$(HOSTCC) `script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@
339
340 .c.d:
341         @echo "Generating dependencies for $<"
342         @$(CC) -MM -MG -MT $(<:.c=.o) -MF $@ $(CFLAGS) $<
343
344 .c.o:
345         @if test -n "$(CC_CHECKER)"; then \
346                 echo "Checking  $< with '$(CC_CHECKER)'"; \
347                 $(CC_CHECKER) `script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@; \
348         fi
349         @echo "Compiling $<"
350         @$(CC) `script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
351
352 .h.h.gch:
353         @echo "Precompiling $<"
354         @$(CC) `script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
355
356 .y.c:
357         @echo "Building $< with $(YACC)"
358         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
359
360 .l.c:
361         @echo "Building $< with $(LEX)"
362         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
363
364 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
365
366 .1.xml.1:
367         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
368
369 .3.xml.3:
370         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
371
372 .5.xml.5:
373         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
374
375 .7.xml.7:
376         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
377
378 .8.xml.8:
379         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<