r8826: Make configure generate config.mk files (with the external libraries
[nivanova/samba-autobuild/.git] / source4 / build / smb_build / makefile.pm
1 ###########################################################
2 ### SMB Build System                                    ###
3 ### - create output for Makefile                        ###
4 ###                                                     ###
5 ###  Copyright (C) Stefan (metze) Metzmacher 2004       ###
6 ###  Released under the GNU GPL                         ###
7 ###########################################################
8
9 package makefile;
10 use strict;
11
12 sub _prepare_command_interpreters($)
13 {
14         my $ctx = shift;
15
16         return << '__EOD__';
17 SHELL=/bin/sh
18 PERL=@PERL@
19
20 __EOD__
21 }
22
23 sub _prepare_path_vars($)
24 {
25         my $ctx = shift;
26         my $output;
27
28         $output = << '__EOD__';
29 prefix=@prefix@
30 exec_prefix=@exec_prefix@
31 VPATH=@srcdir@
32 srcdir=@srcdir@
33 builddir=@builddir@
34
35 BASEDIR= @prefix@
36 BINDIR = @bindir@
37 SBINDIR = @sbindir@
38 LIBDIR = @libdir@
39 CONFIGDIR = @configdir@
40 VARDIR = @localstatedir@
41 SWATDIR = @swatdir@
42
43 # The permissions to give the executables
44 INSTALLPERMS = 0755
45
46 # set these to where to find various files
47 # These can be overridden by command line switches (see smbd(8))
48 # or in smb.conf (see smb.conf(5))
49 LOGFILEBASE = @logfilebase@
50 CONFIGFILE = $(CONFIGDIR)/smb.conf
51 LMHOSTSFILE = $(CONFIGDIR)/lmhosts
52 NCALRPCDIR = @localstatedir@/ncalrpc
53
54 # This is where smbpasswd et al go
55 PRIVATEDIR = @privatedir@
56 SMB_PASSWD_FILE = $(PRIVATEDIR)/smbpasswd
57
58 # the directory where lock files go
59 LOCKDIR = @lockdir@
60
61 # the directory where pid files go
62 PIDDIR = @piddir@
63
64 MANDIR = @mandir@
65
66 PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\"  -DSBINDIR=\"$(SBINDIR)\" \
67          -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
68          -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DLIBDIR=\"$(LIBDIR)\" \
69          -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"@SHLIBEXT@\" \
70          -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
71          -DSWATDIR=\"$(SWATDIR)\" -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \
72          -DPRIVATE_DIR=\"$(PRIVATEDIR)\"
73 __EOD__
74
75         return $output;
76 }
77
78 sub _prepare_compiler_linker($)
79 {
80         my $ctx = shift;
81
82         return << '__EOD__';
83 CC=@CC@
84 CFLAGS=-Iinclude -I. -I$(srcdir)/include -I$(srcdir) -D_SAMBA_BUILD_ -DHAVE_CONFIG_H -Ilib @CFLAGS@ @CPPFLAGS@
85
86 LD=@CC@
87 LD_FLAGS=@LDFLAGS@ @CFLAGS@ -Lbin
88
89 STLD=ar
90 STLD_FLAGS=-rc
91
92 SHLD=@CC@
93 SHLD_FLAGS=@LDSHFLAGS@ @LDFLAGS@ -Lbin
94
95 XSLTPROC=@XSLTPROC@
96
97 __EOD__
98 }
99
100 sub _prepare_default_rule($)
101 {
102         my $ctx = shift;
103         my $output;
104
105         $output = << '__EOD__';
106 default: all
107
108 __EOD__
109
110         return $output;
111 }
112
113 sub _prepare_SUFFIXES($)
114 {
115         my $ctx = shift;
116         my $output;
117
118         $output = << '__EOD__';
119 .SUFFIXES:
120 .SUFFIXES: .c .o .h .h.gch .a .so .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml
121
122 __EOD__
123
124         return $output;
125 }
126
127 sub _prepare_IDL($)
128 {
129         my $ctx = shift;
130
131         return << '__EOD__';
132 idl_full: build/pidl/Parse/Pidl/IDL.pm
133         CPP="@CPP@" PERL="$(PERL)" script/build_idl.sh FULL @PIDL_ARGS@
134
135 idl: build/pidl/Parse/Pidl/IDL.pm
136         @CPP="@CPP@" PERL="$(PERL)" script/build_idl.sh PARTIAL @PIDL_ARGS@
137
138 build/pidl/Parse/Pidl/IDL.pm: build/pidl/idl.yp
139         -yapp -s -m 'Parse::Pidl::IDL' -o build/pidl/Parse/Pidl/IDL.pm build/pidl/idl.yp 
140
141 pch: proto include/includes.h.gch
142
143 pch_clean:
144         -rm -f include/includes.h.gch
145
146 basics: idl proto_exists HEIMDAL_EXTERNAL
147
148 test: @DEFAULT_TEST_TARGET@
149
150 test-swrap: all
151         ./script/tests/selftest.sh @selftest_prefix@/st all SOCKET_WRAPPER
152
153 test-noswrap: all
154         ./script/tests/selftest.sh @selftest_prefix@/st all
155
156 quicktest: all
157         ./script/tests/selftest.sh @selftest_prefix@/st quick SOCKET_WRAPPER
158
159 valgrindtest: all
160         SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
161         ./script/tests/selftest.sh @selftest_prefix@/st quick SOCKET_WRAPPER
162
163 __EOD__
164 }
165
166 sub _prepare_man_rule($)
167 {
168         my $suffix = shift;
169
170         return << "__EOD__";
171 .$suffix.xml.$suffix:
172         \$(XSLTPROC) -o \$@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \$<
173
174 __EOD__
175 }
176
177 sub _prepare_manpages($)
178 {
179         my $ctx = shift;
180
181         my @mp_list = ();
182
183         foreach (values %$ctx) {
184                 if (defined($_->{MANPAGE}) and $_->{MANPAGE} ne "") {
185                         push (@mp_list, $_->{MANPAGE});
186                 }
187         }
188         
189         my $mp = join(' ', @mp_list);
190         return << "__EOD__";
191 MANPAGES = $mp
192
193 manpages: \$(MANPAGES)
194
195 __EOD__
196 }
197
198 sub _prepare_dummy_MAKEDIR()
199 {
200         my $ctx = shift;
201
202         return  << '__EOD__';
203 bin/.dummy:
204         @: >> $@ || : > $@
205
206 dynconfig.o: dynconfig.c Makefile
207         @echo Compiling $*.c
208         @$(CC) $(CFLAGS) @PICFLAG@ $(PATH_FLAGS) -c $< -o $@
209 @BROKEN_CC@     -mv `echo $@ | sed 's%^.*/%%g'` $@
210
211 __EOD__
212 }
213
214 ###########################################################
215 # This function creates a standard make rule which is using $(CC)
216 #
217 # $output = _prepare_std_CC_rule($srcext,$destext,$flags,$message,$comment)
218 #
219 # $srcext -     sourcefile extension
220 #
221 # $destext -    destinationfile extension
222 #
223 # $flags -      additional compiler flags
224 #
225 # $message -    logmessage which is echoed while running this rule
226 #
227 # $comment -    just a comment what this rule should do
228 #
229 # $output -             the resulting output buffer
230 sub _prepare_std_CC_rule($$$$$)
231 {
232         my $src = shift;
233         my $dst = shift;
234         my $flags = shift;
235         my $message = shift;
236         my $comment = shift;
237         my $flagsstr = "";
238         my $output;
239
240         $output = << "__EOD__";
241 # $comment
242 .$src.$dst:
243         \@echo $message \$\*.$src
244         \@\$(CC) `script/cflags.sh \$\@` \$(CFLAGS) $flags -c \$< -o \$\@
245 \@BROKEN_CC\@   -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@
246
247 __EOD__
248
249         return $output;
250 }
251
252 sub array2oneperline($)
253 {
254         my $array = shift;
255         my $output = "";
256
257         foreach (@$array) {
258                 next unless defined($_);
259
260                 $output .= " \\\n\t\t$_";
261         }
262
263         return $output;
264 }
265
266 sub array2oneline($)
267 {
268         my $array = shift;
269         my $i;
270         my $output = "";
271
272         foreach (@{$array}) {
273                 next unless defined($_);
274
275                 $output .= "$_ ";
276         }
277
278         return $output;
279 }
280
281 ###########################################################
282 # This function creates a object file list
283 #
284 # $output = _prepare_var_obj_list($var, $var_ctx)
285 #
286 # $var_ctx -            the subsystem context
287 #
288 # $var_ctx->{NAME}      -       the <var> name
289 # $var_ctx->{OBJ_LIST}  -       the list of objectfiles which sould be linked to this <var>
290 #
291 # $output -             the resulting output buffer
292 sub _prepare_obj_list($$)
293 {
294         my ($var,$ctx) = @_;
295
296         my $tmplist = array2oneperline($ctx->{OBJ_LIST});
297
298         return << "__EOD__";
299 # $var $ctx->{NAME} OBJ LIST
300 $var\_$ctx->{NAME}_OBJS =$tmplist
301
302 __EOD__
303 }
304
305 sub _prepare_cflags($$)
306 {
307         my ($var,$ctx) = @_;
308
309         my $tmplist = array2oneperline($ctx->{CFLAGS});
310
311         return << "__EOD__";
312 $var\_$ctx->{NAME}_CFLAGS =$tmplist
313
314 __EOD__
315 }
316
317 ###########################################################
318 # This function creates a make rule for linking a library
319 #
320 # $output = _prepare_shared_library_rule($library_ctx)
321 #
322 # $library_ctx -                the library context
323 #
324 # $library_ctx->{NAME} -                the library name
325 #
326 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
327 #
328 # $library_ctx->{LIBRARY_NAME} -        the shared library name
329 # $library_ctx->{LIBRARY_REALNAME} -    the shared library real name
330 # $library_ctx->{LIBRARY_SONAME} - the shared library soname
331 # $library_ctx->{LINK_LIST} -   the list of objectfiles and external libraries
332 #                                       which sould be linked to this shared library
333 # $library_ctx->{LINK_FLAGS} -  linker flags used by this shared library
334 #
335 # $output -             the resulting output buffer
336 sub _prepare_shared_library_rule($)
337 {
338         my $ctx = shift;
339         my $tmpdepend;
340         my $tmpstlink;
341         my $tmpstflag;
342         my $tmpshlink;
343         my $tmpshflag;
344         my $tmprules;
345         my $output;
346
347         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
348         $tmpshlink = array2oneperline($ctx->{LINK_LIST});
349         $tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
350
351         $output = << "__EOD__";
352 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
353 #
354 LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink
355 LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag
356 #
357
358 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
359         \@echo Linking \$\@
360         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
361                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\
362                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST)
363
364 __EOD__
365
366         if (defined($ctx->{LIBRARY_SONAME})) {
367             $output .= << "__EOD__";
368 # Symlink $ctx->{LIBRARY_SONAME}
369 bin/$ctx->{LIBRARY_SONAME}: bin/$ctx->{LIBRARY_REALNAME} bin/.dummy
370         \@echo Symlink \$\@
371         \@ln -sf $ctx->{LIBRARY_REALNAME} \$\@
372 # Symlink $ctx->{LIBRARY_NAME}
373 bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy
374         \@echo Symlink \$\@
375         \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
376
377 __EOD__
378         }
379
380 $output .= << "__EOD__";
381 library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}
382
383 __EOD__
384
385         return $output;
386 }
387
388 sub _prepare_objlist_rule($)
389 {
390         my $ctx = shift;
391         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
392         my $output;
393
394         return "" unless $ctx->{TARGET};
395
396         $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
397         $output .= "$ctx->{TARGET}: ";
398         $output .= "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
399         $output .= "\t\@touch $ctx->{TARGET}\n";
400
401         return $output;
402 }
403
404 ###########################################################
405 # This function creates a make rule for linking a library
406 #
407 # $output = _prepare_static_library_rule($library_ctx)
408 #
409 # $library_ctx -                the library context
410 #
411 # $library_ctx->{NAME} -                the library name
412 #
413 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
414 #
415 # $library_ctx->{LIBRARY_NAME} -        the static library name
416 # $library_ctx->{LINK_LIST} -   the list of objectfiles which sould be linked
417 #                                       to this static library
418 # $library_ctx->{LINK_FLAGS} -  linker flags used by this static library
419 #
420 # $output -             the resulting output buffer
421 sub _prepare_static_library_rule($)
422 {
423         my $ctx = shift;
424         my $tmpdepend;
425         my $tmpstlink;
426         my $tmpstflag;
427         my $tmpshlink;
428         my $tmpshflag;
429         my $tmprules;
430         my $output;
431
432         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
433         $tmpstlink = array2oneperline($ctx->{LINK_LIST});
434         $tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
435
436         $output = << "__EOD__";
437 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
438 #
439 LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink
440 #
441 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
442         \@echo Linking \$@
443         \@\$(STLD) \$(STLD_FLAGS) \$@ \\
444                 \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST)
445
446 library_$ctx->{NAME}: basics $ctx->{TARGET}
447
448 __EOD__
449
450         return $output;
451 }
452
453 ###########################################################
454 # This function creates a make rule for linking a binary
455 #
456 # $output = _prepare_binary_rule($binary_ctx)
457 #
458 # $binary_ctx -         the binary context
459 #
460 # $binary_ctx->{NAME} -         the binary name
461 # $binary_ctx->{BINARY} -       the binary binary name
462 #
463 # $binary_ctx->{DEPEND_LIST} -  the list of rules on which this binary depends
464 # $binary_ctx->{LINK_LIST} -    the list of objectfiles and external libraries
465 #                               which sould be linked to this binary
466 # $binary_ctx->{LINK_FLAGS} -   linker flags used by this binary
467 #
468 # $output -             the resulting output buffer
469 sub _prepare_binary_rule($)
470 {
471         my $ctx = shift;
472         my $tmpdepend;
473         my $tmplink;
474         my $tmpflag;
475         my $output;
476
477         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
478         $tmplink = array2oneperline($ctx->{LINK_LIST});
479         $tmpflag = array2oneperline($ctx->{LINK_FLAGS});
480
481         $output = << "__EOD__";
482 #
483 BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
484 BINARY_$ctx->{NAME}_LINK_LIST =$tmplink
485 BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag
486 #
487 bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) \$(BINARY_$ctx->{NAME}_OBJS)
488         \@echo Linking \$\@
489         \@\$(LD) \$(LD_FLAGS) -o \$\@ \\
490                 \$\(BINARY_$ctx->{NAME}_LINK_FLAGS) \\
491                 \$\(BINARY_$ctx->{NAME}_LINK_LIST) \\
492                 \$\(BINARY_$ctx->{NAME}_LINK_FLAGS)
493 binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY}
494
495 __EOD__
496
497         return $output;
498 }
499
500 sub _prepare_custom_rule($)
501 {
502         my $ctx = shift;
503         return "
504 $ctx->{NAME}: bin/.TARGET_$ctx->{NAME}
505
506 bin/.TARGET_$ctx->{NAME}:
507         $ctx->{CMD}
508         touch bin/.TARGET_$ctx->{NAME}
509 ";
510 }
511
512 sub _prepare_proto_rules()
513 {
514         my $output = "";
515
516         $output .= << '__EOD__';
517 # Making this target will just make sure that the prototype files
518 # exist, not necessarily that they are up to date.  Since they're
519 # removed by 'make clean' this will always be run when you do anything
520 # afterwards.
521 proto_exists: include/proto.h
522
523 delheaders: pch_clean
524         -rm -f $(builddir)/include/proto.h
525
526 include/proto.h:
527         @cd $(srcdir) && $(SHELL) script/mkproto.sh "$(PERL)" \
528           -h _PROTO_H_ $(builddir)/include/proto.h \
529           $(PROTO_PROTO_OBJS)
530
531 # 'make headers' or 'make proto' calls a subshell because we need to
532 # make sure these commands are executed in sequence even for a
533 # parallel make.
534 headers: delheaders proto_exists
535
536 proto: idl headers
537
538 proto_test:
539         @[ -f $(builddir)/include/proto.h ] || $(MAKE) proto
540
541 clean: delheaders
542         @echo Removing objects
543         @-find . -name '*.o' -exec rm -f '{}' \;
544         @echo Removing binaries
545         @-rm -f bin/*
546         @echo Removing dummy targets
547         @-rm -f bin/.*_*
548         @echo Removing generated files
549         @-rm -rf librpc/gen_*
550         @echo Removing generated ASN1 files
551         @-find heimdal/lib/asn1 -name 'asn1_*.[xc]' -exec rm -f '{}' \;
552         @-find heimdal/lib/gssapi -name 'asn1_*.[xc]' -exec rm -f '{}' \;
553         @-find heimdal/lib/hdb -name 'asn1_*.[xc]' -exec rm -f '{}' \;
554
555 distclean: clean
556         -rm -f bin/.dummy
557         -rm -f include/config.h include/smb_build.h
558         -rm -f Makefile*
559         -rm -f config.status
560         -rm -f config.log config.cache
561         -rm -f samba4-deps.dot
562         -rm -f lib/registry/winregistry.pc
563
564 removebackup:
565         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
566
567 realdistclean: distclean removebackup
568         -rm -f include/config.h.in
569         -rm -f include/version.h
570         -rm -f configure
571         -rm -f $(MANPAGES)
572 __EOD__
573
574         return $output;
575 }
576
577 sub _prepare_make_target($)
578 {
579         my $ctx = shift;
580         my $tmpdepend;
581         my $output;
582
583         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
584
585         return << "__EOD__";
586 $ctx->{TARGET}: basics $tmpdepend
587
588 __EOD__
589 }
590
591 sub _prepare_target_settings($)
592 {
593         my $CTX = shift;
594         my $output = "";
595
596         foreach my $key (values %$CTX) {
597                 if (defined($key->{OBJ_LIST})) {
598                         $output .= _prepare_obj_list($key->{TYPE}, $key);
599                 }
600
601                 if (defined($key->{OBJ_LIST})) {
602                         $output .= _prepare_cflags($key->{TYPE}, $key);
603                 }
604         }
605
606         return $output;
607 }
608
609 sub _prepare_install_rules($)
610 {
611         my $CTX = shift;
612         my $output = "";
613
614         $output .= << '__EOD__';
615
616 showlayout: 
617         @echo "Samba will be installed into:"
618         @echo "  basedir: $(BASEDIR)"
619         @echo "  bindir:  $(BINDIR)"
620         @echo "  sbindir: $(SBINDIR)"
621         @echo "  libdir:  $(LIBDIR)"
622         @echo "  vardir:  $(VARDIR)"
623         @echo "  privatedir:  $(PRIVATEDIR)"
624         @echo "  piddir:   $(PIDDIR)"
625         @echo "  lockdir:  $(LOCKDIR)"
626         @echo "  swatdir:  $(SWATDIR)"
627         @echo "  mandir:   $(MANDIR)"
628
629 showflags:
630         @echo "Samba will be compiled with flags:"
631         @echo "  CFLAGS = $(CFLAGS)"
632         @echo "  LD_FLAGS = $(LD_FLAGS)"
633         @echo "  STLD_FLAGS = $(STLD_FLAGS)"
634         @echo "  SHLD_FLAGS = $(SHLD_FLAGS)"
635
636 SBIN_PROGS = bin/smbd
637
638 BIN_PROGS = bin/smbclient \
639                 bin/net \
640                 bin/nmblookup \
641                 bin/smbscript \
642                 bin/ntlm_auth
643
644 TORTURE_PROGS = bin/smbtorture \
645                 bin/gentest \
646                 bin/locktest \
647                 bin/masktest \
648                 bin/ndrdump
649
650 LDB_PROGS =     bin/ldbadd \
651                 bin/ldbdel \
652                 bin/ldbmodify \
653                 bin/ldbedit \
654                 bin/ldbsearch
655
656 REG_PROGS =     bin/regpatch \
657                 bin/regshell \
658                 bin/regtree \
659                 bin/regdiff
660
661 GTK_PROGS = bin/gregedit \
662                 bin/gwsam \
663                 bin/gepdump
664
665 install: showlayout installbin installtorture installldb installreg installdat installswat installmisc installgtk
666
667 # DESTDIR is used here to prevent packagers wasting their time
668 # duplicating the Makefile. Remove it and you will have the privilege
669 # of package each samba release for multiple versions of multiple
670 # distributions and operating systems, or at least supplying patches
671 # to all the packaging files required for this, prior to committing
672 # the removal of DESTDIR. Do not remove it even though you think it
673 # is not used.
674
675 installdirs:
676         @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(PIDDIR) $(DESTDIR)$(LOCKDIR) $(DESTDIR)$(PRIVATEDIR)/tls
677
678 installbin: all installdirs
679         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS)
680         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS)
681
682 installtorture: all installdirs
683         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(TORTURE_PROGS)
684
685 installldb: all installdirs
686         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(LDB_PROGS)
687
688 installreg: all installdirs
689         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(REG_PROGS)
690
691 installgtk: all installdirs
692         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(GTK_PROGS)
693
694 installdat: installdirs
695         @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
696
697 installswat: installdirs
698         @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) $(DESTDIR)$(LIBDIR)
699
700 installmisc: installdirs
701         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(BINDIR)
702
703 installman: installdirs
704         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
705
706 uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg uninstallgtk
707
708 uninstallbin:
709         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
710
711 uninstalltorture:
712         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(TORTURE_PROGS)
713
714 uninstallldb:
715         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(LDB_PROGS)
716
717 uninstallreg:
718         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(REG_PROGS)
719
720 uninstallgtk:
721         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(GTK_PROGS)
722
723 uninstallman:
724         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
725
726 # Swig extensions
727
728 swig: scripting/swig/_tdb.so scripting/swig/_dcerpc.so
729
730 scripting/swig/tdb_wrap.c: scripting/swig/tdb.i
731         swig -python scripting/swig/tdb.i
732
733 scripting/swig/_tdb.so: scripting/swig/tdb_wrap.o $(LIBRARY_swig_tdb_DEPEND_LIST)
734         $(SHLD) $(SHLD_FLAGS) -o scripting/swig/_tdb.so scripting/swig/tdb_wrap.o \
735                 $(LIBRARY_swig_tdb_SHARED_LINK_LIST) $(LIBRARY_swig_tdb_SHARED_LINK_FLAGS)
736
737 SWIG_INCLUDES = librpc/gen_ndr/samr.i librpc/gen_ndr/lsa.i librpc/gen_ndr/spoolss.i
738
739 scripting/swig/dcerpc_wrap.c: scripting/swig/dcerpc.i scripting/swig/samba.i scripting/swig/status_codes.i $(SWIG_INCLUDES)
740         swig -python scripting/swig/dcerpc.i
741
742 scripting/swig/_dcerpc.so: scripting/swig/dcerpc_wrap.o $(LIBRARY_swig_dcerpc_DEPEND_LIST)
743         $(SHLD) $(SHLD_FLAGS) -o scripting/swig/_dcerpc.so scripting/swig/dcerpc_wrap.o $(LIBRARY_swig_dcerpc_SHARED_LINK_LIST) $(LIBRARY_swig_dcerpc_SHARED_LINK_FLAGS)
744
745 swig_clean:
746         -rm -f scripting/swig/_tdb.so scripting/swig/tdb.pyc \
747                 scripting/swig/tdb.py scripting/swig/tdb_wrap.c \
748                 scripting/swig/tdb_wrap.o
749
750 everything: all
751
752 etags:
753         etags `find $(srcdir) -name "*.[ch]"`
754
755 ctags:
756         ctags `find $(srcdir) -name "*.[ch]"`
757
758 __EOD__
759
760         return $output;
761 }
762
763 sub _prepare_rule_lists($)
764 {
765         my $depend = shift;
766         my $output = "";
767
768         foreach my $key (values %{$depend}) {
769                 next unless defined $key->{OUTPUT_TYPE};
770
771                 ($output .= _prepare_objlist_rule($key)) if $key->{OUTPUT_TYPE} eq "OBJLIST";
772                 ($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
773                 ($output .= _prepare_shared_library_rule($key)) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
774                 ($output .= _prepare_binary_rule($key)) if $key->{OUTPUT_TYPE} eq "BINARY";
775                 ($output .= _prepare_custom_rule($key) ) if $key->{TYPE} eq "TARGET";
776         }
777
778         my $idl_ctx;
779         $output .= _prepare_IDL($idl_ctx);
780         $output .= _prepare_proto_rules();
781         $output .= _prepare_install_rules($depend);
782
783         return $output;
784 }
785
786 ###########################################################
787 # This function prepares the output for Makefile
788 #
789 # $output = _prepare_makefile_in($OUTPUT)
790 #
791 # $OUTPUT -     the global OUTPUT context
792 #
793 # $output -             the resulting output buffer
794 sub _prepare_makefile_in($)
795 {
796         my ($CTX) = @_;
797         my $output;
798
799         $output  = "########################################\n";
800         $output .= "# Autogenerated by config.smb_build.pl #\n";
801         $output .= "########################################\n";
802         $output .= "\n";
803
804         my $cmd_ctx;
805         $output .= _prepare_command_interpreters($cmd_ctx);
806
807         my $path_ctx;
808         $output .= _prepare_path_vars($path_ctx);
809
810         my $compiler_ctx;
811         $output .= _prepare_compiler_linker($compiler_ctx);
812
813         my $rules_ctx;
814         $output .= _prepare_default_rule($rules_ctx);
815
816         my $suffix_ctx;
817         $output .= _prepare_SUFFIXES($suffix_ctx);
818
819         $output .= _prepare_dummy_MAKEDIR();
820         $output .= _prepare_std_CC_rule("c","o",'@PICFLAG@',"Compiling","Rule for std objectfiles");
821         $output .= _prepare_std_CC_rule("h","h.gch",'@PICFLAG@',"Precompiling","Rule for precompiled headerfiles");
822
823         $output .= _prepare_man_rule("1");
824         $output .= _prepare_man_rule("3");
825         $output .= _prepare_man_rule("5");
826         $output .= _prepare_man_rule("7");
827         $output .= _prepare_manpages($CTX);
828         $output .= _prepare_target_settings($CTX);
829         $output .= _prepare_rule_lists($CTX);
830
831         my @all = ();
832         
833         foreach my $part (values %{$CTX}) {
834                 push (@all, $part->{TARGET}) if defined ($part->{OUTPUT_TYPE}) and $part->{OUTPUT_TYPE} eq "BINARY";    
835         }
836         
837         $output .= _prepare_make_target({ TARGET => "all", DEPEND_LIST => \@all });
838
839         return $output;
840 }
841
842 ###########################################################
843 # This function creates Makefile.in from the OUTPUT 
844 # context
845 #
846 # create_makefile_in($OUTPUT)
847 #
848 # $OUTPUT       -       the global OUTPUT context
849 #
850 # $output -             the resulting output buffer
851 sub create_makefile_in($$)
852 {
853         my ($CTX, $file) = @_;
854
855         open(MAKEFILE_IN,">$file") || die ("Can't open $file\n");
856         print MAKEFILE_IN _prepare_makefile_in($CTX);
857         close(MAKEFILE_IN);
858
859         print "config.smb_build.pl: creating $file\n";
860         return; 
861 }
862
863 1;