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