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