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