r14139: Fix issue with undefined variables.
[bbaumbach/samba-autobuild/.git] / source / build / smb_build / makefile.pm
1 # Samba Build System
2 # - create output for Makefile
3 #
4 #  Copyright (C) Stefan (metze) Metzmacher 2004
5 #  Copyright (C) Jelmer Vernooij 2005
6 #  Released under the GNU GPL
7
8 package smb_build::makefile;
9 use smb_build::env;
10 use strict;
11
12 use base 'smb_build::env';
13
14 sub new($$$)
15 {
16         my ($myname, $config, $mkfile) = @_;
17         my $self = new smb_build::env($config);
18         
19         bless($self, $myname);
20
21         $self->{manpages} = [];
22         $self->{sbin_progs} = [];
23         $self->{bin_progs} = [];
24         $self->{static_libs} = [];
25         $self->{shared_libs} = [];
26         $self->{headers} = [];
27         $self->{shared_modules} = [];
28         $self->{plugins} = [];
29         $self->{install_plugins} = "";
30         $self->{uninstall_plugins} = "";
31         $self->{pc_files} = [];
32         $self->{proto_headers} = [];
33         $self->{output} = "";
34
35         $self->{mkfile} = $mkfile;
36
37         $self->output("#!gmake\n");
38         $self->output("################################################\n");
39         $self->output("# Autogenerated by build/smb_build/makefile.pm #\n");
40         $self->output("################################################\n");
41         $self->output("\n");
42
43         $self->output("default: all\n\n");
44
45         $self->_prepare_path_vars();
46         $self->_prepare_compiler_linker();
47         $self->output(".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 .8 .8.xml .ho\n");
48         $self->_prepare_hostcc_rule();
49         $self->_prepare_std_CC_rule("c","o",'$(PICFLAG)',"Compiling","Rule for std objectfiles");
50         $self->_prepare_std_CC_rule("h","h.gch",'$(PICFLAG)',"Precompiling","Rule for precompiled headerfiles");
51
52         return $self;
53 }
54
55 sub output($$)
56 {
57         my ($self, $text) = @_;
58
59         $self->{output} .= $text;
60 }
61
62 sub _prepare_path_vars($)
63 {
64         my ($self) = @_;
65
66         $self->output(<< "__EOD__"
67 prefix = $self->{config}->{prefix}
68 exec_prefix = $self->{config}->{exec_prefix}
69 selftest_prefix = $self->{config}->{selftest_prefix}
70 VPATH = $self->{config}->{srcdir}
71 srcdir = $self->{config}->{srcdir}
72 builddir = $self->{config}->{builddir}
73
74 BASEDIR = $self->{config}->{prefix}
75 BINDIR = $self->{config}->{bindir}
76 SBINDIR = $self->{config}->{sbindir}
77 LIBDIR = $self->{config}->{libdir}
78 MODULESDIR = $self->{config}->{libdir}
79 INCLUDEDIR = $self->{config}->{includedir}
80 CONFIGDIR = $self->{config}->{sysconfdir}
81 SWATDIR = $self->{config}->{datadir}/swat
82 JSDIR = $self->{config}->{datadir}/js
83 SETUPDIR = $self->{config}->{datadir}/setup
84 VARDIR = $self->{config}->{localstatedir}
85 LOGFILEBASE = $self->{config}->{logfilebase}
86 NCALRPCDIR = $self->{config}->{localstatedir}/ncalrpc
87 LOCKDIR = $self->{config}->{lockdir}
88 PIDDIR = $self->{config}->{piddir}
89 MANDIR = $self->{config}->{mandir}
90 PRIVATEDIR = $self->{config}->{privatedir}
91 WINBINDD_SOCKET_DIR = $self->{config}->{winbindd_socket_dir}
92
93 __EOD__
94 );
95 }
96
97 sub _prepare_compiler_linker($)
98 {
99         my ($self) = @_;
100
101         my $devld_local = "";
102         my $devld_install = "";
103
104         $self->{duplicate_build} = 0;
105         if ($self->{config}->{LIBRARY_OUTPUT_TYPE} eq "SHARED_LIBRARY") {
106                 if ($self->{developer}) {
107                         $self->{duplicate_build} = 1;
108                         $devld_local = " -Wl,-rpath,\$(builddir)/bin";
109                 }
110                 $devld_install = " -Wl,-rpath-link,\$(builddir)/bin";
111         }
112
113         $self->output(<< "__EOD__"
114 SHELL=$self->{config}->{SHELL}
115
116 PERL=$self->{config}->{PERL}
117
118 CPP=$self->{config}->{CPP}
119 CPPFLAGS=$self->{config}->{CPPFLAGS}
120
121 CC=$self->{config}->{CC}
122 CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} \$(CPPFLAGS)
123 PICFLAG=$self->{config}->{PICFLAG}
124 HOSTCC=$self->{config}->{HOSTCC}
125
126 LOCAL_LINK_FLAGS=$devld_local
127 INSTALL_LINK_FLAGS=$devld_install
128
129 LD=$self->{config}->{LD} 
130 LDFLAGS=$self->{config}->{LDFLAGS} -L\$(builddir)/bin
131
132 STLD=$self->{config}->{AR}
133 STLD_FLAGS=-rc -L\$(builddir)/bin
134
135 SHLD=$self->{config}->{CC}
136 SHLD_FLAGS=$self->{config}->{LDSHFLAGS} -L\$(builddir)/bin
137 SONAMEFLAG=$self->{config}->{SONAMEFLAG}
138 SHLIBEXT=$self->{config}->{SHLIBEXT}
139
140 XSLTPROC=$self->{config}->{XSLTPROC}
141
142 LEX=$self->{config}->{LEX}
143 YACC=$self->{config}->{YACC}
144 YAPP=$self->{config}->{YAPP}
145 PIDL_ARGS=$self->{config}->{PIDL_ARGS}
146
147 GCOV=$self->{config}->{GCOV}
148
149 DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET}
150
151 __EOD__
152 );
153 }
154
155 sub _prepare_mk_files($)
156 {
157         my $self = shift;
158         my @tmp = ();
159
160         
161         foreach (@smb_build::config_mk::parsed_files) {
162                 s/ .*$//g;
163                 push (@tmp, $_);
164         }
165
166         $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
167 }
168
169 sub _prepare_dummy_MAKEDIR($)
170 {
171         my ($self) = @_;
172
173         $self->output(<< '__EOD__'
174 dynconfig.o: dynconfig.c Makefile
175         @echo Compiling $*.c
176         @$(CC) $(CFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@
177 __EOD__
178 );
179         if ($self->{config}->{BROKEN_CC} eq "yes") {
180                 $self->output(' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
181 ');
182         }
183         $self->output("\n");
184 }
185
186 sub _prepare_std_CC_rule($$$$$$)
187 {
188         my ($self,$src,$dst,$flags,$message,$comment) = @_;
189
190         $self->output(<< "__EOD__"
191 # $comment
192 .$src.$dst:
193         \@echo $message \$\*.$src
194         \@\$(CC) `script/cflags.pl \$\@` \$(CFLAGS) $flags -c \$\*.$src -o \$\@
195 __EOD__
196 );
197         if ($self->{config}->{BROKEN_CC} eq "yes") {
198                 $self->output(' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
199 ');
200         }
201
202         $self->output("\n");
203 }
204
205 sub _prepare_hostcc_rule($)
206 {
207         my ($self) = @_;
208         
209         $self->output(<< "__EOD__"
210 .c.ho:
211         \@echo Compiling \$\*.c with host compiler
212         \@\$(HOSTCC) `script/cflags.pl \$\@` \$(CFLAGS) -c \$\*.c -o \$\@
213 __EOD__
214 );
215         if ($self->{config}->{BROKEN_CC} eq "yes") {
216                 $self->output(' -mv `echo $@ | sed \'s%^.*/%%g\' -e \'s%\.ho$$%.o%\'` $@
217 ');
218         }
219
220         $self->output("\n");
221 }
222
223 sub array2oneperline($)
224 {
225         my $array = shift;
226         my $output = "";
227
228         foreach (@$array) {
229                 next unless defined($_);
230
231                 $output .= " \\\n\t\t$_";
232         }
233
234         return $output;
235 }
236
237 sub _prepare_list($$$)
238 {
239         my ($self,$ctx,$var) = @_;
240
241         my $tmplist = array2oneperline($ctx->{$var});
242         return if ($tmplist eq "");
243
244         $self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
245 }
246
247 sub DependencyInfo($$)
248 {
249         my ($self,$ctx) = @_;
250
251         $self->output("bin/deps/$ctx->{TYPE}_$ctx->{NAME}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)");
252         $self->output("\n");
253         $self->output("\t\@echo \"Generating dependency info for $ctx->{NAME}\"\n");
254         $self->output("\t\@./script/cdeps.pl \$^ > \$@\n");
255         $self->output("\n");
256         $self->output("-include bin/deps/$ctx->{TYPE}_$ctx->{NAME}\n\n");
257 }
258
259 sub SharedLibrary($$)
260 {
261         my ($self,$ctx) = @_;
262
263         my $installdir;
264         my $init_obj = "";
265         
266         if ($self->{duplicate_build}) {
267                 $installdir = "bin/install";
268         } else {
269                 $installdir = "bin";
270         }
271
272         if ($ctx->{TYPE} eq "LIBRARY") {
273                 push (@{$self->{shared_libs}}, "bin/$ctx->{LIBRARY_REALNAME}");
274         } elsif ($ctx->{TYPE} eq "MODULE") {
275                 push (@{$self->{shared_modules}}, "bin/$ctx->{LIBRARY_REALNAME}");
276                 push (@{$self->{plugins}}, "$installdir/$ctx->{LIBRARY_REALNAME}");
277
278                 my $fixedname = $ctx->{NAME};
279
280                 $fixedname =~ s/^$ctx->{SUBSYSTEM}_//g;
281
282                 $self->{install_plugins} .= "\t\@echo Installing $installdir/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
283                 $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/\n";
284                 $self->{install_plugins} .= "\t\@cp $installdir/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
285                 $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
286                 $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
287         }
288
289         $self->_prepare_list($ctx, "OBJ_LIST");
290         $self->_prepare_list($ctx, "CFLAGS");
291         $self->_prepare_list($ctx, "DEPEND_LIST");
292         $self->_prepare_list($ctx, "LINK_LIST");
293         $self->_prepare_list($ctx, "LINK_FLAGS");
294
295         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
296
297         if ($ctx->{NOPROTO} eq "NO") {
298                 push(@{$self->{proto_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST\)");
299         }
300
301         if ($ctx->{TYPE} eq "MODULE" and defined($ctx->{INIT_FUNCTION})) {
302                 my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
303                 $init_fn =~ s/\(\*\)/init_module/;
304                 my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
305                 $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
306
307                 $self->output(<< "__EOD__"
308 bin/$ctx->{NAME}_init_module.c:
309         \@echo Creating \$\@
310         \@echo \"#include \\\"includes.h\\\"\" > \$\@
311         \@echo \"$proto_fn;\" >> \$\@
312         \@echo -e \"_PUBLIC_ $init_fn \\n{\\n\\treturn $ctx->{INIT_FUNCTION}();\\n}\\n\" >> \$\@
313 __EOD__
314 );
315                 $init_obj = "bin/$ctx->{NAME}_init_module.o";
316         }
317
318         if ($self->{duplicate_build}) {
319                 $self->output(<< "__EOD__"
320 #
321
322 bin/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
323         \@echo Linking \$\@
324         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\
325                 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) \\
326                 $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
327
328 __EOD__
329 );
330                 if (defined($ctx->{LIBRARY_SONAME})) {
331                         $self->output(<< "__EOD__"
332 # Symlink $ctx->{LIBRARY_SONAME}
333 bin/$ctx->{LIBRARY_SONAME}: bin/$ctx->{LIBRARY_REALNAME} 
334         \@echo Symlink \$\@
335         \@ln -sf $ctx->{LIBRARY_REALNAME} \$\@
336 # Symlink $ctx->{LIBRARY_NAME}
337 bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} 
338         \@echo Symlink \$\@
339         \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
340
341 __EOD__
342 );
343                 }
344         }
345
346         $self->output(<< "__EOD__"
347 #
348
349 $installdir/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
350         \@echo Linking \$\@
351         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
352                 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) \\
353                 $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
354
355 __EOD__
356 );
357         if (defined($ctx->{LIBRARY_SONAME})) {
358             $self->output(<< "__EOD__"
359 # Symlink $ctx->{LIBRARY_SONAME}
360 $installdir/$ctx->{LIBRARY_SONAME}: $installdir/$ctx->{LIBRARY_REALNAME}
361         \@echo Symlink \$\@
362         \@ln -sf $ctx->{LIBRARY_REALNAME} \$\@
363 # Symlink $ctx->{LIBRARY_NAME}
364 $installdir/$ctx->{LIBRARY_NAME}: $installdir/$ctx->{LIBRARY_SONAME}
365         \@echo Symlink \$\@
366         \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
367
368 __EOD__
369 );
370         }
371 }
372
373 sub MergedObj($$)
374 {
375         my ($self,$ctx) = @_;
376
377         return unless $ctx->{TARGET};
378
379         $self->_prepare_list($ctx, "OBJ_LIST");
380         $self->_prepare_list($ctx, "CFLAGS");
381         $self->_prepare_list($ctx, "DEPEND_LIST");
382
383         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
384                 
385         if ($ctx->{NOPROTO} eq "NO") {
386                 push(@{$self->{proto_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST\)");
387         }
388
389         $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n");
390
391         $self->output("\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n");
392         $self->output("\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) -o $ctx->{TARGET}\n");
393         $self->output("\n");
394 }
395
396 sub ObjList($$)
397 {
398         my ($self,$ctx) = @_;
399
400         return unless $ctx->{TARGET};
401
402         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
403                 
404         if ($ctx->{NOPROTO} eq "NO") {
405                 push(@{$self->{proto_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST\)");
406         }
407
408         $self->_prepare_list($ctx, "OBJ_LIST");
409         $self->_prepare_list($ctx, "CFLAGS");
410         $self->_prepare_list($ctx, "DEPEND_LIST");
411         $self->output("$ctx->{TARGET}: ");
412         $self->output("\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n");
413         $self->output("\t\@touch $ctx->{TARGET}\n");
414 }
415
416 sub StaticLibrary($$)
417 {
418         my ($self,$ctx) = @_;
419
420         push (@{$self->{static_libs}}, $ctx->{OUTPUT});
421
422         $self->_prepare_list($ctx, "OBJ_LIST");
423         $self->_prepare_list($ctx, "CFLAGS");
424
425         $self->_prepare_list($ctx, "DEPEND_LIST");
426         $self->_prepare_list($ctx, "LINK_LIST");
427         $self->_prepare_list($ctx, "LINK_FLAGS");
428
429         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
430                 
431         if ($ctx->{NOPROTO} eq "NO") {
432                 push(@{$self->{proto_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST\)");
433         }
434
435         $self->output(<< "__EOD__"
436 #
437 $ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) 
438         \@echo Linking \$@
439         \@\$(STLD) \$(STLD_FLAGS) \$@ \\
440                 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
441
442 __EOD__
443 );
444 }
445
446 sub Header($$)
447 {
448         my ($self,$ctx) = @_;
449
450         foreach (@{$ctx->{PUBLIC_HEADERS}}) {
451                 push (@{$self->{headers}}, "$ctx->{BASEDIR}/$_");
452         }
453 }
454
455 sub Binary($$)
456 {
457         my ($self,$ctx) = @_;
458
459         my $installdir;
460         
461         if ($self->{duplicate_build}) {
462                 $installdir = "bin/install";
463         } else {
464                 $installdir = "bin";
465         }
466
467         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
468                 
469         if ($ctx->{NOPROTO} eq "NO") {
470                 push(@{$self->{proto_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST\)");
471         }
472
473         unless (defined($ctx->{INSTALLDIR})) {
474         } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
475                 push (@{$self->{sbin_progs}}, "$installdir/$ctx->{BINARY}");
476         } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
477                 push (@{$self->{bin_progs}}, "$installdir/$ctx->{BINARY}");
478         }
479
480         push (@{$self->{binaries}}, "bin/$ctx->{BINARY}");
481
482         $self->_prepare_list($ctx, "OBJ_LIST");
483         $self->_prepare_list($ctx, "CFLAGS");
484         $self->_prepare_list($ctx, "DEPEND_LIST");
485         $self->_prepare_list($ctx, "LINK_LIST");
486         $self->_prepare_list($ctx, "LINK_FLAGS");
487
488         if ($self->{duplicate_build}) {
489         $self->output(<< "__EOD__"
490 #
491 bin/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
492         \@echo Linking \$\@
493         \@\$(CC) \$(LDFLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\
494                 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\
495                 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
496
497 __EOD__
498 );
499         }
500
501 $self->output(<< "__EOD__"
502 $installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
503         \@echo Linking \$\@
504         \@\$(CC) \$(LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
505                 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\
506                 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) 
507
508 __EOD__
509 );
510 }
511
512 sub Manpage($$)
513 {
514         my ($self,$ctx) = @_;
515
516         my $dir = $ctx->{BASEDIR};
517         
518         $dir =~ s/^\.\///g;
519
520         push (@{$self->{manpages}}, "$dir/$ctx->{MANPAGE}");
521 }
522
523 sub PkgConfig($$)
524 {
525         my ($self,$ctx) = @_;
526         
527         my $link_name = $ctx->{NAME};
528
529         $link_name =~ s/^LIB//g;
530         $link_name = lc($link_name);
531
532         if (not defined($ctx->{DESCRIPTION})) {
533                 warn("$ctx->{NAME} has not DESCRIPTION set, not generating .pc file");
534                 return;
535         }
536
537         my $path = "$ctx->{BASEDIR}/$link_name.pc";
538
539         push (@{$self->{pc_files}}, $path);
540
541         smb_build::env::PkgConfig($self,
542                 $path,
543                 $link_name,
544                 $ctx->{OUTPUT},
545                 "",
546                 "$ctx->{MAJOR_VERSION}.$ctx->{MINOR_VERSION}.$ctx->{RELEASE_VERSION}",
547                 $ctx->{DESCRIPTION}
548         ); 
549 }
550
551 sub ProtoHeader($$)
552 {
553         my ($self,$ctx) = @_;
554
555         my $dir = $ctx->{BASEDIR};
556
557         $dir =~ s/^\.\///g;
558
559         my $comment = "";
560         if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
561                 $comment.= " and $dir/$ctx->{PUBLIC_PROTO_HEADER}";
562                 push (@{$self->{proto_headers}}, "$dir/$ctx->{PUBLIC_PROTO_HEADER}");
563         } else {
564                 $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
565         }       
566         push (@{$self->{proto_headers}}, "$dir/$ctx->{PRIVATE_PROTO_HEADER}");
567
568         $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)\n");
569         $self->output("\t\@echo \"Creating $dir/$ctx->{PRIVATE_PROTO_HEADER}$comment\"\n");
570
571         $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
572 }
573
574 sub write($$)
575 {
576         my ($self,$file) = @_;
577
578         $self->output("MANPAGES = ".array2oneperline($self->{manpages})."\n");
579         $self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
580         $self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
581         $self->output("BINARIES = " . array2oneperline($self->{binaries}) . "\n");
582         $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
583         $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
584         $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
585         $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
586         $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
587         $self->output("PROTO_OBJS = " . array2oneperline($self->{proto_objs}) .  "\n");
588         $self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) .  "\n");
589         $self->output("SHARED_MODULES = " . array2oneperline($self->{shared_modules}) . "\n");
590         $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
591
592         $self->output("\ninstallplugins: \$(PLUGINS)\n".$self->{install_plugins}."\n");
593         $self->output("\nuninstallplugins:\n".$self->{uninstall_plugins}."\n");
594
595         $self->_prepare_mk_files();
596
597         if ($self->{developer}) {
598                 $self->output(<<__EOD__
599
600 #-include \$(ALL_OBJS:.o=.d)
601
602 __EOD__
603 );
604         }
605
606         $self->_prepare_dummy_MAKEDIR();
607
608         $self->output($self->{mkfile});
609
610         open(MAKEFILE,">$file") || die ("Can't open $file\n");
611         print MAKEFILE $self->{output};
612         close(MAKEFILE);
613
614         print __FILE__.": creating $file\n";
615 }
616
617 1;