| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # mkdest: make AFS platform directory for build |
| 4 | |
| 5 | if ($#ARGV >= 0) { |
| 6 | $srcdir = $ARGV[0]; |
| 7 | } |
| 8 | else { |
| 9 | $srcdir = "/tmp/src"; |
| 10 | } |
| 11 | $dir = $ENV{PWD}; |
| 12 | |
| 13 | print "Create build tree from the AFS source tree $srcdir\n"; |
| 14 | print "Create links in platform tree $dir\n"; |
| 15 | |
| 16 | print "continue (y/n) ? "; |
| 17 | |
| 18 | chop ($ans = <STDIN>); |
| 19 | exit if ($ans ne "y"); |
| 20 | |
| 21 | mkdir "dest", 0755 || die "Can't create directory dest\n"; |
| 22 | mkdir "obj", 0755 || die "Can't create directory obj\n"; |
| 23 | chdir "obj" || die "Can't change to directory obj\n"; |
| 24 | |
| 25 | &dodir($srcdir, ".."); |
| 26 | |
| 27 | sub dodir { |
| 28 | local($dir,$destpath) = @_; |
| 29 | print "$dir\n"; |
| 30 | local($a); |
| 31 | local($i); |
| 32 | |
| 33 | #if (-e "$dir/RCS") { |
| 34 | ## Make RCS link and check out all files in this directory |
| 35 | #system("ln -sf $dir/RCS"); |
| 36 | #system("co RCS/*"); |
| 37 | #} |
| 38 | |
| 39 | opendir(DIR,$dir) || die "Can't open directory $dir\n"; |
| 40 | local(@allfiles) = readdir(DIR); |
| 41 | closedir(DIR); |
| 42 | |
| 43 | $thisdir = &lastcomp($dir); |
| 44 | system("ln -s $destpath/dest DEST"); |
| 45 | system("ln -s $destpath/../src/$thisdir SRC"); |
| 46 | |
| 47 | foreach $a (@allfiles) { |
| 48 | #print "$a\n"; |
| 49 | if (! -d "$dir/$a") { |
| 50 | system("ln -s SRC/$a"); |
| 51 | next; |
| 52 | } |
| 53 | next if $a eq '.'; |
| 54 | next if $a eq '..'; |
| 55 | next if $a eq 'RCS'; |
| 56 | |
| 57 | # Make this subdirectory on local copy |
| 58 | mkdir $a, 0755 || die "Can't create directory $dir/$a\n"; |
| 59 | chdir $a || die "Can't change to directory $dir/$a\n"; |
| 60 | |
| 61 | # Recursively process this directory |
| 62 | &dodir("$dir/$a", "$destpath/.."); |
| 63 | chdir '..'; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | sub lastcomp { |
| 68 | local($dir) = @_; |
| 69 | |
| 70 | $_ = $dir; |
| 71 | if (/$srcdir\/(\S+)/) { |
| 72 | $dir = $1; |
| 73 | } |
| 74 | else { |
| 75 | $dir = $_; |
| 76 | } |
| 77 | return $dir; |
| 78 | } |