7 print "usage: modularize_app <app directory>" ;
16 print "$ARGV[0] does not exist\n" ;
20 $app_location = `cd $ARGV[0] ; pwd`;
21 $app_location =~ s/^\s*(.*?)\s*$/$1/;
23 $app_name = `basename $app_location`;
24 $app_name =~ s/^\s*(.*?)\s*$/$1/;
26 $symlinksh = "../../../util/modular/symlink.sh";
27 $newsymlinksh = "../../../util/modular/symlink.sh.new";
29 open IN
, "< $symlinksh" or die "can't open $symlinksh: $!";
30 open OUT
, "> $newsymlinksh" or die "can't open $newsymlinksh for writing: $!";
34 if (/symlink_app\(\) \{/)
36 print OUT
"symlink_app_$app_name() {\n";
37 print OUT
" src_dir programs/$app_name\n";
38 print OUT
" dst_dir app/$app_name\n";
42 ################# Add c files
46 print $app_name, "\n" ;
47 foreach $cfile ( `ls *.c` )
49 @files = (@files, $cfile)
54 foreach $cfile ( @files )
56 $cfile = `basename $cfile`;
57 $cfile =~ s/^\s*(.*?)\s*$/$1/;
60 print "ASFSDFSDFSDF: $cfile\n";
62 print OUT
" action\t$cfile\n";
68 ################# Add README files
72 foreach $file ( `ls README` )
74 @files = (@files, $file);
79 foreach $file (@files)
81 $file = `basename $file`;
82 $file =~ s/^\s*(.*?)\s*$/$1/;
83 print OUT
" action\t$file\n";
91 ################# Add h files
95 foreach $hfile ( `ls *.h` )
97 @files = (@files, $hfile);
102 foreach $hfile (@files)
104 $hfile = `basename $hfile`;
105 $hfile =~ s/^\s*(.*?)\s*$/$1/;
106 print OUT
" action\t$hfile\n";
112 ################ Add man files
116 foreach $manfile (`ls *.man`)
118 @files = (@files, $manfile);
123 foreach $manfile ( @files )
125 $manfile = `basename $manfile`;
126 $manfile =~ s/^\s*(.*?)\s*$/$1/;
127 print OUT
" action\t$manfile\n";
133 ###################################
138 # print "symlink_app() {"
142 print OUT
" symlink_app_$app_name\n"
150 system ( "mv $newsymlinksh $symlinksh\n" );