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