r15298: Fix the build using a few hacks in the build system.
[samba.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_build: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} $self->{config}->{LDFLAGS} -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 __EOD__
160 );
161 }
162
163 sub _prepare_mk_files($)
164 {
165         my $self = shift;
166         my @tmp = ();
167
168         foreach (@smb_build::config_mk::parsed_files) {
169                 s/ .*$//g;
170                 push (@tmp, $_);
171         }
172
173         $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
174 }
175
176 sub array2oneperline($)
177 {
178         my $array = shift;
179         my $output = "";
180
181         foreach (@$array) {
182                 next unless defined($_);
183
184                 $output .= " \\\n\t\t$_";
185         }
186
187         return $output;
188 }
189
190 sub _prepare_list($$$)
191 {
192         my ($self,$ctx,$var) = @_;
193
194         my $tmplist = array2oneperline($ctx->{$var});
195         return if ($tmplist eq "");
196
197         $self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
198 }
199
200 sub Integrated($$)
201 {
202         my ($self,$ctx) = @_;
203
204         $self->_prepare_list($ctx, "OBJ_LIST");
205         $self->_prepare_list($ctx, "LINK_FLAGS");
206 }
207
208 sub SharedLibrary($$)
209 {
210         my ($self,$ctx) = @_;
211
212         my $installdir;
213         my $init_obj = "";
214         
215         if ($self->{duplicate_build}) {
216                 $installdir = $ctx->{RELEASEDIR};
217         } else {
218                 $installdir = $ctx->{DEBUGDIR};
219         }
220
221         if ($ctx->{TYPE} eq "LIBRARY") {
222                 push (@{$self->{shared_libs}}, "$ctx->{DEBUGDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
223                 push (@{$self->{installable_shared_libs}}, "$installdir/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
224         } elsif ($ctx->{TYPE} eq "MODULE") {
225                 push (@{$self->{shared_modules}}, "$ctx->{TARGET}");
226                 push (@{$self->{plugins}}, "$installdir/$ctx->{LIBRARY_REALNAME}");
227
228                 $self->{install_plugins} .= "\t\@echo Installing $installdir/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
229                 $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/\n";
230                 $self->{install_plugins} .= "\t\@cp $installdir/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
231                 $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
232                 $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
233                 if (defined($ctx->{ALIASES})) {
234                         foreach (@{$ctx->{ALIASES}}) {
235                                 $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
236                                 $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
237                         }
238                 }
239         }
240
241         $self->_prepare_list($ctx, "OBJ_LIST");
242         $self->_prepare_list($ctx, "FULL_OBJ_LIST");
243         $self->_prepare_list($ctx, "DEPEND_LIST");
244         $self->_prepare_list($ctx, "LINK_FLAGS");
245
246         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
247
248         if ($ctx->{TYPE} eq "MODULE" and defined($ctx->{INIT_FUNCTION})) {
249                 my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
250                 $init_fn =~ s/\(\*\)/init_module/;
251                 my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
252                 $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
253
254                 $self->output(<< "__EOD__"
255 bin/$ctx->{NAME}_init_module.c:
256         \@echo Creating \$\@
257         \@echo \"#include \\\"includes.h\\\"\" > \$\@
258         \@echo \"$proto_fn;\" >> \$\@
259         \@echo -e \"_PUBLIC_ $init_fn \\n{\\n\\treturn $ctx->{INIT_FUNCTION}();\\n}\\n\" >> \$\@
260 __EOD__
261 );
262                 $init_obj = "bin/$ctx->{NAME}_init_module.o";
263         }
264
265         my $soarg = "";
266         my $soargdebug = "";
267         if ($self->{config}->{SONAMEFLAG} ne "" and 
268                 defined($ctx->{LIBRARY_SONAME})) {
269                 $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME} ";
270                 if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
271                         $soargdebug = "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{DEBUGDIR}/$ctx->{LIBRARY_SONAME}";
272                 }
273         }
274
275         my $singlesoarg = "";
276         
277         if ($ctx->{DEBUGDIR} ne $installdir) {
278                 $self->output(<< "__EOD__"
279 #
280
281 $ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
282         \@echo Linking \$\@
283         \@mkdir -p $ctx->{DEBUGDIR}
284         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\
285                 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
286                 $init_obj $soargdebug
287 __EOD__
288 );
289                 if (defined($ctx->{ALIASES})) {
290                         foreach (@{$ctx->{ALIASES}}) {
291                                 $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{DEBUGDIR}/$_.\$(SHLIBEXT)\n");
292                         }
293                 }
294
295                 $self->output("\n");
296         } else {
297                 if ($self->{config}->{SONAMEFLAG} ne "" and 
298                         defined($ctx->{LIBRARY_SONAME}) and 
299                         $ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
300                         $singlesoarg = "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $installdir/$ctx->{LIBRARY_SONAME}";
301                 }
302
303         }
304
305         $self->output(<< "__EOD__"
306 #
307
308 $installdir/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
309         \@echo Linking \$\@
310         \@mkdir -p $installdir
311         \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
312                 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
313                 $init_obj $singlesoarg
314
315 __EOD__
316 );
317 }
318
319 sub MergedObj($$)
320 {
321         my ($self,$ctx) = @_;
322
323         $self->_prepare_list($ctx, "OBJ_LIST");
324         $self->_prepare_list($ctx, "FULL_OBJ_LIST");
325         $self->_prepare_list($ctx, "DEPEND_LIST");
326
327         return unless $ctx->{TARGET};
328
329         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
330                 
331         $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)\n");
332
333         $self->output("\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n");
334         $self->output("\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) -o $ctx->{TARGET}\n");
335         $self->output("\n");
336 }
337
338 sub ObjList($$)
339 {
340         my ($self,$ctx) = @_;
341
342         return unless $ctx->{TARGET};
343
344         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
345                 
346         $self->_prepare_list($ctx, "OBJ_LIST");
347         $self->_prepare_list($ctx, "FULL_OBJ_LIST");
348         $self->_prepare_list($ctx, "DEPEND_LIST");
349         $self->output("$ctx->{TARGET}: ");
350         $self->output("\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)\n");
351         $self->output("\t\@touch $ctx->{TARGET}\n");
352 }
353
354 sub StaticLibrary($$)
355 {
356         my ($self,$ctx) = @_;
357
358         push (@{$self->{static_libs}}, $ctx->{TARGET});
359
360         $self->_prepare_list($ctx, "OBJ_LIST");
361         $self->_prepare_list($ctx, "FULL_OBJ_LIST");
362
363         $self->_prepare_list($ctx, "LINK_FLAGS");
364
365         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
366                 
367         $self->output(<< "__EOD__"
368 #
369 $ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
370         \@echo Linking \$@
371         \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
372
373 __EOD__
374 );
375 }
376
377 sub Header($$)
378 {
379         my ($self,$ctx) = @_;
380
381         my $dir = $ctx->{BASEDIR};
382
383         $dir =~ s/^\.\///g;
384
385         foreach (@{$ctx->{PUBLIC_HEADERS}}) {
386                 push (@{$self->{headers}}, "$dir/$_");
387         }
388 }
389
390 sub Binary($$)
391 {
392         my ($self,$ctx) = @_;
393
394         my $installdir;
395         
396         if ($self->{duplicate_build}) {
397                 $installdir = "bin/install";
398         } else {
399                 $installdir = "bin";
400         }
401
402         push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
403                 
404         unless (defined($ctx->{INSTALLDIR})) {
405         } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
406                 push (@{$self->{sbin_progs}}, "$installdir/$ctx->{BINARY}");
407         } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
408                 push (@{$self->{bin_progs}}, "$installdir/$ctx->{BINARY}");
409         }
410
411         push (@{$self->{binaries}}, "bin/$ctx->{BINARY}");
412
413         $self->_prepare_list($ctx, "OBJ_LIST");
414         $self->_prepare_list($ctx, "FULL_OBJ_LIST");
415         $self->_prepare_list($ctx, "DEPEND_LIST");
416         $self->_prepare_list($ctx, "LINK_FLAGS");
417
418         if ($self->{duplicate_build}) {
419         $self->output(<< "__EOD__"
420 #
421 bin/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) 
422         \@echo Linking \$\@
423         \@\$(CC) \$(LDFLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \$(INSTALL_LINK_FLAGS) \\
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}_FULL_OBJ_LIST) 
432         \@echo Linking \$\@
433         \@\$(CC) \$(LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
434                 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) 
435
436 __EOD__
437 );
438 }
439
440 sub Manpage($$)
441 {
442         my ($self,$ctx) = @_;
443
444         my $dir = $ctx->{BASEDIR};
445         
446         $dir =~ s/^\.\///g;
447
448         push (@{$self->{manpages}}, "$dir/$ctx->{MANPAGE}");
449 }
450
451 sub PkgConfig($$)
452 {
453         my ($self,$ctx) = @_;
454         
455         my $link_name = $ctx->{NAME};
456
457         $link_name =~ s/^LIB//g;
458         $link_name = lc($link_name);
459
460         return if (not defined($ctx->{DESCRIPTION}));
461
462         my $path = "$ctx->{BASEDIR}/$link_name.pc";
463
464         push (@{$self->{pc_files}}, $path);
465
466         my $pubs;
467         my $privs;
468
469         if (defined($ctx->{PUBLIC_DEPENDENCIES})) {
470                 foreach (@{$ctx->{PUBLIC_DEPENDENCIES}}) {
471 #                       next unless ($self-> ) {
472
473                         $pubs .= "$_ ";
474                 }
475         }
476
477         if (defined($ctx->{PRIVATE_DEPENDENCIES})) {
478                 foreach (@{$ctx->{PRIVATE_DEPENDENCIES}}) {
479 #                       next unless ($self-> ) {
480
481                         $privs .= "$_ ";
482                 }
483         }
484
485         smb_build::env::PkgConfig($self,
486                 $path,
487                 $link_name,
488                 "-l$link_name",
489                 "",
490                 "$ctx->{VERSION}",
491                 $ctx->{DESCRIPTION},
492                 defined($ctx->{INIT_FUNCTIONS}),
493                 $pubs,
494                 $privs
495         ); 
496 }
497
498 sub ProtoHeader($$)
499 {
500         my ($self,$ctx) = @_;
501
502         my $dir = $ctx->{BASEDIR};
503
504         $dir =~ s/^\.\///g;
505
506         my $target = "";
507
508         my $comment = "Creating ";
509         if (defined($ctx->{PRIVATE_PROTO_HEADER})) {
510                 $target.= "$dir/$ctx->{PRIVATE_PROTO_HEADER}";
511                 $comment.= "$dir/$ctx->{PRIVATE_PROTO_HEADER}";
512                 if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
513                         $comment .= " and ";
514                         $target.= " ";
515                 }
516                 push (@{$self->{proto_headers}}, "$dir/$ctx->{PRIVATE_PROTO_HEADER}");
517         } else {
518                 $ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER};
519         }
520         
521         if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
522                 $comment.= "$dir/$ctx->{PUBLIC_PROTO_HEADER}";
523                 $target .= "$dir/$ctx->{PUBLIC_PROTO_HEADER}";
524                 push (@{$self->{proto_headers}}, "$dir/$ctx->{PUBLIC_PROTO_HEADER}");
525         } else {
526                 $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
527         }       
528
529         $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: $ctx->{MK_FILE} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
530         $self->output("\t\@echo \"$comment\"\n");
531
532         $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");
533 }
534
535 sub write($$)
536 {
537         my ($self,$file) = @_;
538
539         $self->output("MANPAGES = ".array2oneperline($self->{manpages})."\n");
540         $self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
541         $self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
542         $self->output("BINARIES = " . array2oneperline($self->{binaries}) . "\n");
543         $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
544         $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
545         $self->output("INSTALLABLE_SHARED_LIBS = " . array2oneperline($self->{installable_shared_libs}) . "\n");
546         $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
547         $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
548         $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
549         $self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) .  "\n");
550         $self->output("SHARED_MODULES = " . array2oneperline($self->{shared_modules}) . "\n");
551         $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
552
553         $self->output("\ninstallplugins: \$(PLUGINS)\n".$self->{install_plugins}."\n");
554         $self->output("\nuninstallplugins:\n".$self->{uninstall_plugins}."\n");
555
556         # nasty hack to allow running locally
557         if ($self->{duplicate_build}) {
558                 $self->output("bin/libdynconfig.\$(SHLIBEXT).0.0.1: dynconfig-devel.o\n");
559                 $self->output("bin/libdynconfig.\$(SHLIBEXT).0.0.1: LIBRARY_DYNCONFIG_OBJ_LIST=dynconfig-devel.o\n");
560         }
561
562         $self->_prepare_mk_files();
563
564         $self->output($self->{mkfile});
565
566         if ($self->{automatic_deps}) {
567                 $self->output("
568 ifneq (\$(MAKECMDGOALS),clean)
569 ifneq (\$(MAKECMDGOALS),distclean)
570 ifneq (\$(MAKECMDGOALS),realdistclean)
571 -include \$(DEP_FILES)
572 endif
573 endif
574 endif
575 ");
576         } else {
577                 $self->output("include \$(srcdir)/static_deps.mk\n");
578         }
579
580         open(MAKEFILE,">$file") || die ("Can't open $file\n");
581         print MAKEFILE $self->{output};
582         close(MAKEFILE);
583
584         print __FILE__.": creating $file\n";
585 }
586
587 1;