r8576: install scripts from scripting/bin/
[bbaumbach/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@/prefix-test all SOCKET_WRAPPER
152
153 test-noswrap: all
154         ./script/tests/selftest.sh @selftest_prefix@/prefix-test all
155
156 quicktest: all
157         ./script/tests/selftest.sh @selftest_prefix@/prefix-test 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@/prefix-test 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 $i;
256         my $output = "";
257
258         foreach my $str (@{$array}) {
259                 if (!defined($str)) {
260                         next;
261                 }
262
263                 $output .= " \\\n\t\t";
264                 $output .= $str;
265         }
266
267         return $output;
268 }
269
270 sub array2oneline($)
271 {
272         my $array = shift;
273         my $i;
274         my $output = "";
275
276         foreach my $str (@{$array}) {
277                 if (!defined($str)) {
278                         next;
279                 }
280
281                 $output .= $str;
282                 $output .= " ";
283         }
284
285         return $output;
286 }
287
288 ###########################################################
289 # This function creates a object file list
290 #
291 # $output = _prepare_var_obj_list($var, $var_ctx)
292 #
293 # $var_ctx -            the subsystem context
294 #
295 # $var_ctx->{NAME}      -       the <var> name
296 # $var_ctx->{OBJ_LIST}  -       the list of objectfiles which sould be linked to this <var>
297 #
298 # $output -             the resulting output buffer
299 sub _prepare_obj_list($$)
300 {
301         my $var = shift;
302         my $ctx = shift;
303
304         my $tmplist = array2oneperline($ctx->{OBJ_LIST});
305
306         return << "__EOD__";
307 # $var $ctx->{NAME} OBJ LIST
308 $var\_$ctx->{NAME}_OBJS =$tmplist
309
310 __EOD__
311 }
312
313 sub _prepare_cflags($$)
314 {
315         my $var = shift;
316         my $ctx = shift;
317
318         my $tmplist = array2oneperline($ctx->{CFLAGS});
319
320         return << "__EOD__";
321 $var\_$ctx->{NAME}_CFLAGS =$tmplist
322
323 __EOD__
324 }
325
326 ###########################################################
327 # This function creates a make rule for linking a library
328 #
329 # $output = _prepare_shared_library_rule($library_ctx)
330 #
331 # $library_ctx -                the library context
332 #
333 # $library_ctx->{NAME} -                the library name
334 #
335 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
336 #
337 # $library_ctx->{LIBRARY_NAME} -        the shared library name
338 # $library_ctx->{LIBRARY_REALNAME} -    the shared library real name
339 # $library_ctx->{LIBRARY_SONAME} - the shared library soname
340 # $library_ctx->{LINK_LIST} -   the list of objectfiles and external libraries
341 #                                       which sould be linked to this shared library
342 # $library_ctx->{LINK_FLAGS} -  linker flags used by this shared library
343 #
344 # $output -             the resulting output buffer
345 sub _prepare_shared_library_rule($)
346 {
347         my $ctx = shift;
348         my $tmpdepend;
349         my $tmpstlink;
350         my $tmpstflag;
351         my $tmpshlink;
352         my $tmpshflag;
353         my $tmprules;
354         my $output;
355
356         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
357
358         $tmpshlink = array2oneperline($ctx->{LINK_LIST});
359         $tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
360
361         $output = << "__EOD__";
362 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
363 #
364 LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink
365 LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag
366 #
367
368 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
369         \@echo Linking \$\@
370         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
371                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\
372                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST)
373
374 __EOD__
375
376         if (defined($ctx->{LIBRARY_SONAME})) {
377             $output .= << "__EOD__";
378 # Symlink $ctx->{LIBRARY_SONAME}
379 bin/$ctx->{LIBRARY_SONAME}: bin/$ctx->{LIBRARY_REALNAME} bin/.dummy
380         \@echo Symlink \$\@
381         \@ln -sf $ctx->{LIBRARY_REALNAME} \$\@
382 # Symlink $ctx->{LIBRARY_NAME}
383 bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy
384         \@echo Symlink \$\@
385         \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
386
387 __EOD__
388         }
389
390 $output .= << "__EOD__";
391 library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}
392
393 __EOD__
394
395         return $output;
396 }
397
398 sub _prepare_objlist_rule($)
399 {
400         my $ctx = shift;
401         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
402         my $output;
403
404         if (! $ctx->{TARGET}) {
405                 return "";
406         }
407
408         $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
409
410         $output .= "$ctx->{TARGET}: ";
411
412         $output .= "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
413         $output .= "\t\@touch $ctx->{TARGET}\n";
414
415         return $output;
416 }
417
418 ###########################################################
419 # This function creates a make rule for linking a library
420 #
421 # $output = _prepare_static_library_rule($library_ctx)
422 #
423 # $library_ctx -                the library context
424 #
425 # $library_ctx->{NAME} -                the library name
426 #
427 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
428 #
429 # $library_ctx->{LIBRARY_NAME} -        the static library name
430 # $library_ctx->{LINK_LIST} -   the list of objectfiles which sould be linked
431 #                                       to this static library
432 # $library_ctx->{LINK_FLAGS} -  linker flags used by this static library
433 #
434 # $output -             the resulting output buffer
435 sub _prepare_static_library_rule($)
436 {
437         my $ctx = shift;
438         my $tmpdepend;
439         my $tmpstlink;
440         my $tmpstflag;
441         my $tmpshlink;
442         my $tmpshflag;
443         my $tmprules;
444         my $output;
445
446         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
447
448         $tmpstlink = array2oneperline($ctx->{LINK_LIST});
449         $tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
450
451         $output = << "__EOD__";
452 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
453 #
454 LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink
455 #
456 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
457         \@echo Linking \$@
458         \@\$(STLD) \$(STLD_FLAGS) \$@ \\
459                 \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST)
460
461 library_$ctx->{NAME}: basics $ctx->{TARGET}
462
463 __EOD__
464
465         return $output;
466 }
467
468 ###########################################################
469 # This function creates a make rule for linking a binary
470 #
471 # $output = _prepare_binary_rule($binary_ctx)
472 #
473 # $binary_ctx -         the binary context
474 #
475 # $binary_ctx->{NAME} -         the binary name
476 # $binary_ctx->{BINARY} -       the binary binary name
477 #
478 # $binary_ctx->{DEPEND_LIST} -  the list of rules on which this binary depends
479 # $binary_ctx->{LINK_LIST} -    the list of objectfiles and external libraries
480 #                               which sould be linked to this binary
481 # $binary_ctx->{LINK_FLAGS} -   linker flags used by this binary
482 #
483 # $output -             the resulting output buffer
484 sub _prepare_binary_rule($)
485 {
486         my $ctx = shift;
487         my $tmpdepend;
488         my $tmplink;
489         my $tmpflag;
490         my $output;
491
492         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
493         $tmplink = array2oneperline($ctx->{LINK_LIST});
494         $tmpflag = array2oneperline($ctx->{LINK_FLAGS});
495
496         $output = << "__EOD__";
497 #
498 BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
499 BINARY_$ctx->{NAME}_LINK_LIST =$tmplink
500 BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag
501 #
502 bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) \$(BINARY_$ctx->{NAME}_OBJS)
503         \@echo Linking \$\@
504         \@\$(LD) \$(LD_FLAGS) -o \$\@ \\
505                 \$\(BINARY_$ctx->{NAME}_LINK_FLAGS) \\
506                 \$\(BINARY_$ctx->{NAME}_LINK_LIST) \\
507                 \$\(BINARY_$ctx->{NAME}_LINK_FLAGS)
508 binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY}
509
510 __EOD__
511
512         return $output;
513 }
514
515 sub _prepare_custom_rule($)
516 {
517         my $ctx = shift;
518         return "
519 $ctx->{NAME}: bin/.TARGET_$ctx->{NAME}
520
521 bin/.TARGET_$ctx->{NAME}:
522         $ctx->{CMD}
523         touch bin/.TARGET_$ctx->{NAME}
524 ";
525 }
526
527 sub _prepare_proto_rules()
528 {
529         my $output = "";
530
531         $output .= << '__EOD__';
532 # Making this target will just make sure that the prototype files
533 # exist, not necessarily that they are up to date.  Since they're
534 # removed by 'make clean' this will always be run when you do anything
535 # afterwards.
536 proto_exists: include/proto.h
537
538 delheaders: pch_clean
539         -rm -f $(builddir)/include/proto.h
540
541 include/proto.h:
542         @cd $(srcdir) && $(SHELL) script/mkproto.sh "$(PERL)" \
543           -h _PROTO_H_ $(builddir)/include/proto.h \
544           $(PROTO_PROTO_OBJS)
545
546 # 'make headers' or 'make proto' calls a subshell because we need to
547 # make sure these commands are executed in sequence even for a
548 # parallel make.
549 headers: delheaders proto_exists
550
551 proto: idl headers
552
553 proto_test:
554         @[ -f $(builddir)/include/proto.h ] || $(MAKE) proto
555
556 clean: delheaders
557         @echo Removing objects
558         @-find . -name '*.o' -exec rm -f '{}' \;
559         @echo Removing binaries
560         @-rm -f bin/*
561         @echo Removing dummy targets
562         @-rm -f bin/.*_*
563         @echo Removing generated files
564         @-rm -rf librpc/gen_*
565         @echo Removing generated ASN1 files
566         @-find heimdal/lib/asn1 -name 'asn1_*.[xc]' -exec rm -f '{}' \;
567         @-find heimdal/lib/gssapi -name 'asn1_*.[xc]' -exec rm -f '{}' \;
568         @-find heimdal/lib/hdb -name 'asn1_*.[xc]' -exec rm -f '{}' \;
569
570 distclean: clean
571         -rm -f bin/.dummy
572         -rm -f include/config.h include/smb_build.h
573         -rm -f Makefile*
574         -rm -f config.status
575         -rm -f config.log config.cache
576         -rm -f samba4-deps.dot
577         -rm -f lib/registry/winregistry.pc
578
579 removebackup:
580         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
581
582 realdistclean: distclean removebackup
583         -rm -f include/config.h.in
584         -rm -f include/version.h
585         -rm -f configure
586         -rm -f $(MANPAGES)
587 __EOD__
588
589         return $output;
590 }
591
592 sub _prepare_make_target($)
593 {
594         my $ctx = shift;
595         my $tmpdepend;
596         my $output;
597
598         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
599
600         return << "__EOD__";
601 $ctx->{TARGET}: basics $tmpdepend
602
603 __EOD__
604 }
605
606 sub _prepare_target_settings($)
607 {
608         my $CTX = shift;
609         my $output = "";
610
611         foreach my $key (values %$CTX) {
612                 if (defined($key->{OBJ_LIST})) {
613                         $output .= _prepare_obj_list($key->{TYPE}, $key);
614                 }
615
616                 if (defined($key->{OBJ_LIST})) {
617                         $output .= _prepare_cflags($key->{TYPE}, $key);
618                 }
619         }
620
621         return $output;
622 }
623
624 sub _prepare_install_rules($)
625 {
626         my $CTX = shift;
627         my $output = "";
628
629         $output .= << '__EOD__';
630
631 showlayout: 
632         @echo "Samba will be installed into:"
633         @echo "  basedir: $(BASEDIR)"
634         @echo "  bindir:  $(BINDIR)"
635         @echo "  sbindir: $(SBINDIR)"
636         @echo "  libdir:  $(LIBDIR)"
637         @echo "  vardir:  $(VARDIR)"
638         @echo "  privatedir:  $(PRIVATEDIR)"
639         @echo "  piddir:   $(PIDDIR)"
640         @echo "  lockdir:  $(LOCKDIR)"
641         @echo "  swatdir:  $(SWATDIR)"
642         @echo "  mandir:   $(MANDIR)"
643
644 showflags:
645         @echo "Samba will be compiled with flags:"
646         @echo "  CFLAGS = $(CFLAGS)"
647         @echo "  LD_FLAGS = $(LD_FLAGS)"
648         @echo "  STLD_FLAGS = $(STLD_FLAGS)"
649         @echo "  SHLD_FLAGS = $(SHLD_FLAGS)"
650
651 SBIN_PROGS = bin/smbd
652
653 BIN_PROGS = bin/smbclient \
654                 bin/net \
655                 bin/nmblookup \
656                 bin/ntlm_auth
657
658 TORTURE_PROGS = bin/smbtorture \
659                 bin/gentest \
660                 bin/locktest \
661                 bin/masktest \
662                 bin/ndrdump
663
664 LDB_PROGS =     bin/ldbadd \
665                 bin/ldbdel \
666                 bin/ldbmodify \
667                 bin/ldbedit \
668                 bin/ldbsearch
669
670 REG_PROGS =     bin/regpatch \
671                 bin/regshell \
672                 bin/regtree \
673                 bin/regdiff
674
675 GTK_PROGS = bin/gregedit \
676                 bin/gwsam \
677                 bin/gepdump
678
679 install: showlayout installbin installtorture installldb installreg installdat installswat installmisc installgtk
680
681 # DESTDIR is used here to prevent packagers wasting their time
682 # duplicating the Makefile. Remove it and you will have the privilege
683 # of package each samba release for multiple versions of multiple
684 # distributions and operating systems, or at least supplying patches
685 # to all the packaging files required for this, prior to committing
686 # the removal of DESTDIR. Do not remove it even though you think it
687 # is not used.
688
689 installdirs:
690         @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(PIDDIR) $(DESTDIR)$(LOCKDIR) $(DESTDIR)$(PRIVATEDIR)/tls
691
692 installbin: all installdirs
693         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS)
694         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS)
695
696 installtorture: all installdirs
697         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(TORTURE_PROGS)
698
699 installldb: all installdirs
700         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(LDB_PROGS)
701
702 installreg: all installdirs
703         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(REG_PROGS)
704
705 installgtk: all installdirs
706         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(GTK_PROGS)
707
708 installdat: installdirs
709         @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
710
711 installswat: installdirs
712         @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) $(DESTDIR)$(LIBDIR)
713
714 installmisc: installdirs
715         @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(BINDIR)
716
717 installman: installdirs
718         @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
719
720 uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg uninstallgtk
721
722 uninstallbin:
723         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
724
725 uninstalltorture:
726         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(TORTURE_PROGS)
727
728 uninstallldb:
729         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(LDB_PROGS)
730
731 uninstallreg:
732         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(REG_PROGS)
733
734 uninstallgtk:
735         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(GTK_PROGS)
736
737 uninstallman:
738         @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
739
740 # Swig extensions
741
742 swig: scripting/swig/_tdb.so scripting/swig/_dcerpc.so
743
744 scripting/swig/tdb_wrap.c: scripting/swig/tdb.i
745         swig -python scripting/swig/tdb.i
746
747 scripting/swig/_tdb.so: scripting/swig/tdb_wrap.o $(LIBRARY_swig_tdb_DEPEND_LIST)
748         $(SHLD) $(SHLD_FLAGS) -o scripting/swig/_tdb.so scripting/swig/tdb_wrap.o \
749                 $(LIBRARY_swig_tdb_SHARED_LINK_LIST) $(LIBRARY_swig_tdb_SHARED_LINK_FLAGS)
750
751 SWIG_INCLUDES = librpc/gen_ndr/samr.i librpc/gen_ndr/lsa.i librpc/gen_ndr/spoolss.i
752
753 scripting/swig/dcerpc_wrap.c: scripting/swig/dcerpc.i scripting/swig/samba.i scripting/swig/status_codes.i $(SWIG_INCLUDES)
754         swig -python scripting/swig/dcerpc.i
755
756 scripting/swig/_dcerpc.so: scripting/swig/dcerpc_wrap.o $(LIBRARY_swig_dcerpc_DEPEND_LIST)
757         $(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)
758
759 swig_clean:
760         -rm -f scripting/swig/_tdb.so scripting/swig/tdb.pyc \
761                 scripting/swig/tdb.py scripting/swig/tdb_wrap.c \
762                 scripting/swig/tdb_wrap.o
763
764 everything: all
765
766 etags:
767         etags `find $(srcdir) -name "*.[ch]"`
768
769 ctags:
770         ctags `find $(srcdir) -name "*.[ch]"`
771
772 __EOD__
773
774         return $output;
775 }
776
777 sub _prepare_rule_lists($)
778 {
779         my $depend = shift;
780         my $output = "";
781
782         foreach my $key (values %{$depend}) {
783                 next if not defined $key->{OUTPUT_TYPE};
784
785                 ($output .= _prepare_objlist_rule($key)) if $key->{OUTPUT_TYPE} eq "OBJLIST";
786                 ($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
787                 ($output .= _prepare_shared_library_rule($key)) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
788                 ($output .= _prepare_binary_rule($key)) if $key->{OUTPUT_TYPE} eq "BINARY";
789                 ($output .= _prepare_custom_rule($key) ) if $key->{TYPE} eq "TARGET";
790         }
791
792         my $idl_ctx;
793         $output .= _prepare_IDL($idl_ctx);
794
795         $output .= _prepare_proto_rules();
796
797         $output .= _prepare_install_rules($depend);
798
799         return $output;
800 }
801
802 ###########################################################
803 # This function prepares the output for Makefile
804 #
805 # $output = _prepare_makefile_in($OUTPUT)
806 #
807 # $OUTPUT -     the global OUTPUT context
808 #
809 # $output -             the resulting output buffer
810 sub _prepare_makefile_in($$)
811 {
812         my $CTX = shift;
813         my $settings = shift;
814         my $output;
815
816         $output  = "########################################\n";
817         $output .= "# Autogenerated by config.smb_build.pl #\n";
818         $output .= "########################################\n";
819         $output .= "\n";
820
821         my $cmd_ctx;
822         $output .= _prepare_command_interpreters($cmd_ctx);
823
824         my $path_ctx;
825         $output .= _prepare_path_vars($path_ctx);
826
827         my $compiler_ctx;
828         $output .= _prepare_compiler_linker($compiler_ctx);
829
830         my $rules_ctx;
831         $output .= _prepare_default_rule($rules_ctx);
832
833         my $suffix_ctx;
834         $output .= _prepare_SUFFIXES($suffix_ctx);
835
836         $output .= _prepare_dummy_MAKEDIR();
837
838         $output .= _prepare_std_CC_rule("c","o",'@PICFLAG@',"Compiling","Rule for std objectfiles");
839         $output .= _prepare_std_CC_rule("h","h.gch",'@PICFLAG@',"Precompiling","Rule for precompiled headerfiles");
840
841         $output .= _prepare_man_rule("1");
842         $output .= _prepare_man_rule("3");
843         $output .= _prepare_man_rule("5");
844         $output .= _prepare_man_rule("7");
845
846         $output .= _prepare_manpages($CTX);
847
848         $output .= _prepare_target_settings($CTX);
849
850         $output .= _prepare_rule_lists($CTX);
851
852         my @all = ();
853         
854         foreach my $part (values %{$CTX}) {
855                 push (@all, $part->{TARGET}) if defined ($part->{OUTPUT_TYPE}) and $part->{OUTPUT_TYPE} eq "BINARY";    
856         }
857         
858         $output .= _prepare_make_target({ TARGET => "all", DEPEND_LIST => \@all });
859
860         return $output;
861 }
862
863 ###########################################################
864 # This function creates Makefile.in from the OUTPUT 
865 # context
866 #
867 # create_makefile_in($OUTPUT)
868 #
869 # $OUTPUT       -       the global OUTPUT context
870 #
871 # $output -             the resulting output buffer
872 sub create_makefile_in($$$)
873 {
874         my $CTX = shift;
875         my $settings = shift;
876         my $file = shift;
877
878         open(MAKEFILE_IN,">$file") || die ("Can't open $file\n");
879         print MAKEFILE_IN _prepare_makefile_in($CTX, $settings);
880         close(MAKEFILE_IN);
881
882         print "config.smb_build.pl: creating $file\n";
883         return; 
884 }
885
886 1;