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