r6853: again fixed SOCKET_WRAPPER_DIR in 'make test'
[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 = << '__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_ -DHAVE_CONFIG_H -Ilib @CFLAGS@ @CPPFLAGS@
89
90 LD=@CC@
91 LD_FLAGS=@LDFLAGS@ @CFLAGS@ -Lbin
92
93 STLD=ar
94 STLD_FLAGS=-rc
95
96 SHLD=@CC@
97 SHLD_FLAGS=@LDSHFLAGS@ @LDFLAGS@ -Lbin
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         SOCKET_WRAPPER_DIR=. ./script/tests/selftest.sh `pwd`/prefix-test
157
158 test-noswrap: all
159         ./script/tests/selftest.sh `pwd`/prefix-test
160
161 __EOD__
162
163         return $output;
164 }
165
166 sub _prepare_dummy_MAKEDIR()
167 {
168         my $ctx = shift;
169         my $output;
170
171         $output =  << '__EOD__';
172 bin/.dummy:
173         @: >> $@ || : > $@
174
175 dynconfig.o: dynconfig.c Makefile
176         @echo Compiling $*.c
177         @$(CC) $(CC_FLAGS) @PICFLAG@ $(PATH_FLAGS) -c $< -o $@
178 @BROKEN_CC@     -mv `echo $@ | sed 's%^.*/%%g'` $@
179
180 __EOD__
181
182         return $output;
183 }
184
185 ###########################################################
186 # This function creates a standard make rule which is using $(CC)
187 #
188 # $output = _prepare_std_CC_rule($srcext,$destext,$flags,$message,$comment)
189 #
190 # $srcext -     sourcefile extension
191 #
192 # $destext -    destinationfile extension
193 #
194 # $flags -      additional compiler flags
195 #
196 # $message -    logmessage which is echoed while running this rule
197 #
198 # $comment -    just a comment what this rule should do
199 #
200 # $output -             the resulting output buffer
201 sub _prepare_std_CC_rule($$$$$)
202 {
203         my $src = shift;
204         my $dst = shift;
205         my $flags = shift;
206         my $message = shift;
207         my $comment = shift;
208         my $flagsstr = "";
209         my $output;
210
211         $output = << "__EOD__";
212 ###################################
213 # Start $comment
214 .$src.$dst:
215         \@echo $message \$\*.$src
216         \@\$(CC) \$(CC_FLAGS) $flags -c \$< -o \$\@
217 \@BROKEN_CC\@   -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@
218 #End $comment
219 ###################################
220
221 __EOD__
222
223         return $output;
224 }
225
226 sub array2oneperline($)
227 {
228         my $array = shift;
229         my $i;
230         my $output = "";
231
232         foreach my $str (@{$array}) {
233                 if (!defined($str)) {
234                         next;
235                 }
236
237                 $output .= " \\\n\t\t";
238                 $output .= $str;
239         }
240
241         return $output;
242 }
243
244 sub array2oneline($)
245 {
246         my $array = shift;
247         my $i;
248         my $output = "";
249
250         foreach my $str (@{$array}) {
251                 if (!defined($str)) {
252                         next;
253                 }
254
255                 $output .= $str;
256                 $output .= " ";
257         }
258
259         return $output;
260 }
261
262 ###########################################################
263 # This function creates a object file list
264 #
265 # $output = _prepare_var_obj_list($var, $var_ctx)
266 #
267 # $var_ctx -            the subsystem context
268 #
269 # $var_ctx->{NAME}      -       the <var> name
270 # $var_ctx->{OBJ_LIST}  -       the list of objectfiles which sould be linked to this <var>
271 #
272 # $output -             the resulting output buffer
273 sub _prepare_obj_list($$)
274 {
275         my $var = shift;
276         my $ctx = shift;
277         my $tmpobjlist;
278         my $output;
279
280         $tmpobjlist = array2oneperline($ctx->{OBJ_LIST});
281
282         $output = << "__EOD__";
283 ###################################
284 # Start $var $ctx->{NAME} OBJ LIST
285 $var\_$ctx->{NAME}_OBJS =$tmpobjlist
286 # End $var $ctx->{NAME} OBJ LIST
287 ###################################
288
289 __EOD__
290
291         return $output;
292 }
293
294 ###########################################################
295 # This function creates a object file list for a subsystem
296 #
297 # $output = _prepare_subsystem_obj_list($subsystem_ctx)
298 #
299 # $subsystem_ctx -              the subsystem context
300 #
301 # $subsystem_ctx->{NAME} -      the subsystem name
302 # $subsystem_ctx->{OBJ_LIST} -  the list of objectfiles which sould be linked to this subsystem
303 #
304 # $output -             the resulting output buffer
305 sub _prepare_subsystem_obj_list($)
306 {
307         my $ctx = shift;
308
309         return _prepare_var_obj_list("SUBSYSTEM",$ctx);
310 }
311
312 ###########################################################
313 # This function creates a object file list for a module
314 #
315 # $output = _prepare_module_obj_and_lib_list($module_ctx)
316 #
317 # $module_ctx -         the module context
318 #
319 # $module_ctx->{NAME} -         the module binary name
320 # $module_ctx->{OBJ_LIST} -     the list of objectfiles which sould be linked to this module
321 #
322 # $output -             the resulting output buffer
323 sub _prepare_module_obj_list($)
324 {
325         my $ctx = shift;
326
327         return _prepare_var_obj_list("MODULE",$ctx);
328
329 }
330
331 ###########################################################
332 # This function creates a make rule for linking a library
333 #
334 # $output = _prepare_shared_library_rule($library_ctx)
335 #
336 # $library_ctx -                the library context
337 #
338 # $library_ctx->{NAME} -                the library name
339 #
340 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
341 #
342 # $library_ctx->{LIBRARY_NAME} -        the shared library name
343 # $library_ctx->{LIBRARY_REALNAME} -    the shared library real name
344 # $library_ctx->{LIBRARY_SONAME} - the shared library soname
345 # $library_ctx->{LINK_LIST} -   the list of objectfiles and external libraries
346 #                                       which sould be linked to this shared library
347 # $library_ctx->{LINK_FLAGS} -  linker flags used by this shared library
348 #
349 # $output -             the resulting output buffer
350 sub _prepare_shared_library_rule($)
351 {
352         my $ctx = shift;
353         my $tmpdepend;
354         my $tmpstlink;
355         my $tmpstflag;
356         my $tmpshlink;
357         my $tmpshflag;
358         my $tmprules;
359         my $output;
360
361         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
362
363         $tmpshlink = array2oneperline($ctx->{LINK_LIST});
364         $tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
365
366         $output = << "__EOD__";
367 ###################################
368 # Start Library $ctx->{NAME}
369 #
370 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
371 #
372 LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink
373 LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag
374 #
375
376 # Shared $ctx->{LIBRARY_NAME}
377 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy
378         \@echo Linking \$\@
379         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
380                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\
381                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST)
382
383 __EOD__
384
385         if (defined($ctx->{LIBRARY_SONAME})) {
386             $output .= << "__EOD__";
387 # Symlink $ctx->{LIBRARY_SONAME}
388 bin/$ctx->{LIBRARY_SONAME}: bin/$ctx->{LIBRARY_REALNAME} bin/.dummy
389         \@echo Symlink \$\@
390         \@ln -sf $ctx->{LIBRARY_REALNAME} \$\@
391 # Symlink $ctx->{LIBRARY_NAME}
392 bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy
393         \@echo Symlink \$\@
394         \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
395
396 __EOD__
397         }
398
399 $output .= << "__EOD__";
400 library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}
401 # End Library $ctx->{NAME}
402 ###################################
403
404 __EOD__
405
406         return $output;
407 }
408
409 ###########################################################
410 # This function creates a make rule for linking a library
411 #
412 # $output = _prepare_static_library_rule($library_ctx)
413 #
414 # $library_ctx -                the library context
415 #
416 # $library_ctx->{NAME} -                the library name
417 #
418 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
419 #
420 # $library_ctx->{LIBRARY_NAME} -        the static library name
421 # $library_ctx->{LINK_LIST} -   the list of objectfiles which sould be linked
422 #                                       to this static library
423 # $library_ctx->{LINK_FLAGS} -  linker flags used by this static library
424 #
425 # $output -             the resulting output buffer
426 sub _prepare_static_library_rule($)
427 {
428         my $ctx = shift;
429         my $tmpdepend;
430         my $tmpstlink;
431         my $tmpstflag;
432         my $tmpshlink;
433         my $tmpshflag;
434         my $tmprules;
435         my $output;
436
437         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
438
439         $tmpstlink = array2oneperline($ctx->{LINK_LIST});
440         $tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
441
442         $tmprules = "bin/$ctx->{LIBRARY_NAME}";
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 $tmprules
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
628 showflags:
629         @echo "Samba will be compiled with flags:"
630         @echo "  CC_FLAGS = $(CC_FLAGS)"
631         @echo "  LD_FLAGS = $(LD_FLAGS)"
632         @echo "  STLD_FLAGS = $(STLD_FLAGS)"
633         @echo "  SHLD_FLAGS = $(SHLD_FLAGS)"
634
635 SBIN_PROGS = bin/smbd
636
637 BIN_PROGS = bin/smbclient \
638                 bin/net \
639                 bin/nmblookup \
640                 bin/ntlm_auth
641
642 TORTURE_PROGS = bin/smbtorture \
643                 bin/gentest \
644                 bin/locktest \
645                 bin/masktest \
646                 bin/ndrdump
647
648 LDB_PROGS =     bin/ldbadd \
649                 bin/ldbdel \
650                 bin/ldbmodify \
651                 bin/ldbedit \
652                 bin/ldbsearch
653
654 REG_PROGS =     bin/regpatch \
655                 bin/regshell \
656                 bin/regtree \
657                 bin/regpatch \
658                 bin/regdiff
659
660 install: showlayout installbin installtorture installldb installreg installdat 
661
662 # DESTDIR is used here to prevent packagers wasting their time
663 # duplicating the Makefile. Remove it and you will have the privelege
664 # of package each samba release for muliple versions of multiple
665 # distributions and operating systems, or at least supplying patches
666 # to all the packaging files required for this, prior to committing
667 # the removal of DESTDIR. Do not remove it even though you think it
668 # is not used
669
670 installdirs:
671         @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(PIDDIR) $(DESTDIR)$(LOCKDIR)
672
673 installbin: all installdirs
674         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS)
675         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS)
676
677 installtorture: all installdirs
678         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(TORTURE_PROGS)
679
680 installldb: all installdirs
681         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(LDB_PROGS)
682
683 installreg: all installdirs
684         @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(REG_PROGS)
685
686 installdat: installdirs
687         @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
688
689 uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg
690
691 uninstallbin:
692         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
693
694 uninstalltorture:
695         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(TORTURE_PROGS)
696
697 uninstallldb:
698         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(LDB_PROGS)
699
700 uninstallreg:
701         @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(REG_PROGS)
702
703 # Swig extensions
704
705 swig: scripting/swig/_tdb.so scripting/swig/_dcerpc.so
706
707 scripting/swig/tdb_wrap.c: scripting/swig/tdb.i
708         swig -python scripting/swig/tdb.i
709
710 scripting/swig/_tdb.so: scripting/swig/tdb_wrap.o $(LIBRARY_swig_tdb_DEPEND_LIST)
711         $(SHLD) $(SHLD_FLAGS) -o scripting/swig/_tdb.so scripting/swig/tdb_wrap.o \
712                 $(LIBRARY_swig_tdb_SHARED_LINK_LIST) $(LIBRARY_swig_tdb_SHARED_LINK_FLAGS)
713
714 SWIG_INCLUDES = librpc/gen_ndr/samr.i librpc/gen_ndr/lsa.i librpc/gen_ndr/spoolss.i
715
716 scripting/swig/dcerpc_wrap.c: scripting/swig/dcerpc.i scripting/swig/samba.i scripting/swig/status_codes.i $(SWIG_INCLUDES)
717         swig -python scripting/swig/dcerpc.i
718
719 scripting/swig/_dcerpc.so: scripting/swig/dcerpc_wrap.o $(LIBRARY_swig_dcerpc_DEPEND_LIST)
720         $(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)
721
722 swig_clean:
723         -rm -f scripting/swig/_tdb.so scripting/swig/tdb.pyc \
724                 scripting/swig/tdb.py scripting/swig/tdb_wrap.c \
725                 scripting/swig/tdb_wrap.o
726
727 everything: all
728
729 etags:
730         etags `find $(srcdir) -name "*.[ch]"`
731
732 ctags:
733         ctags `find $(srcdir) -name "*.[ch]"`
734
735 __EOD__
736
737         return $output;
738 }
739
740 sub _prepare_rule_lists($)
741 {
742         my $depend = shift;
743         my $output = "";
744
745         foreach my $key (values %{$depend}) {
746                 next if not defined $key->{OUTPUT_TYPE};
747                 ($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
748                 ($output .= _prepare_shared_library_rule($key)) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
749                 ($output .= _prepare_binary_rule($key)) if $key->{OUTPUT_TYPE} eq "BINARY";
750         }
751
752         my $idl_ctx;
753         $output .= _prepare_IDL($idl_ctx);
754
755         $output .= _prepare_proto_rules();
756
757         $output .= _prepare_install_rules($depend);
758
759         return $output;
760 }
761
762 ###########################################################
763 # This function prepares the output for Makefile
764 #
765 # $output = _prepare_makefile_in($SMB_BUILD_CTX)
766 #
767 # $SMB_BUILD_CTX -      the global SMB_BUILD context
768 #
769 # $output -             the resulting output buffer
770 sub _prepare_makefile_in($)
771 {
772         my $CTX = shift;
773         my $output;
774
775         $output  = "########################################\n";
776         $output .= "# Autogenerated by config.smb_build.pl #\n";
777         $output .= "########################################\n";
778         $output .= "\n";
779
780         my $cmd_ctx;
781         $output .= _prepare_command_interpreters($cmd_ctx);
782
783         my $path_ctx;
784         $output .= _prepare_path_vars($path_ctx);
785
786         my $compiler_ctx;
787         $output .= _prepare_compiler_linker($compiler_ctx);
788
789         my $rules_ctx;
790         $output .= _prepare_default_rule($rules_ctx);
791
792         my $suffix_ctx;
793         $output .= _prepare_SUFFIXES($suffix_ctx);
794
795         $output .= _prepare_dummy_MAKEDIR();
796
797         $output .= _prepare_std_CC_rule("c","o",'@PICFLAG@',"Compiling","Rule for std objectfiles");
798         $output .= _prepare_std_CC_rule("h","h.gch",'@PICFLAG@',"Precompiling","Rule for precompiled headerfiles");
799
800         $output .= _prepare_obj_lists($CTX);
801
802         $output .= _prepare_rule_lists($CTX);
803
804         my @all = ();
805         
806         foreach my $part (values %{$CTX}) {
807                 push (@all, $part->{TARGET}) if defined ($part->{OUTPUT_TYPE}) and $part->{OUTPUT_TYPE} eq "BINARY";    
808         }
809         
810         $output .= _prepare_make_target({ TARGET => "all", DEPEND_LIST => \@all });
811
812         return $output;
813 }
814
815 ###########################################################
816 # This function creates Makefile.in from the SMB_BUILD 
817 # context
818 #
819 # create_makefile_in($SMB_BUILD_CTX)
820 #
821 # $SMB_BUILD_CTX -      the global SMB_BUILD context
822 #
823 # $output -             the resulting output buffer
824 sub create_makefile_in($)
825 {
826         my $CTX = shift;
827
828         open(MAKEFILE_IN,"> Makefile.in") || die ("Can't open Makefile.in\n");
829         print MAKEFILE_IN _prepare_makefile_in($CTX);
830         close(MAKEFILE_IN);
831
832         print "config.smb_build.pl: creating Makefile.in\n";
833         return; 
834 }
835
836 1;