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