eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # $Id$ # # Creates an ACE build tree in directory "build/" below the current # directory, which must be an ACE "top level" directory (such as # $ACE_ROOT). The build tree directory structure mirrors that of the ACE # top level directory structure, except that instead of containing any plain # files, it contains only symlinks to the files in the ACE top level structure. # # This program has a similar purpose to "clone", but in addition to # only creating symlinks (clone creates hard links, by default), this # script: # 1) uses relative rather than absolute symlinks, # 2) tries not to put junk files into the build tree, # 3) only creates a new tree in a build/ directory below the current, # top level ACE directory (it's a feature :-), but it does enforce # consistency). # # This program can be re-run on a build tree at any time in order to # update it. It will only add new symlinks, it won't remove any that # are no longer valid. If you want to do that, it's easiest just to # remove the build completely and start from scratch. # # If the starts with "build/", that part will be removed # from it. # # The first three lines above let this script run without specifying the # full path to perl, as long as it is in the user's PATH. # Taken from perlrun man page. $usage = "usage: $0 -? | [-a] [-d ] [-v] \n"; $directory_mode = 042755; #### fine on Suns, but maybe not all Unix platforms $verbose = 0; $source='.'; $absolute= 0; $perl_version = $] + 0; if ($perl_version >= 5) { #### Use an eval so that this script will compile with perl4. eval <<'PERL5_CWD' require Cwd; sub cwd { Cwd::getcwd (); } PERL5_CWD } else { sub cwd { local ($pwd); chop ($pwd = `pwd`); $pwd; } } #### #### process command line args #### while ( $#ARGV >= 0 && $ARGV[0] =~ /^-/ ) { if ( $ARGV[0] eq '-v' ) { $verbose = 1; } elsif ( $ARGV[0] eq '-d' ) { if ( $ARGV[1] =~ /^\d+$/ ) { $directory_mode = $ARGV[1]; shift; } else { warn "$0: must provide argument for -d option\n"; die $usage; } } elsif ($ARGV[0] eq '-a' ) { $source = &cwd (); $absolute = 1; } elsif ( $ARGV[0] eq '-?' ) { print "$usage"; exit; } else { warn "$0: unknown option $ARGV[0]\n"; die $usage; } shift; } die $usage unless $#ARGV == 0; $build = $ARGV[0]; $build =~ s%^build/%%; #### remove leading "build/", if any $build = "build/$build"; #### #### check that we're in an ACE "top level" directory #### ( -d 'ace' && -d 'examples' && -d 'netsvcs' ) || die "$0: must be in an ACE top level (ACE_ROOT) directory!\n"; #### #### Create build directories, if needed. #### -d 'build' || mkdir ('build', $directory_mode); -d "$build" || mkdir ("$build", $directory_mode); #### #### Get all ACE plain file and directory names. #### @files = ( `/usr/bin/find . -name CVS -prune \\\ -o -name build -prune -o \\\ -name '.*obj' -prune -o -name Templates.DB -prune -o \\\ \\( ! -type l ! -name core ! -name '*.state' ! -name '*.so' \\\ ! -name '*.[oa]' ! -name '*~' ! -name '.' ! -name '.#*' \\\ ! -name '*.log' \\) \\\ -print` ); #### #### Create directories and symlinks to files. #### foreach $file ( @files ) { chop $file; #### remove trailing newline (from find command above) $file =~ s%^./%%g; #### excise leading ./ directory component if ( -d $file ) { unless ( -d "$build/$file" ) { print "mkdir $build/$file, $directory_mode\n" if $verbose; mkdir ("$build/$file", $directory_mode); } } else { unless ( -e "$build/$file" ) { if (!$absolute) { $up = '../..'; while ( $file =~ m%/%g ) { $up .= '/..'; } print "symlink $up/$file $build/$file\n" if $verbose; symlink ("$up/$file", "$build/$file") || die "$0 symlink to $build/$file failed\n"; } else { $path = $source . '/' . $file; print "symlink $path $build/$file\n" if $verbose; symlink ("$path", "$build/$file") || die "$0 symlink to $build/$file failed\n"; } } } } #### #### Done: print message. #### print "\nCompleted creation of $build/.\n"; unless ( -e "$build/ace/config.h" && -e "$build/include/makeinclude/platform_macros.GNU" ) { print "Be sure to setup $build/ace/config.h and\n" . "$build/include/makeinclude/platform_macros.GNU symlinks.\n"; } #### EOF