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