2 # - create output for Makefile
4 # Copyright (C) Stefan (metze) Metzmacher 2004
5 # Copyright (C) Jelmer Vernooij 2005
6 # Released under the GNU GPL
8 package smb_build::makefile;
10 use smb_build::output;
14 use base 'smb_build::env';
19 my ($myname, $config, $mkfile) = @_;
20 my $self = new smb_build::env($config);
22 bless($self, $myname);
24 $self->{manpages} = [];
25 $self->{sbin_progs} = [];
26 $self->{bin_progs} = [];
27 $self->{torture_progs} = [];
28 $self->{static_libs} = [];
29 $self->{python_dsos} = [];
30 $self->{shared_libs} = [];
31 $self->{installable_shared_libs} = [];
32 $self->{headers} = [];
33 $self->{shared_modules} = [];
34 $self->{plugins} = [];
35 $self->{install_plugins} = "";
36 $self->{uninstall_plugins} = "";
37 $self->{pc_files} = [];
38 $self->{proto_headers} = [];
41 $self->{mkfile} = $mkfile;
43 $self->output("#!gmake\n");
44 $self->output("################################################\n");
45 $self->output("# Autogenerated by build/smb_build/makefile.pm #\n");
46 $self->output("################################################\n");
49 $self->output("default: all\n\n");
51 $self->_prepare_path_vars();
52 $self->_prepare_suffix_rules();
53 $self->_prepare_compiler_linker();
55 if (!$self->{automatic_deps}) {
56 $self->output("ALL_PREDEP = proto\n");
57 $self->output(".NOTPARALLEL:\n");
65 my ($self, $text) = @_;
67 $self->{output} .= $text;
70 sub _prepare_path_vars($)
74 $self->output(<< "__EOD__"
75 prefix = $self->{config}->{prefix}
76 exec_prefix = $self->{config}->{exec_prefix}
77 selftest_prefix = $self->{config}->{selftest_prefix}
79 builddir = $self->{config}->{builddir}
80 srcdir = $self->{config}->{srcdir}
81 datarootdir = $self->{config}->{datarootdir}
83 VPATH = \$(builddir):\$(srcdir):heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
85 BASEDIR = $self->{config}->{prefix}
86 BINDIR = $self->{config}->{bindir}
87 SBINDIR = $self->{config}->{sbindir}
88 LIBDIR = $self->{config}->{libdir}
89 TORTUREDIR = $self->{config}->{libdir}/torture
90 MODULESDIR = $self->{config}->{modulesdir}
91 INCLUDEDIR = $self->{config}->{includedir}
92 CONFIGDIR = $self->{config}->{sysconfdir}
93 DATADIR = $self->{config}->{datadir}
94 SWATDIR = \$(DATADIR)/swat
95 JSDIR = \$(DATADIR)/js
96 SETUPDIR = \$(DATADIR)/setup
97 VARDIR = $self->{config}->{localstatedir}
98 LOGFILEBASE = $self->{config}->{logfilebase}
99 NCALRPCDIR = $self->{config}->{localstatedir}/ncalrpc
100 LOCKDIR = $self->{config}->{lockdir}
101 PIDDIR = $self->{config}->{piddir}
102 MANDIR = $self->{config}->{mandir}
103 PRIVATEDIR = $self->{config}->{privatedir}
104 WINBINDD_SOCKET_DIR = $self->{config}->{winbindd_socket_dir}
110 sub _prepare_suffix_rules($)
113 my $first_prereq = '$*.c';
115 if ($self->{config}->{GNU_MAKE} eq 'yes') {
116 $first_prereq = '$<';
119 $self->output(<< "__EOD__"
120 FIRST_PREREQ = $first_prereq
122 # Dependencies command
123 DEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.o) -MT \$@ \\
124 `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
125 \$(CFLAGS) \$(FIRST_PREREQ) -o \$@
126 # Dependencies for host objects
127 HDEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.ho) -MT \$@ \\
128 `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
129 \$(HOSTCC_FLAGS) \$(FIRST_PREREQ) -o \$@
130 # Dependencies for precompiled headers
131 PCHDEPENDS = \$(CC) -M -MG -MT include/includes.h.gch -MT \$@ \\
132 \$(CFLAGS) \$(FIRST_PREREQ) -o \$@
134 # \$< is broken in older BSD versions:
135 # when \$@ is foo/bar.o, \$< could be torture/foo/bar.c
136 # if it also exists. So better use \$* which is foo/bar
137 # and append .c manually to get foo/bar.c
139 # If we have GNU Make, it is safe to use \$<, which also lets
140 # building with \$srcdir != \$builddir work.
142 # Run a static analysis checker
143 CHECK = \$(CC_CHECKER) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
144 \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
146 # Run the configured compiler
147 COMPILE = \$(CC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
148 \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
150 # Run the compiler for the build host
151 HCOMPILE = \$(HOSTCC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
152 \$(HOSTCC_FLAGS) -c \$(FIRST_PREREQ) -o \$@
155 PCHCOMPILE = @\$(CC) -Ilib/replace \\
156 `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
157 \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
163 sub _prepare_compiler_linker($)
167 my $builddir_headers = "";
169 my $extra_link_flags = "";
171 if ($self->{config}->{USESHARED} eq "true") {
172 $libdir = "\$(builddir)/bin/shared";
173 $extra_link_flags = "-Wl,-rpath-link,\$(builddir)/bin/shared";
175 $libdir = "\$(builddir)/bin/static";
178 if (!(abs_path($self->{config}->{srcdir}) eq abs_path($self->{config}->{builddir}))) {
179 $builddir_headers= "-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
182 $self->output(<< "__EOD__"
183 SHELL=$self->{config}->{SHELL}
185 PERL=$self->{config}->{PERL}
186 PYTHON=$self->{config}->{PYTHON}
187 SWIG=$self->{config}->{SWIG}
189 CPP=$self->{config}->{CPP}
190 CPPFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $self->{config}->{CPPFLAGS}
192 CC=$self->{config}->{CC}
193 CFLAGS=$self->{config}->{CFLAGS} \$(CPPFLAGS)
194 PICFLAG=$self->{config}->{PICFLAG}
196 INSTALL_LINK_FLAGS=$extra_link_flags
198 BNLD=$self->{config}->{LD}
199 BNLD_FLAGS=$self->{config}->{LDFLAGS} -L$libdir
201 STLD=$self->{config}->{STLD}
202 STLD_FLAGS=$self->{config}->{STLD_FLAGS}
204 SHLD=$self->{config}->{SHLD}
205 SHLD_FLAGS=$self->{config}->{SHLD_FLAGS} -L\$(builddir)/bin/shared
207 MDLD=$self->{config}->{MDLD}
208 MDLD_FLAGS=$self->{config}->{MDLD_FLAGS} -L\$(builddir)/bin/shared
210 SHLIBEXT=$self->{config}->{SHLIBEXT}
212 HOSTCC=$self->{config}->{HOSTCC}
213 HOSTCC_FLAGS=-D_SAMBA_HOSTCC_ $self->{config}->{CFLAGS} \$(CPPFLAGS)
215 HOSTLD=$self->{config}->{HOSTLD}
216 HOSTLD_FLAGS=$self->{config}->{LDFLAGS}
218 XSLTPROC=$self->{config}->{XSLTPROC}
220 LEX=$self->{config}->{LEX}
221 YACC=$self->{config}->{YACC}
222 YAPP=$self->{config}->{YAPP}
224 GCOV=$self->{config}->{GCOV}
226 DEFAULT_TEST_OPTIONS=$self->{config}->{DEFAULT_TEST_OPTIONS}
232 sub _prepare_mk_files($)
237 foreach (@smb_build::config_mk::parsed_files) {
242 if ($self->{gnu_make}) {
244 ifneq (\$(MAKECMDGOALS),clean)
245 ifneq (\$(MAKECMDGOALS),distclean)
246 ifneq (\$(MAKECMDGOALS),realdistclean)
250 $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
252 if ($self->{gnu_make}) {
261 sub array2oneperline($)
267 next unless defined($_);
269 $output .= " \\\n\t\t$_";
275 sub _prepare_list_ex($$$$$)
277 my ($self,$ctx,$var,$pre,$post) = @_;
280 push(@tmparr, $pre) if defined($pre);
281 push(@tmparr, @{$ctx->{$var}}) if defined($ctx->{$var});
282 push(@tmparr, $post) if defined($post);
284 my $tmplist = array2oneperline(\@tmparr);
285 return if ($tmplist eq "");
287 $self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
290 sub _prepare_list($$$)
292 my ($self,$ctx,$var) = @_;
294 $self->_prepare_list_ex($ctx, $var, undef, undef);
299 my ($self,$ctx) = @_;
301 $self->_prepare_list($ctx, "OBJ_LIST");
302 $self->_prepare_list($ctx, "FULL_OBJ_LIST");
303 $self->_prepare_list($ctx, "LINK_FLAGS");
308 my ($self,$ctx) = @_;
312 my $sane_subsystem = lc($ctx->{SUBSYSTEM});
313 $sane_subsystem =~ s/^lib//;
315 if ($ctx->{TYPE} eq "PYTHON") {
316 push (@{$self->{python_dsos}},
317 "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
319 push (@{$self->{shared_modules}}, "$ctx->{TARGET_SHARED_LIBRARY}");
320 push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
321 $self->{install_plugins} .= "\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
322 $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/\n";
323 $self->{install_plugins} .= "\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
324 $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
325 $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
326 if (defined($ctx->{ALIASES})) {
327 foreach (@{$ctx->{ALIASES}}) {
328 $self->{install_plugins} .= "\t\@rm -f \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
329 $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
330 $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
335 $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
336 $self->_prepare_list($ctx, "OBJ_LIST");
337 $self->_prepare_list($ctx, "FULL_OBJ_LIST");
338 $self->_prepare_list($ctx, "DEPEND_LIST");
339 $self->_prepare_list($ctx, "LINK_FLAGS");
341 push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
343 if (defined($ctx->{INIT_FUNCTION})) {
344 my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
345 $init_fn =~ s/\(\*\)/init_module/;
346 my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
347 $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
349 $self->output(<< "__EOD__"
350 bin/$ctx->{NAME}_init_module.c:
352 \@echo \"#include \\\"includes.h\\\"\" > \$\@
353 \@echo \"$proto_fn;\" >> \$\@
354 \@echo \"_PUBLIC_ $init_fn\" >> \$\@
356 \@echo \" return $ctx->{INIT_FUNCTION}();\" >> \$\@
361 $init_obj = "bin/$ctx->{NAME}_init_module.o";
364 $self->output(<< "__EOD__"
367 $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
369 \@mkdir -p $ctx->{SHAREDDIR}
370 \@\$(MDLD) \$(MDLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
371 \$($ctx->{TYPE}_$ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
372 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
376 if (defined($ctx->{ALIASES})) {
377 foreach (@{$ctx->{ALIASES}}) {
378 $self->output("\t\@rm -f $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
379 $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
385 sub SharedLibrary($$)
387 my ($self,$ctx) = @_;
389 my $has_static_lib = 0;
391 push (@{$self->{shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
392 push (@{$self->{installable_shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
394 $has_static_lib = 1 if grep(/STATIC_LIBRARY/, @{$ctx->{OUTPUT_TYPE}});
396 if (not $has_static_lib) {
397 $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
398 $self->_prepare_list($ctx, "OBJ_LIST");
399 $self->_prepare_list($ctx, "FULL_OBJ_LIST");
401 $self->_prepare_list($ctx, "DEPEND_LIST");
402 $self->_prepare_list($ctx, "LINK_FLAGS");
403 # $self->_prepare_list_ex($ctx, "LINK_FLAGS", "-Wl,--whole-archive", "-Wl,--no-whole-archive");
405 push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
409 if ($self->{config}->{SONAMEFLAG} ne "#" and defined($ctx->{LIBRARY_SONAME})) {
410 $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME}";
411 if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
412 $lns .= "\n\t\@rm -f $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
413 $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
417 if (defined($ctx->{LIBRARY_SONAME})) {
418 $lns .= "\n\t\@rm -f $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
419 $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
422 $self->output(<< "__EOD__"
425 $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
427 \@mkdir -p $ctx->{SHAREDDIR}
428 \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
429 \$($ctx->{TYPE}_$ctx->{NAME}\_FULL_OBJ_LIST) \\
430 \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) \\
437 sub StaticLibrary($$)
439 my ($self,$ctx) = @_;
441 return unless (defined($ctx->{OBJ_FILES}));
443 push (@{$self->{static_libs}}, $ctx->{TARGET_STATIC_LIBRARY}) if ($ctx->{TYPE} eq "LIBRARY");
445 $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
446 $self->_prepare_list($ctx, "OBJ_LIST");
447 $self->_prepare_list($ctx, "FULL_OBJ_LIST");
449 push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
451 $self->output(<< "__EOD__"
453 $ctx->{TARGET_STATIC_LIBRARY}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
456 \@mkdir -p $ctx->{STATICDIR}
457 \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
465 my ($self,$ctx) = @_;
467 foreach (@{$ctx->{PUBLIC_HEADERS}}) {
468 push (@{$self->{headers}}, output::add_dir_str($ctx->{BASEDIR}, $_));
474 my ($self,$ctx) = @_;
479 if (defined($ctx->{INSTALLDIR}) && $ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
480 $extradir = "/torture" . substr($ctx->{INSTALLDIR}, length("TORTUREDIR"));
482 my $localdir = "bin$extradir";
484 $installdir = "bin$extradir";
486 push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
488 unless (defined($ctx->{INSTALLDIR})) {
489 } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
490 push (@{$self->{sbin_progs}}, "$installdir/$ctx->{BINARY}");
491 } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
492 push (@{$self->{bin_progs}}, "$installdir/$ctx->{BINARY}");
493 } elsif ($ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
494 push (@{$self->{torture_progs}}, "$installdir/$ctx->{BINARY}");
498 push (@{$self->{binaries}}, "$localdir/$ctx->{BINARY}");
500 $self->_prepare_list($ctx, "OBJ_LIST");
501 $self->_prepare_list($ctx, "FULL_OBJ_LIST");
502 $self->_prepare_list($ctx, "DEPEND_LIST");
503 $self->_prepare_list($ctx, "LINK_FLAGS");
505 $self->output(<< "__EOD__"
506 $installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
511 if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
512 $self->output(<< "__EOD__"
513 \@\$(HOSTLD) \$(HOSTLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
514 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
518 $self->output(<< "__EOD__"
519 \@\$(BNLD) \$(BNLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
520 \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
529 my ($self,$ctx) = @_;
531 foreach (@{$ctx->{PYTHON_FILES}}) {
532 my $target = "bin/python/".basename($_);
533 my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
534 $self->output("$target: $source\n" .
535 "\tcp $source \$@\n\n");
536 push (@{$self->{python_dsos}}, $target);
542 my ($self,$ctx) = @_;
544 my $path = output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE});
545 push (@{$self->{manpages}}, $path);
550 my ($self,$ctx,$other) = @_;
552 my $link_name = $ctx->{NAME};
554 $link_name =~ s/^LIB//g;
555 $link_name = lc($link_name);
557 return if (not defined($ctx->{DESCRIPTION}));
559 my $path = output::add_dir_str($ctx->{BASEDIR}, "$link_name.pc");
561 push (@{$self->{pc_files}}, $path);
567 if (defined($ctx->{PUBLIC_DEPENDENCIES})) {
568 foreach (@{$ctx->{PUBLIC_DEPENDENCIES}}) {
569 next if ($other->{$_}->{ENABLE} eq "NO");
570 if ($other->{$_}->{TYPE} eq "LIBRARY") {
579 $privlibs .= "-l$_ ";
584 if (defined($ctx->{PRIVATE_DEPENDENCIES})) {
585 foreach (@{$ctx->{PRIVATE_DEPENDENCIES}}) {
586 next if ($other->{$_}->{ENABLE} eq "NO");
587 if ($other->{$_}->{TYPE} eq "LIBRARY") {
596 $privlibs .= "-l$_ ";
601 smb_build::env::PkgConfig($self,
604 "-L\${libdir} -l$link_name",
609 defined($ctx->{INIT_FUNCTIONS}),
613 "prefix=$self->{config}->{prefix}",
614 "exec_prefix=$self->{config}->{exec_prefix}",
615 "libdir=$self->{config}->{libdir}",
616 "includedir=$self->{config}->{includedir}"
619 my $abs_srcdir = abs_path($self->{config}->{srcdir});
620 smb_build::env::PkgConfig($self,
621 "bin/pkgconfig/$link_name-uninstalled.pc",
623 "-Lbin/shared -Lbin/static -l$link_name",
627 "-I$abs_srcdir/include",
629 "-I$abs_srcdir/lib/replace"),
632 defined($ctx->{INIT_FUNCTIONS}),
637 "includedir=$ctx->{BASEDIR}"
644 my ($self,$ctx) = @_;
647 my $comment = "Creating ";
652 if (defined($ctx->{PRIVATE_PROTO_HEADER})) {
653 $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
656 if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
660 push (@{$self->{proto_headers}}, $priv);
662 $ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER};
663 $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
666 if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
667 $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
670 push (@{$self->{proto_headers}}, $pub);
672 $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
673 $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
676 $self->output("$pub: $ctx->{MK_FILE} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
677 $self->output("\t\@echo \"$comment\"\n");
678 $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$priv --public=$pub \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
683 my ($self,$file) = @_;
685 $self->output("MANPAGES = ".array2oneperline($self->{manpages})."\n");
686 $self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
687 $self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
688 $self->output("TORTURE_PROGS = " . array2oneperline($self->{torture_progs}) . "\n");
689 $self->output("BINARIES = " . array2oneperline($self->{binaries}) . "\n");
690 $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
691 $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
692 $self->output("PYTHON_DSOS = " . array2oneperline($self->{python_dsos}) . "\n");
693 $self->output("INSTALLABLE_SHARED_LIBS = " . array2oneperline($self->{installable_shared_libs}) . "\n");
694 $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
695 $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
696 $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
697 $self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) . "\n");
698 $self->output("SHARED_MODULES = " . array2oneperline($self->{shared_modules}) . "\n");
699 $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
701 $self->output("\ninstallplugins: \$(PLUGINS)\n".$self->{install_plugins}."\n");
702 $self->output("\nuninstallplugins:\n".$self->{uninstall_plugins}."\n");
704 $self->_prepare_mk_files();
706 $self->output($self->{mkfile});
708 if ($self->{automatic_deps}) {
710 ifneq (\$(MAKECMDGOALS),clean)
711 ifneq (\$(MAKECMDGOALS),distclean)
712 ifneq (\$(MAKECMDGOALS),realdistclean)
713 ifneq (\$(SKIP_DEP_FILES),yes)
714 -include \$(DEP_FILES)
720 ifneq (\$(SKIP_DEP_FILES),yes)
722 \@echo Removing dependency files
723 \@find . -name '*.d' -o -name '*.hd' | xargs rm -f
727 $self->output("include \$(srcdir)/static_deps.mk\n");
730 open(MAKEFILE,">$file") || die ("Can't open $file\n");
731 print MAKEFILE $self->{output};
734 print __FILE__.": creating $file\n";