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