##!/usr/local/bin/perl eval "exec perl -S $0 $*" if $running_under_some_shell; # # Creates a toplevel Cakefile from picking up the FIGLIST variable # from subdirectories. # # Matthias Schwab: 31may95 # $usage = "Usage: $0 - \n"; $selfdoc = "Creates a Cakefile from picking up the FIGLIST variables from all lowercase subdirectories of the directory you are in.\n"; if( $#ARGV < 0 ||$#ARGV > 1 ) { print $usage; die $selfdoc; } $notice = "\$ **** MACHINE MADE CAKEFILE (by makecake) ****\n"; # Check if Cakefile exists and if it is made by makecake if (-e "cakefile" || -e "Cakefile") { if (-e "cakefile") {$cakename = "cakefile";} if (-e "Cakefile") {$cakename = "Cakefile";} $first_line = `sed 1q< $cakename`; if ("$first_line" ne "$notice") { $dir = `pwd`; chop($dir); print "$dir"; print ": a Cakefile exists and it is not made by makecake. I quit.\n"; die; } } open(DODIR, "ls -d [a-z]* |") || die "Can't see $dir\n"; while ($dir = ) { chop $dir; if ( -d $dir ) { $dirlist = join(" ",$dirlist,$dir); } } `echo "$notice" > Cakefile`; `echo ' \$ This Cakefile is generated by executing the "makecake" perl script \$ in this directory. To generate a Cakefile for all chapter directories \$ in a book, you execute "Tour makecake" in the Adm directory.' >> Cakefile`; `echo ' ' >> Cakefile`; `echo '#define FIGDIR ./Fig' >> Cakefile`; `echo '#include ' >> Cakefile`; `echo ' ' >> Cakefile`; foreach $dir (split(" ",$dirlist)) { $localfigs = &subfigs($dir,$localfigs); chop $localfigs; $figlist = join(" ",$figlist,$localfigs); } `echo '#define FIGLIST '"$figlist" >> Cakefile`; `echo ' ' >> Cakefile`; foreach $dir (split(" ",$dirlist)) { $localfigs = &subfigs($dir,$localfigs); foreach $figure (split(" ",$localfigs)) { #`echo "$figure"'.% & : if not {{ pushd '"$dir"'; cake -q '"$figure"'.%; popd; }}' >> Cakefile`; #`echo "$figure.% & : " >> Cakefile`; #`echo "\tcd $dir; cake $figure.%;" >> Cakefile`; #`echo ' ' >> Cakefile`; `echo "./Fig/$figure.% & : " >> Cakefile`; `echo "\tcd $dir; cake ./../Fig/$figure.%;" >> Cakefile`; `echo ' ' >> Cakefile`; } } `echo 'clean & : texclean' >> Cakefile`; foreach $dir (split(" ",$dirlist)) { `echo "\t-cd $dir; cake clean;" >> Cakefile`; } `echo ' ' >> Cakefile`; `echo '#include ' >> Cakefile`; `echo '#include ' >> Cakefile`; `echo '#include ' >> Cakefile`; sub subfigs{ local($dir,$localfigs) = @_; $localfigs = `grep FIGLIST $dir/[C-c]akefile`; $localfigs =~ s/\$.*$//g; $localfigs =~ s/\n/ /g; $localfigs =~ s/.*#define.*FIGLIST//g ; return $localfigs; } # print "I look at $dir \n";