File: pcd2html_create_makefile

package info (click to toggle)
pcd2html 0.5.1-3.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 368 kB
  • ctags: 56
  • sloc: perl: 1,405; makefile: 120; sh: 69
file content (95 lines) | stat: -rwxr-xr-x 1,980 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl -w
# pcd2html module pcd2html_create_makefile
# Copyright Andreas Tille <tille@debian.org>
#
# This module creates Makefiles in each subdirectory from a rules file
use pcd2html_uti;
use strict ;

my ( @deps,    ## dependencies
     $prevdep, ## previous dependency line
     $dep,     ## current dependency line
     $nextdep, ## next dependency line
     $i        ## counter for valid lines
   );

OpenRules(); # We do not need the %keys dictionary which is returned by OpenRules in this module

open(MAKEFILE, ">Makefile" ) || die "Unable to open Makefile\n" ;
select (MAKEFILE) ;

$_ = `pwd` ;
chomp ;
s/.*\/([^\/]*)$/$1/;
my $dir = $_ ;

print "# Makefile in $dir created by pcd2html_create_makefile\n" ;

print "SOURCES= " ;

@deps = () ;
$i    = 0 ;

my $cur ;

while ( <RULES> ) {
  unless ( /\s*#/ ) {
    chomp ;
    if ( /(\w*):(\w*)/ ) {
      $cur = "$1_$2" ;
      print "\\\n\t$cur " ;
      system("touch $cur.img");
    }
    if ( $i > 0 ) {
      # other than first valid entry

      @deps = (@deps, $dep . "$cur.jpg" );
      $dep = "$cur.html: $nextdep.jpg " . "$cur.jpg " ;
    } else {
      $dep = "$cur.html: $cur.jpg " ;
    }
    $nextdep = $cur ;
    $i++ ;
  }
}

@deps = (@deps, $dep );

close RULES ;


print "\n" ;
print ".SUFFIXES: .img .jpg .html\n\n" ;

print ".jpg.html:\n" ;
print "	\@${datadir}/pcd2html_create_html `basename \$< jpg`img\n\n" ;

print ".img.jpg:\n" ;
print "	\@${datadir}/pcd2html_create_jpg \$<\n\n" ;

print "all: \$(SOURCES:%=%.html) Makefile\n\n" ;

foreach $dep (@deps) {
  print "$dep\n" ;
}

print "\nMakefile: rules\n" ;
print "	\@touch *.img\n" ;
print "	\@rm -rf *~\n" ;
print "	\@${datadir}/pcd2html_create_makefile\n\n" ;

print "\ncleanhtml:\n" ;
print "	\@rm -rf *.html *~\n\n" ;

print "clean:\n" ;
print "	\@rm -rf *.img *~\n" ;
print "	\@make cleanhtml\n\n" ;

print "distclean:\n" ;
print "	\@make clean\n" ;
print "	\@rm -rf *.img *.jpg Makefile\n" ;

select (STDOUT) ;
close(MAKEFILE) ;