Add app/xinput.
[xorg-util-modular.git] / symlinkapp.pl
blobf97bda466ef215aa99a5cb1aca2373f146eba311
1 #!/usr/bin/perl -w
3 $n_args = $#ARGV + 1;
5 if ($n_args < 1)
7 print "usage: modularize_app <app directory>" ;
8 print "\n" ;
9 print "\n" ;
11 exit 1
14 if (!-d $ARGV[0] )
16 print "$ARGV[0] does not exist\n" ;
17 exit 1
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: $!";
32 while (<IN>)
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";
40 print OUT "\n";
42 ################# Add c files
44 @files = ();
46 print $app_name, "\n" ;
47 foreach $cfile ( `ls *.c` )
49 @files = (@files, $cfile)
52 if ($#files + 1)
54 foreach $cfile ( @files )
56 $cfile = `basename $cfile`;
57 $cfile =~ s/^\s*(.*?)\s*$/$1/;
58 if (-l $cfile)
60 print "ASFSDFSDFSDF: $cfile\n";
62 print OUT " action\t$cfile\n";
65 print OUT "\n";
68 ################# Add README files
70 @files = ();
72 foreach $file ( `ls README` )
74 @files = (@files, $file);
77 if ($#files + 1)
79 foreach $file (@files)
81 $file = `basename $file`;
82 $file =~ s/^\s*(.*?)\s*$/$1/;
83 print OUT " action\t$file\n";
86 print OUT "\n" ;
91 ################# Add h files
93 @files = ();
95 foreach $hfile ( `ls *.h` )
97 @files = (@files, $hfile);
100 if ($#files + 1)
102 foreach $hfile (@files)
104 $hfile = `basename $hfile`;
105 $hfile =~ s/^\s*(.*?)\s*$/$1/;
106 print OUT " action\t$hfile\n";
109 print OUT "\n" ;
112 ################ Add man files
114 @files = ();
116 foreach $manfile (`ls *.man`)
118 @files = (@files, $manfile);
121 if ($#files + 1)
123 foreach $manfile ( @files )
125 $manfile = `basename $manfile`;
126 $manfile =~ s/^\s*(.*?)\s*$/$1/;
127 print OUT " action\t$manfile\n";
130 print OUT "\n" ;
133 ###################################
135 print OUT "}\n";
136 print OUT "\n";
138 # print "symlink_app() {"
140 print OUT ;
142 print OUT " symlink_app_$app_name\n"
144 else
146 print OUT ;
150 system ( "mv $newsymlinksh $symlinksh\n" );