4 # Build the libafs_tree by reading component list files in the src dir, and copying the
5 # listed files from the src and obj dirs into the libafs_tree directory.
7 # Dependent components are listed in file named "libafsdep" in each dir with dependencies.
15 while ( $_ = shift @ARGV )
17 if (m/^-t/) { $treedir = testArg( shift @ARGV ); next; }
18 if (m/^-p/) { $projdir = testArg( shift @ARGV ); next; }
19 if (m/^-sn/) { $sysname = testArg( shift @ARGV ); next; }
21 if (m/^-os/) { $ostype = testArg( shift @ARGV ); next; }
22 elsif (m/^-o/) { $objdir = testArg( shift @ARGV ); next; }
24 if (m/^-q/) { $quiet = 1; next; }
25 if (m/^-n/) { $showonly = 1; next; }
28 if ( !$treedir || !$projdir || !$ostype || !$sysname)
38 $quiet || print "libafs_tree_dir = $treedir\n";
39 $quiet || print "top_proj_dir = $projdir\n";
40 $quiet || print "top_obj_dir = $objdir\n";
42 my $qprojdir = quotemeta($projdir);
45 # Start with an empty dir
47 if ( -e $treedir && ! -d $treedir )
49 die "Ick. Destination is not a directory and already exists!\n";
53 #$quiet || print "Cleaning up previous tree build:\n";
54 #rmtree([$treedir],!$quiet,0);
55 #$quiet || print "Done.\n\n";
59 # Find all the dep list files in the src dir
61 finddepth(\&find_libafsdep, $projdir);
66 ©it("$projdir/configure-libafs", "$treedir/configure");
67 ©it("$projdir/Makefile-libafs.in", "$treedir/Makefile.in");
69 system("$objdir/src/config/config",
70 "$projdir/src/libafs/MakefileProto.$ostype.in",
71 "$treedir/src/libafs/Makefile.in",
82 if ( $fname eq "libafsdep" )
84 &process_libafsdep($File::Find::dir, $fname);
90 my ($dir, $depname) = @_;
94 $subdir =~ s|^$qprojdir||o;
98 print "# $dir/$depname\n";
99 open(COMPS, "$depname");
100 while ( defined($file = <COMPS>) )
102 my ($destdir, $proj_src,$obj_src);
108 # do some simple substitution in dep file
110 $file =~ s/MKAFS_OSTYPE/$ostype/ge;
111 $file =~ s/AFS_SYSNAME/$sysname/ge;
113 next if ( $file eq "" );
115 $proj_src = "$projdir/$subdir/$file";
116 $obj_src = "$objdir/$subdir/$file";
117 $proj_src =~ s|//+|/|gio;
118 $obj_src =~ s|//+|/|gio;
120 if ( $file !~ /\*/ && $file !~ /\[/ ) # no globs in filename
123 $fname =~ s|.*/||gio;
127 $destdir = mkfullpath($projdir, $proj_src, $treedir);
128 copyit($proj_src, "$destdir/$fname");
131 if ( $obj_src ne $proj_src && -f $obj_src)
133 $destdir = mkfullpath($objdir, $obj_src, $treedir);
134 copyit($obj_src, "$destdir/$fname");
139 #print "Globbing ($proj_src)\n";
140 foreach my $src ( glob($proj_src) )
143 $fname =~ s|.*/||gio;
145 $destdir = mkfullpath($projdir, $src, $treedir);
146 copyit($src, "$destdir/$fname");
148 #print "Globbing ($obj_src)\n";
149 foreach my $src ( glob($obj_src) )
152 $fname =~ s|.*/||gio;
154 $destdir = mkfullpath($objdir, $src, $treedir);
155 copyit($src, "$destdir/$fname");
161 $quiet || print "\n";
166 print "usage: $0 -p top_proj_dir -os mkafs_ostype -sn sysname\n";
167 print "\t\t[-o top_obj_dir] [-t libafs_tree_dir] [-h] [-q] [-n]\n";
168 print "\ttop_proj_dir = /path/to/openafs - top level of openafs checkout/tarball\n";
169 print "\ttop_obj_dir = /path/to/objdir - top level of build directory, defaults to top_proj_dir\n";
170 print "\tlibafs_tree_dir = /path/to/libafs_tree - tree dir to create, defaults to top_obj_dir/libafs_tree\n";
171 print "\t-os = ostype value (i.e. LINUX)\n";
172 print "\t-sn = afs sysname (i.e. i386_linux24)\n";
173 print "\t-q = quiet build\n";
174 print "\t-n = just show what will be done\n";
175 print "\t-h = show this message\n";
183 return $arg if ( $arg && $arg ne "" );
189 my ($frombase, $fromfile, $destbase) = @_;
190 my $qfrombase = quotemeta $frombase;
192 my $subdir = $fromfile;
193 $subdir =~ s|^$qfrombase||;
194 $subdir =~ s|^(.*)/(.*?)$|$1|o;
195 $subdir =~ s|^/||gio;
196 $subdir =~ s|/$||gio;
197 $subdir =~ s|//+|/|gio;
199 my $destdir = "$destbase/$subdir";
200 $destdir =~ s|/$||gio;
201 $destdir =~ s|//+|/|gio;
203 $showonly || mkpath([$destdir], !$quiet, 0755);
210 my ( $from, $to ) = @_;
216 if ( ($#to < 0) || ($from[7] != $to[7]) || ($from[9] != $to[9]) )
218 $quiet || print "+ cp -p $from $to\n";
219 $showonly || system( "cp", "-p", $from, $to );