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