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