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