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