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