1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | # use strict 'subs' ; |
---|
4 | # use strict 'vars' ; |
---|
5 | # use strict 'refs' ; |
---|
6 | |
---|
7 | # use strict ; |
---|
8 | |
---|
9 | # |
---|
10 | # Perl script to beautify and enhance RTEMS autoconf Makefile.ins |
---|
11 | # |
---|
12 | # Reads from stdin and writes to stdout |
---|
13 | # |
---|
14 | # usage: |
---|
15 | # acpolish <Makefile.in >Makefile.in~ |
---|
16 | # mv Makefile.in~ Makefile.in |
---|
17 | # |
---|
18 | # Note: This tool is not indented to be exported from the source-tree |
---|
19 | # |
---|
20 | |
---|
21 | if ( -f "Makefile.am" ) |
---|
22 | { |
---|
23 | # Refuse to work on Makefile.ins generated from automake; |
---|
24 | # redirecting STDOUT to Makefile.in will trash the Makefile.in ;- |
---|
25 | |
---|
26 | die "acpolish must not be run in automake directories" ; |
---|
27 | } |
---|
28 | |
---|
29 | my $experimental = 0 ; # enable experimental/unsafe features |
---|
30 | my $verbose = 0 ; |
---|
31 | my $build_pgms_seen = "" ; |
---|
32 | my $make_exe_seen = 0 ; |
---|
33 | my $install_seen = 0 ; |
---|
34 | my $top_builddir = ""; |
---|
35 | my $subdir = ""; |
---|
36 | my @installdirs = () ; |
---|
37 | |
---|
38 | my @pieces = () ; |
---|
39 | my @files = () ; |
---|
40 | my @variants = () ; |
---|
41 | my @vars = () ; |
---|
42 | |
---|
43 | sub print_macro($$) |
---|
44 | { |
---|
45 | my $line = $_[0] ; |
---|
46 | my $input = $_[1] ; |
---|
47 | $input =~ s/\\\\/ /g; |
---|
48 | my @l = split(' ',$input); |
---|
49 | |
---|
50 | foreach (@l) { |
---|
51 | if ( ( length($line) + length($_) ) < 76 ) |
---|
52 | { |
---|
53 | $line .= " $_"; |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | print "$line \\\n"; |
---|
58 | $line = " $_" ; |
---|
59 | } |
---|
60 | } |
---|
61 | print "$line\n" ; |
---|
62 | } |
---|
63 | |
---|
64 | # Strip off duplicate entries from a list |
---|
65 | sub purge($) |
---|
66 | { |
---|
67 | my $list = $_[0] ; # Reference to list ! |
---|
68 | my (@tmp) = () ; |
---|
69 | |
---|
70 | foreach my $l ( @{$list} ) |
---|
71 | { |
---|
72 | my $i = 1 ; |
---|
73 | foreach my $t (@tmp) |
---|
74 | { |
---|
75 | if ( $t eq $l ) |
---|
76 | { |
---|
77 | $i = 0 ; |
---|
78 | last ; |
---|
79 | } |
---|
80 | } |
---|
81 | push @tmp,$l if ($i) ; |
---|
82 | } |
---|
83 | |
---|
84 | @{$list} = @tmp ; |
---|
85 | } |
---|
86 | |
---|
87 | sub find_root |
---|
88 | { |
---|
89 | $top_builddir = "." ; |
---|
90 | $subdir=""; |
---|
91 | my $pwd = `pwd`; chomp $pwd; |
---|
92 | $pwd .= "/" ; |
---|
93 | my $len ; |
---|
94 | |
---|
95 | if ( -f "configure.in" ) { return $top_builddir ; } |
---|
96 | my $i = rindex($pwd,'/'); |
---|
97 | |
---|
98 | $len = $i; |
---|
99 | $pwd = substr($pwd,0,$len); |
---|
100 | $i = rindex($pwd,'/'); |
---|
101 | $subdir = substr($pwd,$i+1,$len - 1); |
---|
102 | $top_builddir = ".." ; |
---|
103 | |
---|
104 | while( -d "$top_builddir" ) |
---|
105 | { |
---|
106 | if ( -f "${top_builddir}/configure.in" ) |
---|
107 | { |
---|
108 | return $top_builddir ; |
---|
109 | } |
---|
110 | $len=$i; |
---|
111 | $pwd = substr($pwd,0,$len); |
---|
112 | $i = rindex($pwd,'/'); |
---|
113 | $subdir = substr($pwd,$i+1,$len - 1) . "/$subdir"; |
---|
114 | $top_builddir .= "/.." ; |
---|
115 | } ; |
---|
116 | die "Can't find configure.in\n" ; |
---|
117 | } |
---|
118 | |
---|
119 | find_root(); |
---|
120 | |
---|
121 | my @buffer = () ; |
---|
122 | |
---|
123 | sub subst_line |
---|
124 | { |
---|
125 | # substitute obsolete variables |
---|
126 | if ( /^([^\s]*)[\s]+$/o ) |
---|
127 | { # strip trailing spaces |
---|
128 | $_ = "$1\n"; |
---|
129 | } |
---|
130 | if ( /^(.*)MKLIB(.*)$/o ) |
---|
131 | { |
---|
132 | s/MKLIB/RANLIB/g ; |
---|
133 | } |
---|
134 | if ( /^(.*)\$\(INSTINCFLAGS\)(.*)$/o ) |
---|
135 | { |
---|
136 | s/\$\(INSTINCFLAGS\)/-m 644/g ; |
---|
137 | } |
---|
138 | if ( /^(.*)ASM(_FILES|_PIECES|_O_FILES)(.*)$/o ) |
---|
139 | { |
---|
140 | s/ASM_FILES/S_FILES/g ; |
---|
141 | s/ASM_PIECES/S_PIECES/g ; |
---|
142 | s/ASM_O_FILES/S_O_FILES/g ; |
---|
143 | print STDERR "ASM: $_" if ( $verbose > 0) ; |
---|
144 | } |
---|
145 | if ( /^(.*)MP_PIECES(.*)$/o ) |
---|
146 | { # HACK: this is not always correct |
---|
147 | s/MP_PIECES/MP_C_PIECES/g ; |
---|
148 | print STDERR "MP_PIECES: $_" if ( $verbose > 0 ); |
---|
149 | } |
---|
150 | if ( /^(.*)\$\(RTEMS_BSP\)(.*)$/o ) |
---|
151 | { |
---|
152 | s/\$\(RTEMS_BSP\)/\@RTEMS_BSP\@/g ; |
---|
153 | } |
---|
154 | if ( /^(.*)\$\(RTEMS_ROOT\)\/mkinstalldirs(.*)$/o ) |
---|
155 | { |
---|
156 | $_ = "$1\$\(mkinstalldirs\)$2\n" ; |
---|
157 | } |
---|
158 | if ( /^(.*)\$\{(.*)_FILES\}(.*)$/o ) |
---|
159 | { |
---|
160 | $_ = "$1\$\($2_FILES\)$3\n" ; |
---|
161 | } |
---|
162 | if ( /^(.*)\$\{(.*)_PIECES\}(.*)$/o ) |
---|
163 | { |
---|
164 | $_ = "$1\$\($2_PIECES\)$3\n" ; |
---|
165 | } |
---|
166 | if ( /^(.*)\$\(PROJECT_ROOT\)\/\@RTEMS_BSP\@\/lib\/include(.*)$/o ) |
---|
167 | { |
---|
168 | $_ = "$1\$\(PROJECT_INCLUDE\)$2\n" ; |
---|
169 | } |
---|
170 | if ( /^(.*)\$\{PROJECT_RELEASE\}(.*)$/o ) |
---|
171 | { |
---|
172 | $_ = "$1\$\(PROJECT_RELEASE\)$2\n" ; |
---|
173 | } |
---|
174 | if ( /^(.*\$\(INSTALL_[A-Z]+\))[\s]+-m[\s]+([54])([0-9][0-9].*)$/o ) |
---|
175 | { |
---|
176 | my $v = $2 + 2 ; |
---|
177 | $_ = "$1 -m $v$3\n" ; |
---|
178 | } |
---|
179 | if ( /^H_FILES[\s]*=[\s]*\$\(wildcard[\s]+\$\(srcdir\)\/\*\.h\)[\s]*$/o ) |
---|
180 | { |
---|
181 | my $files =`ls *.h 2>/dev/null`; |
---|
182 | print STDERR "WARNING: Replacing \"\(wildcard... in $_\n" ; |
---|
183 | $line = "H_FILES ="; |
---|
184 | @l = split(' ',$files) ; |
---|
185 | foreach(@l) { $line .= " \$\(srcdir\)/$_"; } |
---|
186 | $line .= "\n" ; |
---|
187 | $_ = "$line" ; |
---|
188 | } |
---|
189 | if ( /^.*\$\(make\-exe\).*$/o ) |
---|
190 | { |
---|
191 | $make_exe_seen = 1 ; |
---|
192 | } |
---|
193 | if ( /^.*\$\(INSTALL_(DATA|SCRIPT|PROGRAM)\)(.*)$/o ) |
---|
194 | { |
---|
195 | $install_seen = 1 ; |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | { |
---|
200 | # 1st PASS: |
---|
201 | # * Read input file |
---|
202 | # * concatenate multiple lines |
---|
203 | # * Remove obsolete variables |
---|
204 | |
---|
205 | my @ibuf = () ; |
---|
206 | my $line = "" ; |
---|
207 | |
---|
208 | while ( <> ) |
---|
209 | { |
---|
210 | &subst_line ; |
---|
211 | if ( /^(#.*)$/o ) |
---|
212 | { # preserve comments |
---|
213 | $line = "$_" ; |
---|
214 | push @ibuf, $line ; |
---|
215 | $line = "" ; |
---|
216 | } |
---|
217 | elsif ( /^.*\\$/o ) |
---|
218 | { # multilines |
---|
219 | chop ; |
---|
220 | $line .= "$_\\" ; |
---|
221 | } |
---|
222 | else |
---|
223 | { |
---|
224 | $line .= "$_" ; |
---|
225 | push @ibuf, $line ; |
---|
226 | $line = "" ; |
---|
227 | } |
---|
228 | } |
---|
229 | @buffer = @ibuf; |
---|
230 | } |
---|
231 | |
---|
232 | { |
---|
233 | # 2nd PASS: |
---|
234 | # * remove automatically generated lines |
---|
235 | # * process some selected make rules |
---|
236 | my $line = "" ; |
---|
237 | my @tbuf = () ; |
---|
238 | foreach (@buffer) |
---|
239 | { |
---|
240 | if ( /^[\t](.*)$/o ) |
---|
241 | { # make rule production |
---|
242 | my $line = $1 ; |
---|
243 | tr/\\/ / ; |
---|
244 | my @l = split(/;/,$_); |
---|
245 | foreach (@l) |
---|
246 | { # try to get installation directories |
---|
247 | if ( /^.*\$\(mkinstalldirs\).*\s\$\(INSTALLDIRS\)$/o ) |
---|
248 | { |
---|
249 | } |
---|
250 | elsif ( /^.*\$\(mkinstalldirs\).*\s([^\s]+)$/o ) |
---|
251 | { |
---|
252 | push @installdirs, "$1" ; |
---|
253 | } |
---|
254 | elsif ( /^.*\$\(INSTALL_CHANGE\).*\s([^\s]+)$/o ) |
---|
255 | { |
---|
256 | push @installdirs, "$1" ; |
---|
257 | } |
---|
258 | } |
---|
259 | push @tbuf, "§3$line" |
---|
260 | } |
---|
261 | elsif ( /^[\s]*\#.*$/o ) |
---|
262 | { # comment |
---|
263 | push @tbuf, "$_" ; |
---|
264 | } |
---|
265 | elsif ( /^[\s]*([A-Z_]*)_FILES[\s]*\=[\s]*(.*)$/o ) |
---|
266 | { # *_FILES = ... Macros |
---|
267 | if ( /^[\s]*([A-Z_]*_|)(CC|C|EQ|H|I|O|S|X)_FILES[\s]*\=[\s]*(.*)$/o ) |
---|
268 | { |
---|
269 | # print STDERR "FILES: <$1>--<$2>--<$3>\n" ; |
---|
270 | my $f = "$1$2_FILES" ; |
---|
271 | ${"var_$f"}="$3" ; |
---|
272 | if ( ( $experimental > 0 ) |
---|
273 | and ( ( "$2" eq "C" ) or ( "$2" eq "CC" ) or ( "$2" eq "S" ) |
---|
274 | or ( "$2" eq "I" ) or ( "$2" eq "H" ) ) ) |
---|
275 | { |
---|
276 | my $p = "$1$2_PIECES" ; |
---|
277 | if ( not defined ${"var_$p"} ) |
---|
278 | { |
---|
279 | print STDERR "ADDING $p\n" ; |
---|
280 | ${"var_$p"} = "" ; |
---|
281 | push @tbuf, "§4$p\n" ; |
---|
282 | push @pieces, "$p" ; |
---|
283 | } |
---|
284 | } |
---|
285 | # place a marker |
---|
286 | push @tbuf, "§4$f\n" ; |
---|
287 | push @files, "$f" ; |
---|
288 | } |
---|
289 | else |
---|
290 | { # found a bug |
---|
291 | print STDERR "UNKNOWN _FILES: $_\n" ; |
---|
292 | my $f = "$1_FILES" ; |
---|
293 | ${"var_$f"}="$2" ; |
---|
294 | # place a marker |
---|
295 | push @tbuf, "§4$f\n" ; |
---|
296 | push @files, "$f" ; |
---|
297 | } |
---|
298 | } |
---|
299 | elsif ( /^[\s]*([A-Z_]*)_PIECES[\s]*\=[\s]*(.*)$/o ) |
---|
300 | { # *_PIECES = ... Macros |
---|
301 | if ( /^[\s]*([A-Z][A-Z0-9_]*_|)(CC|C|EQ|H|I|O|S|X|REL)_PIECES[\s]*\=[\s]*(.*)$/o ) |
---|
302 | { |
---|
303 | my $p = "$1$2_PIECES" ; |
---|
304 | |
---|
305 | if ( not defined ${"var_$p"} ) |
---|
306 | { |
---|
307 | ${"var_$p"} = "$3" ; |
---|
308 | push @tbuf, "§4$p\n" ; |
---|
309 | push @pieces, "$p" ; |
---|
310 | } |
---|
311 | else |
---|
312 | { |
---|
313 | ${"var_$p"} .= " $3" ; |
---|
314 | } |
---|
315 | } |
---|
316 | elsif ( /^[\s]*(BSP|CPU|GENERIC)_PIECES[\s]*\=[\s]*(.*)$/o ) |
---|
317 | { # Explicit exceptions from the *_PIECES naming conventions |
---|
318 | # They should better be replaced in future |
---|
319 | my $p = "$1_PIECES" ; |
---|
320 | ${"var_$p"}="$2" ; |
---|
321 | # place a marker |
---|
322 | push @tbuf, "§4$p\n" ; |
---|
323 | push @pieces, "$p" ; |
---|
324 | } |
---|
325 | else |
---|
326 | { # found a bug |
---|
327 | print STDERR "UNKNOWN _PIECES: $_\n" ; |
---|
328 | my $p = "$1_PIECES" ; |
---|
329 | ${"var_$p"}="$2" ; |
---|
330 | # place a marker |
---|
331 | push @tbuf, "§4$p\n" ; |
---|
332 | push @pieces, "$p" ; |
---|
333 | } |
---|
334 | } |
---|
335 | elsif ( /^[\s]*([A-Z_]+)_PIECES_([^\s]+)_V[\s]*\=[\s]*(.*)$/o ) |
---|
336 | { # *_PIECES_.._V = ... Macros |
---|
337 | if ( /^[\s]*([A-Z][A-Z0-9_]*_|)(CC|C|EQ|H|I|O|S|X|REL)_PIECES_([^\s]+)_V[\s]*\=[\s]*(.*)$/o ) |
---|
338 | { |
---|
339 | my @l = split(/_/,$3); |
---|
340 | my $v = "$1$2-$#l" ; |
---|
341 | if ( not defined @{"variants_$v"} ) { push @variants, "$v" ; } |
---|
342 | |
---|
343 | my $p = "$1$2_PIECES_$3_V" ; |
---|
344 | push @{"variants_${v}"}, "$p" ; |
---|
345 | |
---|
346 | ${"var_$p"}="$4" ; |
---|
347 | # place a marker |
---|
348 | push @tbuf, "§4$p\n" ; |
---|
349 | push @pieces, "$p" ; |
---|
350 | } |
---|
351 | else |
---|
352 | { # found a bug |
---|
353 | print STDERR "UNKNOWN _PIECES: $_\n" ; |
---|
354 | my $p = "$1_PIECES" ; |
---|
355 | ${"var_$p"}="$2" ; |
---|
356 | # place a marker |
---|
357 | push @tbuf, "§4$p\n" ; |
---|
358 | push @pieces, "$p" ; |
---|
359 | } |
---|
360 | } |
---|
361 | elsif ( /^[\s]*([^\s+=]+)[\s]*\=[\s]*(.*)$/o ) |
---|
362 | { # makefile variable |
---|
363 | if ( ( "$1" eq "subdir" ) |
---|
364 | or ( "$1" eq "top_srcdir" ) |
---|
365 | or ( "$1" eq "top_builddir" ) |
---|
366 | or ( "$1" eq "RTEMS_ROOT" ) |
---|
367 | or ( "$1" eq "PROJECT_ROOT" ) |
---|
368 | or ( "$1" eq "INSTALL" ) |
---|
369 | or ( "$1" eq "PACKHEX" ) |
---|
370 | or ( "$1" eq "INSTALL_CHANGE" ) |
---|
371 | or ( "$1" eq "mkinstalldirs" ) |
---|
372 | ) |
---|
373 | { |
---|
374 | print STDERR "REMOVE: $1\n" if $verbose ; |
---|
375 | } |
---|
376 | elsif ( "$1" eq "srcdir" ) |
---|
377 | { # place marker |
---|
378 | push @tbuf, "§0\n"; |
---|
379 | } |
---|
380 | elsif ( "$1" eq "INSTALLDIRS" ) |
---|
381 | { # process the block |
---|
382 | my $input = $2 ; |
---|
383 | $input =~ s/\\\\/ /g ; |
---|
384 | my @l = split(' ',$input); |
---|
385 | foreach (@l) |
---|
386 | { |
---|
387 | if ( /[\s]*([^\s]+)[\s]*$/o ) |
---|
388 | { |
---|
389 | push @installdirs, "$1" ; |
---|
390 | } |
---|
391 | } |
---|
392 | } |
---|
393 | else |
---|
394 | { |
---|
395 | # print STDERR "MACRO: <$1> = <$2>\n"; |
---|
396 | my $p = "$1" ; |
---|
397 | ${"var_$p"}="$2" ; |
---|
398 | # place a marker |
---|
399 | push @tbuf, "§4$p\n" ; |
---|
400 | push @vars, "$p" ; |
---|
401 | } |
---|
402 | } |
---|
403 | elsif ( /^[\s]*([^\s+=]+)[\s]*\+\=[\s]*(.*)$/o ) |
---|
404 | { # makefile variable addition |
---|
405 | # print STDERR "MACRO: <$1> += <$2>\n"; |
---|
406 | my $p = "$1" ; |
---|
407 | ${"var_$p+"}="$2" ; |
---|
408 | # place a marker |
---|
409 | push @tbuf, "§5$p\n" ; |
---|
410 | push @vars, "$p+" ; |
---|
411 | } |
---|
412 | elsif ( /^[\s]*(\@[^\s]+\@)$/o ) |
---|
413 | { # autoconf variable |
---|
414 | if ( "$1" eq "\@SET_MAKE\@" ) |
---|
415 | { |
---|
416 | } |
---|
417 | else |
---|
418 | { |
---|
419 | push @tbuf, "$1\n" ; |
---|
420 | } |
---|
421 | } |
---|
422 | elsif ( /^[\s]*include[\s]+(.*)$/o ) |
---|
423 | { # include line |
---|
424 | push @tbuf, "$_" ; |
---|
425 | if ( /^include[\s\t]*.*(directory|leaf|lib)\.cfg.*$/o ) |
---|
426 | { |
---|
427 | push @tbuf, "§1\n" ; |
---|
428 | push @tbuf, "PACKHEX = \@PACKHEX\@\n" if ( $make_exe_seen == 1 ) ; |
---|
429 | push @tbuf, "§2\n" ; |
---|
430 | } |
---|
431 | } |
---|
432 | elsif ( /^[\s]*(ifeq|ifneq|else|endif)[\s]+(.*)$/o ) |
---|
433 | { # gmake conditionals |
---|
434 | # Most of them are removed, but we still have some :- |
---|
435 | push @tbuf, "$1 $2\n" ; |
---|
436 | } |
---|
437 | elsif ( /^[\s]*([^:]+)[\s]*(:[:]*)[\s]*(.*)$/o ) |
---|
438 | { |
---|
439 | if ( "$2" eq "::" ) |
---|
440 | { |
---|
441 | # Warn about "::"-rules |
---|
442 | # Will be silently removed below. |
---|
443 | print STDERR "WARNING: Removing \"::\" in RULE $_\n" ; |
---|
444 | } |
---|
445 | |
---|
446 | if ( ( "$1" eq "Makefile" ) |
---|
447 | or ( "$1" eq "\$\(INSTALLDIRS\)" ) ) |
---|
448 | { # delete entry |
---|
449 | shift @buffer ; |
---|
450 | } |
---|
451 | elsif ( ( "$1" eq "all" ) |
---|
452 | or ( "$1" eq "preinstall" ) ) |
---|
453 | { |
---|
454 | # Note the dependencies |
---|
455 | # Not yet exploited, but could be useful for dependency |
---|
456 | # tracking in future |
---|
457 | if ( defined ${"var_$1"} ) |
---|
458 | { ${"var_$1"} .= " $3" ; } |
---|
459 | else |
---|
460 | { ${"var_$1"} = "$3" ; } |
---|
461 | push @tbuf, "$1: $3\n" ; |
---|
462 | } |
---|
463 | else |
---|
464 | { # make rule |
---|
465 | push @tbuf, "$1: $3\n" ; |
---|
466 | } |
---|
467 | } |
---|
468 | elsif ( /^[\s]*$/o ) |
---|
469 | { # empty line |
---|
470 | push @tbuf, "\n" ; |
---|
471 | } |
---|
472 | else |
---|
473 | { |
---|
474 | die "PASS 2: Unhandled $_" ; |
---|
475 | } |
---|
476 | } |
---|
477 | @buffer = @tbuf ; |
---|
478 | purge \@installdirs ; |
---|
479 | purge \@pieces ; |
---|
480 | } |
---|
481 | |
---|
482 | # A fragment to debug conditionals |
---|
483 | #foreach( @variants ) |
---|
484 | #{ |
---|
485 | # my $v = $_ ; |
---|
486 | # print STDERR "VARIANT: $v\n"; |
---|
487 | # foreach (@{"variants_${v}"}) |
---|
488 | # { |
---|
489 | # print STDERR "* $_\n;" ; |
---|
490 | # } |
---|
491 | #} |
---|
492 | |
---|
493 | # sanity check on *_FILES macros |
---|
494 | # too fragile for the time being, |
---|
495 | # therefore disabled by default |
---|
496 | if ( $experimental > 1 ) |
---|
497 | { |
---|
498 | foreach( @files ) |
---|
499 | { |
---|
500 | my $file = "$_" ; |
---|
501 | my $line = ${"var_$_"} ; |
---|
502 | $line =~ tr /\\/ /; |
---|
503 | my @l = split(' ',$line); |
---|
504 | my @o = () ; |
---|
505 | foreach (@l) |
---|
506 | { |
---|
507 | if ( /^([^\.]+)\.([a-z]+)$/o ) |
---|
508 | { |
---|
509 | print STDERR "$file: *.$2 in $_\n" ; |
---|
510 | } |
---|
511 | elsif ( /^\$\(.*\)$/o ) |
---|
512 | { |
---|
513 | print STDERR "$file: REF: $_\n" ; |
---|
514 | } |
---|
515 | else |
---|
516 | { |
---|
517 | print STDERR "$file: UNHANDLED: $_\n" ; |
---|
518 | } |
---|
519 | } |
---|
520 | } |
---|
521 | } |
---|
522 | |
---|
523 | # print STDERR "PASS 2: @buffer" ; |
---|
524 | |
---|
525 | { |
---|
526 | # PASS 3: |
---|
527 | # * output to new Makefile |
---|
528 | # * prettyprint newlines |
---|
529 | |
---|
530 | my $nl_seen = 0 ; |
---|
531 | foreach ( @buffer ) |
---|
532 | { |
---|
533 | if ( /^$/o ) |
---|
534 | { |
---|
535 | $nl_seen++ ; |
---|
536 | print "\n" if ( $nl_seen < 2 ); |
---|
537 | } |
---|
538 | elsif ( /^\§0$/o ) |
---|
539 | { |
---|
540 | print "\@SET_MAKE\@\n" ; |
---|
541 | print "srcdir = \@srcdir\@\n" ; |
---|
542 | print "top_srcdir = \@top_srcdir\@\n" ; |
---|
543 | print "top_builddir = $top_builddir\n" ; |
---|
544 | print "subdir = $subdir\n" if "$subdir" ; |
---|
545 | print "\nRTEMS_ROOT = \@RTEMS_ROOT\@\n" ; |
---|
546 | print "PROJECT_ROOT = \@PROJECT_ROOT\@\n\n" ; |
---|
547 | $nl_seen = 1 ; |
---|
548 | } |
---|
549 | elsif ( /^\§1$/o ) |
---|
550 | { |
---|
551 | print "\n" ; |
---|
552 | print "INSTALL = \@INSTALL\@\n" if ( $install_seen > 0 ); |
---|
553 | print "INSTALL_CHANGE = \@INSTALL_CHANGE\@\n" ; |
---|
554 | $nl_seen = 0 ; |
---|
555 | } |
---|
556 | elsif ( /^\§2$/o ) |
---|
557 | { # Handle installdirs related items |
---|
558 | if ( $#installdirs >= 0 ) |
---|
559 | { |
---|
560 | print "mkinstalldirs = \$(SHELL) \$(top_srcdir)/\@RTEMS_TOPdir\@/mkinstalldirs\n\n" ; |
---|
561 | my $line = join( ' ',@installdirs ); |
---|
562 | print_macro "INSTALLDIRS =", $line ; |
---|
563 | print "\n\$(INSTALLDIRS):\n\t\@\$(mkinstalldirs) \$(INSTALLDIRS)\n\n" ; |
---|
564 | $nl_seen = 1 ; |
---|
565 | } |
---|
566 | } |
---|
567 | elsif ( /^\§3(.*)$/o ) |
---|
568 | { # pretty print a shell script fragment/make production |
---|
569 | my @l = split(/\\\\/,$1); |
---|
570 | if ( $#l >= 0 ) { my $i = shift @l ; print "\t$i"; } |
---|
571 | foreach( @l ) { print "\\\n$_"; } |
---|
572 | print "\n" ; |
---|
573 | $nl_seen = 0 ; |
---|
574 | } |
---|
575 | elsif ( /^\§4(.*)$/o ) |
---|
576 | { # pretty print a make variable |
---|
577 | print_macro "$1 =", ${"var_$1"} ; |
---|
578 | $nl_seen = 0 ; |
---|
579 | } |
---|
580 | elsif ( /^\§5(.*)$/o ) |
---|
581 | { # pretty print an addition to a make variable |
---|
582 | print_macro "$1 +=", ${"var_$1+"} ; |
---|
583 | $nl_seen = 0 ; |
---|
584 | } |
---|
585 | else |
---|
586 | { |
---|
587 | $nl_seen = 0 ; |
---|
588 | print "$_" ; |
---|
589 | } |
---|
590 | } |
---|
591 | } |
---|
592 | |
---|
593 | # Add rules for config.status generated files |
---|
594 | if ( "$build_pgms_seen" ) |
---|
595 | { |
---|
596 | print "%: \$(srcdir)/%.in \$(top_builddir)/config.status\n" ; |
---|
597 | print " cd \$(top_builddir) \\\n" ; |
---|
598 | print " && CONFIG_FILES=" ; |
---|
599 | print "\$(subdir)/" if ( "$subdir" ); |
---|
600 | print "\$@ CONFIG_HEADERS= \$(SHELL) ./config.status\n"; |
---|
601 | } |
---|
602 | else |
---|
603 | { |
---|
604 | print "Makefile: \@MAINTAINER_MODE_TRUE\@ \$(srcdir)/Makefile.in \$(top_builddir)/config.status\n" ; |
---|
605 | print " cd \$(top_builddir) \\\n" ; |
---|
606 | print " && CONFIG_FILES=" ; |
---|
607 | print "\$(subdir)/" if ( "$subdir" ); |
---|
608 | print "\$@ CONFIG_HEADERS= \$(SHELL) ./config.status\n"; |
---|
609 | } |
---|
610 | |
---|
611 | ;1 |
---|