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