r14349: Kill proto.h!
[jelmer/samba4-debian.git] / source / 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         @$(SHELL) $(srcdir)/script/installheader.sh $(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/param.h \
237                 libcli/util/proto.h \
238                 librpc/ndr/ndr_orpc_proto.h \
239                 libcli/nbt/nbtname.h \
240                 librpc/ndr/ndr_sec.h \
241                 librpc/ndr/ndr_drsuapi.h \
242                 librpc/ndr/ndr_spoolss_buf.h \
243                 librpc/ndr/ndr_krb5pac.h \
244                 librpc/ndr/ndr_compression.h
245
246 clean_pch: 
247         -rm -f include/includes.h.gch
248
249 pch: clean_pch include/includes.h.gch
250
251 basics: include/includes.h \
252         $(PROTO_HEADERS) \
253         idl \
254         heimdal_basics
255
256 clean: heimdal_clean clean_pch
257         @echo Removing objects
258         @-find . -name '*.o' -exec rm -f '{}' \;
259         @echo Removing hostcc objects
260         @-find . -name '*.ho' -exec rm -f '{}' \;
261         @echo Removing binaries
262         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES)
263         @echo Removing libraries
264         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
265         @-rm -f bin/*.$(SHLIBEXT)*
266         @echo Removing modules
267         @-rm -f $(SHARED_MODULES) $(PLUGINS)
268         @-rm -f bin/*_init_module.c
269         @echo Removing dummy targets
270         @-rm -f bin/.*_*
271         @echo Removing generated files
272         @-rm -f bin/*_init_module.c
273         @-rm -rf librpc/gen_* 
274         @-rm -f lib/registry/regf.h lib/registry/tdr_regf*
275         @echo Removing proto headers
276         @-rm -f $(PROTO_HEADERS)
277
278 distclean: clean
279         -rm -f include/config.h include/smb_build.h
280         -rm -f Makefile 
281         -rm -f config.status
282         -rm -f config.log config.cache
283         -rm -f samba4-deps.dot
284         -rm -f config.pm config.mk
285         -rm -f $(PC_FILES)
286
287 removebackup:
288         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
289
290 realdistclean: distclean removebackup
291         -rm -f include/config.h.in
292         -rm -f include/version.h
293         -rm -f configure
294         -rm -f $(MANPAGES)
295
296 test: $(DEFAULT_TEST_TARGET)
297
298 test-swrap: all
299         ./script/tests/selftest.sh ${selftest_prefix}/st all SOCKET_WRAPPER
300
301 test-noswrap: all
302         ./script/tests/selftest.sh ${selftest_prefix}/st all
303
304 quicktest: all
305         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
306
307 valgrindtest: 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 gdbtest: all
313         SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
314         ./script/tests/selftest.sh ${selftest_prefix}/st quick SOCKET_WRAPPER
315
316 unused_macros:
317         ./script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
318
319 ###############################################################################
320 # File types
321 ###############################################################################
322
323 .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
324
325 .c.ho:
326         @echo Compiling $*.c with host compiler
327         @$(HOSTCC) `script/cflags.pl $@` $(CFLAGS) -c $*.c -o $@
328
329 .c.d:
330         @echo "Generating dependencies for $<"
331         @$(CC) -MM -MG -MT $(<:.c=.o) -MF $@ $(CFLAGS) $<
332
333 .c.o:
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) $<