r11245: Hopefully fix heimdal build on some hosts
[bbaumbach/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 ###  Copyright (C) Jelmer Vernooij 2005                 ###
7 ###  Released under the GNU GPL                         ###
8 ###########################################################
9
10 package makefile;
11 use config qw(%config);
12 use strict;
13
14 sub _prepare_path_vars()
15 {
16         my $output;
17
18         $config{srcdir} = '.';
19         $config{builddir} = '.';
20
21         if ($config{prefix} eq "NONE") {
22                 $config{prefix} = $config{ac_default_prefix};
23         }
24
25         if ($config{exec_prefix} eq "NONE") {
26                 $config{exec_prefix} = $config{prefix};
27         }
28
29         $output = << "__EOD__";
30 prefix = $config{prefix}
31 exec_prefix = $config{exec_prefix}
32 selftest_prefix = $config{selftest_prefix}
33 VPATH = $config{srcdir}
34 srcdir = $config{srcdir}
35 builddir = $config{builddir}
36
37 BASEDIR = $config{prefix}
38 BINDIR = $config{bindir}
39 SBINDIR = $config{sbindir}
40 datadir = $config{datadir}
41 LIBDIR = $config{libdir}
42 CONFIGDIR = $config{configdir}
43 localstatedir = $config{localstatedir}
44 SWATDIR = $config{swatdir}
45 VARDIR = $config{localstatedir}
46 LOGFILEBASE = $config{logfilebase}
47 NCALRPCDIR = $config{localstatedir}/ncalrpc
48 LOCKDIR = $config{lockdir}
49 PIDDIR = $config{piddir}
50 MANDIR = $config{mandir}
51 PRIVATEDIR = $config{privatedir}
52
53 __EOD__
54         
55         $output.= << '__EOD__';
56
57 # The permissions to give the executables
58 INSTALLPERMS = 0755
59
60 # set these to where to find various files
61 # These can be overridden by command line switches (see smbd(8))
62 # or in smb.conf (see smb.conf(5))
63 CONFIGFILE = $(CONFIGDIR)/smb.conf
64 LMHOSTSFILE = $(CONFIGDIR)/lmhosts
65
66 PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\"  -DSBINDIR=\"$(SBINDIR)\" \
67          -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
68          -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DLIBDIR=\"$(LIBDIR)\" \
69          -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
70          -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
71          -DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\"
72 __EOD__
73
74         return $output;
75 }
76
77 sub _prepare_compiler_linker()
78 {
79         return << "__EOD__";
80 SHELL=$config{SHELL}
81
82 PERL=$config{PERL}
83
84 CC=$config{CC}
85 CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $config{CFLAGS} $config{CPPFLAGS}
86 PICFLAG=$config{PICFLAG}
87 HOSTCC=$config{HOSTCC}
88
89 CPP=$config{CPP}
90 CPPFLAGS=$config{CPPFLAGS}
91
92 LD=$config{LD}
93 LD_FLAGS=$config{LDFLAGS} 
94
95 STLD=$config{AR}
96 STLD_FLAGS=-rc
97
98 SHLD=$config{CC}
99 SHLD_FLAGS=$config{LDSHFLAGS}
100 SONAMEFLAG=$config{SONAMEFLAG}
101 SHLIBEXT=$config{SHLIBEXT}
102
103 XSLTPROC=$config{XSLTPROC}
104
105 LEX=$config{LEX}
106 YACC=$config{YACC}
107 YAPP=$config{YAPP}
108 PIDL_ARGS=$config{PIDL_ARGS}
109
110 GCOV=$config{GCOV}
111
112 DEFAULT_TEST_TARGET=$config{DEFAULT_TEST_TARGET}
113
114 __EOD__
115 }
116
117 sub _prepare_default_rule()
118 {
119         return << '__EOD__';
120 default: all
121
122 __EOD__
123 }
124
125 sub _prepare_SUFFIXES()
126 {
127         return << '__EOD__';
128 .SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .so .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .ho
129
130 __EOD__
131 }
132
133 sub _prepare_man_rule($)
134 {
135         my $suffix = shift;
136
137         return << "__EOD__";
138 .$suffix.xml.$suffix:
139         \$(XSLTPROC) -o \$@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \$<
140
141 __EOD__
142 }
143
144 sub _prepare_config_status()
145 {
146         my @parsed_files = @smb_build::config_mk::parsed_files;
147         my $deps = "";
148         
149         foreach (@parsed_files) {
150                 /^([^ |]+)/;
151                 $deps.= " $1";
152         }
153
154         return "
155
156 Makefile: config.status $deps
157         ./config.status
158
159 ";
160 }
161
162 sub _prepare_binaries($)
163 {
164         my $ctx = shift;
165
166         my @bbn_list = ();
167         my @sbn_list = ();
168
169         foreach (values %$ctx) {
170                 next unless defined $_->{OUTPUT_TYPE};
171                 next unless ($_->{OUTPUT_TYPE} eq "BINARY");
172
173                 next unless defined($_->{INSTALLDIR});
174
175                 push(@sbn_list, $_->{OUTPUT}) if ($_->{INSTALLDIR} eq "SBINDIR");
176                 push(@bbn_list, $_->{OUTPUT}) if ($_->{INSTALLDIR} eq "BINDIR");
177         }
178
179         my $bbn = array2oneperline(\@bbn_list);
180         my $sbn = array2oneperline(\@sbn_list);
181         return << "__EOD__";
182 BIN_PROGS = $bbn
183 SBIN_PROGS = $sbn
184 __EOD__
185 }
186
187 sub _prepare_manpages($)
188 {
189         my $ctx = shift;
190
191         my @mp_list = ();
192
193         foreach (values %$ctx) {
194                 push (@mp_list, "$_->{BASEDIR}/$_->{MANPAGE}") if (defined($_->{MANPAGE}) and $_->{MANPAGE} ne "");
195         }
196         
197         my $mp = array2oneperline(\@mp_list);
198         return << "__EOD__";
199 MANPAGES = $mp
200
201 __EOD__
202 }
203
204 sub _prepare_dummy_MAKEDIR()
205 {
206         my $ctx = shift;
207
208         my $ret = << '__EOD__';
209 bin/.dummy:
210         @: >> $@ || : > $@
211
212 dynconfig.o: dynconfig.c Makefile
213         @echo Compiling $*.c
214         @$(CC) $(CFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@
215 __EOD__
216         if ($config{BROKEN_CC} eq "yes") {
217                 $ret .= '       -mv `echo $@ | sed \'s%^.*/%%g\'` $@
218 ';
219         }
220         return $ret."\n";
221 }
222
223 sub _prepare_depend_CC_rule()
224 {
225         return << '__EOD__';
226
227 .c.d:
228         @echo "Generating dependencies for $<"
229         @$(CC) -MM -MG -MT $(<:.c=.o) -MF $@ $(CFLAGS) $<
230
231 __EOD__
232 }
233
234 ###########################################################
235 # This function creates a standard make rule which is using $(CC)
236 #
237 # $output = _prepare_std_CC_rule($srcext,$destext,$flags,$message,$comment)
238 #
239 # $srcext -     sourcefile extension
240 #
241 # $destext -    destinationfile extension
242 #
243 # $flags -      additional compiler flags
244 #
245 # $message -    logmessage which is echoed while running this rule
246 #
247 # $comment -    just a comment what this rule should do
248 #
249 # $output -             the resulting output buffer
250 sub _prepare_std_CC_rule($$$$$)
251 {
252         my ($src,$dst,$flags,$message,$comment) = @_;
253
254         my $ret = << "__EOD__";
255 # $comment
256 .$src.$dst:
257         \@echo $message \$\*.$src
258         \@\$(CC) `script/cflags.sh \$\@` \$(CFLAGS) $flags -c \$< -o \$\@
259 __EOD__
260         if ($config{BROKEN_CC} eq "yes") {
261                 $ret.= '        -mv `echo $@ | sed \'s%^.*/%%g\'` $@
262 ';
263         }
264         return $ret."\n";
265 }
266
267 sub _prepare_hostcc_rule()
268 {
269         my $ret = << "__EOD__";
270 .c.ho:
271         \@echo Compiling \$\*.c with host compiler
272         \@\$(HOSTCC) `script/cflags.sh \$\@` \$(CFLAGS) -c \$< -o \$\@
273 __EOD__
274         if ($config{BROKEN_CC} eq "yes") {
275                 $ret .= '       -mv `echo $@ | sed \'s%^.*/%%g\' -e \'s%\.ho$$%.o%\'` $@
276 ';
277         }
278
279         return $ret."\n";
280 }
281
282
283
284 sub array2oneperline($)
285 {
286         my $array = shift;
287         my $output = "";
288
289         foreach (@$array) {
290                 next unless defined($_);
291
292                 $output .= " \\\n\t\t$_";
293         }
294
295         return $output;
296 }
297
298 ###########################################################
299 # This function creates a object file list
300 #
301 # $output = _prepare_var_obj_list($var, $var_ctx)
302 #
303 # $var_ctx -            the subsystem context
304 #
305 # $var_ctx->{NAME}      -       the <var> name
306 # $var_ctx->{OBJ_LIST}  -       the list of objectfiles which sould be linked to this <var>
307 #
308 # $output -             the resulting output buffer
309 sub _prepare_obj_list($$)
310 {
311         my ($var,$ctx) = @_;
312
313         my $tmplist = array2oneperline($ctx->{OBJ_LIST});
314         return "" if ($tmplist eq "");
315
316         return << "__EOD__";
317 $var\_$ctx->{NAME}_OBJS =$tmplist
318 __EOD__
319 }
320
321 sub _prepare_cflags($$)
322 {
323         my ($var,$ctx) = @_;
324
325         my $tmplist = array2oneperline($ctx->{CFLAGS});
326         return "" if ($tmplist eq "");
327
328         return << "__EOD__";
329 $var\_$ctx->{NAME}_CFLAGS =$tmplist
330
331 __EOD__
332 }
333
334 ###########################################################
335 # This function creates a make rule for linking a library
336 #
337 # $output = _prepare_shared_library_rule($library_ctx)
338 #
339 # $library_ctx -                the library context
340 #
341 # $library_ctx->{NAME} -                the library name
342 #
343 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
344 #
345 # $library_ctx->{LIBRARY_NAME} -        the shared library name
346 # $library_ctx->{LIBRARY_REALNAME} -    the shared library real name
347 # $library_ctx->{LIBRARY_SONAME} - the shared library soname
348 # $library_ctx->{LINK_LIST} -   the list of objectfiles and external libraries
349 #                                       which sould be linked to this shared library
350 # $library_ctx->{LINK_FLAGS} -  linker flags used by this shared library
351 #
352 # $output -             the resulting output buffer
353 sub _prepare_shared_library_rule($)
354 {
355         my $ctx = shift;
356         my $output;
357
358         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
359         my $tmpshlink = array2oneperline($ctx->{LINK_LIST});
360         my $tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
361
362         $output = << "__EOD__";
363 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
364 LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink
365 LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag
366 #
367
368 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
369         \@echo Linking \$\@
370         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
371                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\
372                 \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST)
373
374 __EOD__
375
376         if (defined($ctx->{LIBRARY_SONAME})) {
377             $output .= << "__EOD__";
378 # Symlink $ctx->{LIBRARY_SONAME}
379 bin/$ctx->{LIBRARY_SONAME}: bin/$ctx->{LIBRARY_REALNAME} bin/.dummy
380         \@echo Symlink \$\@
381         \@ln -sf $ctx->{LIBRARY_REALNAME} \$\@
382 # Symlink $ctx->{LIBRARY_NAME}
383 bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy
384         \@echo Symlink \$\@
385         \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
386
387 __EOD__
388         }
389
390 $output .= << "__EOD__";
391 library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}
392
393 __EOD__
394
395         return $output;
396 }
397
398 sub _prepare_mergedobj_rule($)
399 {
400         my $ctx = shift;
401
402         return "" unless $ctx->{TARGET};
403
404         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
405
406         my $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
407
408         $output .= "$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
409
410         $output .= "\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n";
411         $output .= "\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJS) -o $ctx->{TARGET}\n";
412         $output .= "\n";
413
414         return $output;
415 }
416
417 sub _prepare_objlist_rule($)
418 {
419         my $ctx = shift;
420         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
421
422         return "" unless $ctx->{TARGET};
423
424         my $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
425         $output .= "$ctx->{TARGET}: ";
426         $output .= "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
427         $output .= "\t\@touch $ctx->{TARGET}\n";
428
429         return $output;
430 }
431
432 ###########################################################
433 # This function creates a make rule for linking a library
434 #
435 # $output = _prepare_static_library_rule($library_ctx)
436 #
437 # $library_ctx -                the library context
438 #
439 # $library_ctx->{NAME} -                the library name
440 #
441 # $library_ctx->{DEPEND_LIST} -         the list of rules on which this library depends
442 #
443 # $library_ctx->{LIBRARY_NAME} -        the static library name
444 # $library_ctx->{LINK_LIST} -   the list of objectfiles which sould be linked
445 #                                       to this static library
446 # $library_ctx->{LINK_FLAGS} -  linker flags used by this static library
447 #
448 # $output -             the resulting output buffer
449 sub _prepare_static_library_rule($)
450 {
451         my $ctx = shift;
452         my $output;
453
454         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
455         my $tmpstlink = array2oneperline($ctx->{LINK_LIST});
456         my $tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
457
458         $output = << "__EOD__";
459 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
460 #
461 LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink
462 #
463 $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
464         \@echo Linking \$@
465         \@\$(STLD) \$(STLD_FLAGS) \$@ \\
466                 \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST)
467
468 library_$ctx->{NAME}: basics $ctx->{TARGET}
469
470 __EOD__
471
472         return $output;
473 }
474
475 ###########################################################
476 # This function creates a make rule for linking a binary
477 #
478 # $output = _prepare_binary_rule($binary_ctx)
479 #
480 # $binary_ctx -         the binary context
481 #
482 # $binary_ctx->{NAME} -         the binary name
483 # $binary_ctx->{BINARY} -       the binary binary name
484 #
485 # $binary_ctx->{DEPEND_LIST} -  the list of rules on which this binary depends
486 # $binary_ctx->{LINK_LIST} -    the list of objectfiles and external libraries
487 #                               which sould be linked to this binary
488 # $binary_ctx->{LINK_FLAGS} -   linker flags used by this binary
489 #
490 # $output -             the resulting output buffer
491 sub _prepare_binary_rule($)
492 {
493         my $ctx = shift;
494
495         my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
496         my $tmplink = array2oneperline($ctx->{LINK_LIST});
497         my $tmpflag = array2oneperline($ctx->{LINK_FLAGS});
498
499         my $output = << "__EOD__";
500 #
501 BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
502 BINARY_$ctx->{NAME}_LINK_LIST =$tmplink
503 BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag
504 #
505 bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) \$(BINARY_$ctx->{NAME}_OBJS)
506         \@echo Linking \$\@
507         \@\$(CC) \$(LD_FLAGS) -o \$\@ \\
508                 \$\(BINARY_$ctx->{NAME}_LINK_FLAGS) \\
509                 \$\(BINARY_$ctx->{NAME}_LINK_LIST) \\
510                 \$\(BINARY_$ctx->{NAME}_LINK_FLAGS)
511 binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY}
512
513 __EOD__
514
515         return $output;
516 }
517
518 sub _prepare_custom_rule($)
519 {
520         my $ctx = shift;
521         return "
522 $ctx->{NAME}: bin/.TARGET_$ctx->{NAME}
523
524 bin/.TARGET_$ctx->{NAME}:
525         $ctx->{CMD}
526         touch bin/.TARGET_$ctx->{NAME}
527 ";
528 }
529
530 sub _prepare_clean_rules()
531 {
532         my $output = << '__EOD__';
533 clean: heimdal_clean
534         @echo Removing headers
535         @-rm -f include/proto.h
536         @echo Removing objects
537         @-find . -name '*.o' -exec rm -f '{}' \;
538         @echo Removing binaries
539         @-rm -f $(BIN_PROGS) $(SBIN_PROGS)
540         @echo Removing dummy targets
541         @-rm -f bin/.*_*
542         @echo Removing generated files
543         @-rm -rf librpc/gen_* 
544         @-rm -f lib/registry/regf.h lib/registry/tdr_regf*
545
546 distclean: clean
547         -rm -f bin/.dummy
548         -rm -f include/config.h include/smb_build.h
549         -rm -f Makefile 
550         -rm -f config.status
551         -rm -f config.log config.cache
552         -rm -f samba4-deps.dot
553         -rm -f config.pm config.mk
554         -rm -f lib/registry/winregistry.pc
555 __EOD__
556
557         if ($config{developer} eq "yes") {
558                 $output .= "\t\@-rm -f \$(_ALL_OBJS_OBJS:.o=.d)\n";
559         }
560
561         $output .= << '__EOD__';
562
563 removebackup:
564         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
565
566 realdistclean: distclean removebackup
567         -rm -f include/config.h.in
568         -rm -f include/version.h
569         -rm -f configure
570         -rm -f $(MANPAGES)
571 __EOD__
572
573         return $output;
574 }
575
576 sub _prepare_make_target($)
577 {
578         my $ctx = shift;
579         my $tmpdepend;
580
581         $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
582
583         return << "__EOD__";
584 $ctx->{TARGET}: basics $tmpdepend
585
586 __EOD__
587 }
588
589 sub _prepare_target_settings($)
590 {
591         my $CTX = shift;
592         my $output = "";
593
594         foreach my $key (values %$CTX) {
595                 if (defined($key->{OBJ_LIST})) {
596                         $output .= _prepare_obj_list($key->{TYPE}, $key);
597                         $output .= _prepare_cflags($key->{TYPE}, $key);
598                 }
599         }
600
601         return $output;
602 }
603
604 sub _prepare_rule_lists($)
605 {
606         my $depend = shift;
607         my $output = "";
608
609         foreach my $key (values %{$depend}) {
610                 next unless defined $key->{OUTPUT_TYPE};
611
612                 ($output .= _prepare_mergedobj_rule($key)) if $key->{OUTPUT_TYPE} eq "MERGEDOBJ";
613                 ($output .= _prepare_objlist_rule($key)) if $key->{OUTPUT_TYPE} eq "OBJLIST";
614                 ($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
615                 ($output .= _prepare_shared_library_rule($key)) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
616                 ($output .= _prepare_binary_rule($key)) if $key->{OUTPUT_TYPE} eq "BINARY";
617                 ($output .= _prepare_custom_rule($key) ) if $key->{TYPE} eq "TARGET";
618         }
619
620         $output .= _prepare_clean_rules();
621
622         return $output;
623 }
624
625 ###########################################################
626 # This function prepares the output for Makefile
627 #
628 # $output = _prepare_makefile($OUTPUT)
629 #
630 # $OUTPUT -     the global OUTPUT context
631 #
632 # $output -             the resulting output buffer
633 sub _prepare_makefile($)
634 {
635         my ($CTX) = @_;
636         my $output;
637
638         $output  = "############################################\n";
639         $output .= "# Autogenerated by build/smb_build/main.pl #\n";
640         $output .= "############################################\n";
641         $output .= "\n";
642
643         $output .= _prepare_path_vars();
644         $output .= _prepare_compiler_linker();
645         $output .= _prepare_default_rule();
646         $output .= _prepare_SUFFIXES();
647         $output .= _prepare_dummy_MAKEDIR();
648         $output .= _prepare_hostcc_rule();
649         $output .= _prepare_std_CC_rule("c","o",'$(PICFLAG)',"Compiling","Rule for std objectfiles");
650         $output .= _prepare_std_CC_rule("h","h.gch",'$(PICFLAG)',"Precompiling","Rule for precompiled headerfiles");
651
652         $output .= _prepare_depend_CC_rule();
653         
654         $output .= _prepare_man_rule("1");
655         $output .= _prepare_man_rule("3");
656         $output .= _prepare_man_rule("5");
657         $output .= _prepare_man_rule("7");
658         $output .= _prepare_manpages($CTX);
659         $output .= _prepare_binaries($CTX);
660         $output .= _prepare_target_settings($CTX);
661         $output .= _prepare_rule_lists($CTX);
662         $output .= _prepare_config_status();
663
664         if ($config{developer} eq "yes") {
665                 $output .= <<__EOD__
666 #-include \$(_ALL_OBJS_OBJS:.o=.d)
667 IDL_FILES = \$(wildcard librpc/idl/*.idl)
668 \$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.c,\$(IDL_FILES)) \\
669 \$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_\%_c.c,\$(IDL_FILES)) \\
670 \$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.h,\$(IDL_FILES)): idl
671 __EOD__
672         }
673
674         return $output;
675 }
676
677 ###########################################################
678 # This function creates Makefile from the OUTPUT 
679 # context
680 #
681 # create_makefile($OUTPUT)
682 #
683 # $OUTPUT       -       the global OUTPUT context
684 #
685 # $output -             the resulting output buffer
686 sub create_makefile($$$)
687 {
688         my ($CTX, $mk, $file) = @_;
689
690         open(MAKEFILE,">$file") || die ("Can't open $file\n");
691         print MAKEFILE _prepare_makefile($CTX) . $mk;
692         close(MAKEFILE);
693
694         print "build/smb_build/main.pl: creating $file\n";
695         return; 
696 }
697
698 1;