7 # Build the libafs_tree by reading component list files in the src dir, and copying the
8 # listed files from the src and obj dirs into the libafs_tree directory.
10 # Dependent components are listed in file named "libafsdep" in each dir with dependencies.
23 while ( $_ = shift @ARGV )
25 if (m/^-t/) { $treedir = testArg( shift @ARGV ); next; }
26 if (m/^-p/) { $projdir = testArg( shift @ARGV ); next; }
27 if (m/^-sn/) { $sysname = testArg( shift @ARGV ); next; }
29 if (m/^-os/) { $ostype = testArg( shift @ARGV ); next; }
30 elsif (m/^-o/) { $objdir = testArg( shift @ARGV ); next; }
32 if (m/^-q/) { $quiet = 1; next; }
33 if (m/^-n/) { $showonly = 1; next; }
36 if ( !$treedir || !$projdir || !$ostype || !$sysname)
46 $quiet || print "libafs_tree_dir = $treedir\n";
47 $quiet || print "top_proj_dir = $projdir\n";
48 $quiet || print "top_obj_dir = $objdir\n";
50 my $qprojdir = quotemeta($projdir);
53 # Start with an empty dir
55 if ( -e $treedir && ! -d $treedir )
57 die "Ick. Destination is not a directory and already exists!\n";
61 #$quiet || print "Cleaning up previous tree build:\n";
62 #rmtree([$treedir],!$quiet,0);
63 #$quiet || print "Done.\n\n";
67 # Find all the dep list files in the src dir
69 finddepth(\&find_libafsdep, $projdir);
74 ©it("$projdir/configure-libafs", "$treedir/configure");
75 ©it("$projdir/Makefile-libafs.in", "$treedir/Makefile.in");
76 ©it("$projdir/src/libafs/MakefileProto.$ostype.in",
77 "$treedir/src/libafs/MakefileProto.in");
79 # We need to regenerate this to support building amd64 kernels from a
80 # libafs_tree built on i386.
81 unlink("$treedir/include/afs/param.h");
91 if ( $fname eq "libafsdep" )
93 &process_libafsdep($File::Find::dir, $fname);
99 my ($dir, $depname) = @_;
103 $subdir =~ s|^$qprojdir||o;
104 $subdir =~ s|^/||gio;
105 $subdir =~ s|/$||gio;
107 print "# $dir/$depname\n";
108 open(COMPS, "$depname");
109 while ( defined($file = <COMPS>) )
111 my ($destdir, $proj_src,$obj_src);
117 # do some simple substitution in dep file
119 $file =~ s/MKAFS_OSTYPE/$ostype/ge;
121 next if ( $file eq "" );
123 $proj_src = "$projdir/$subdir/$file";
124 $obj_src = "$objdir/$subdir/$file";
125 $proj_src =~ s|//+|/|gio;
126 $obj_src =~ s|//+|/|gio;
128 if ( $file !~ /\*/ && $file !~ /\[/ ) # no globs in filename
131 $fname =~ s|.*/||gio;
135 $destdir = mkfullpath($projdir, $proj_src, $treedir);
136 copyit($proj_src, "$destdir/$fname");
139 if ( $obj_src ne $proj_src && -f $obj_src)
141 $destdir = mkfullpath($objdir, $obj_src, $treedir);
142 copyit($obj_src, "$destdir/$fname");
147 #print "Globbing ($proj_src)\n";
148 foreach my $src ( glob($proj_src) )
151 $fname =~ s|.*/||gio;
153 $destdir = mkfullpath($projdir, $src, $treedir);
154 copyit($src, "$destdir/$fname");
156 #print "Globbing ($obj_src)\n";
157 foreach my $src ( glob($obj_src) )
160 $fname =~ s|.*/||gio;
162 $destdir = mkfullpath($objdir, $src, $treedir);
163 copyit($src, "$destdir/$fname");
169 $quiet || print "\n";
174 print "usage: $0 -p top_proj_dir -os mkafs_ostype -sn sysname\n";
175 print "\t\t[-o top_obj_dir] [-t libafs_tree_dir] [-h] [-q] [-n]\n";
176 print "\ttop_proj_dir = /path/to/openafs - top level of openafs checkout/tarball\n";
177 print "\ttop_obj_dir = /path/to/objdir - top level of build directory, defaults to top_proj_dir\n";
178 print "\tlibafs_tree_dir = /path/to/libafs_tree - tree dir to create, defaults to top_obj_dir/libafs_tree\n";
179 print "\t-os = ostype value (i.e. LINUX)\n";
180 print "\t-sn = afs sysname (i.e. i386_linux24)\n";
181 print "\t-q = quiet build\n";
182 print "\t-n = just show what will be done\n";
183 print "\t-h = show this message\n";
191 return $arg if ( $arg && $arg ne "" );
197 my ($frombase, $fromfile, $destbase) = @_;
198 my $qfrombase = quotemeta $frombase;
200 my $subdir = $fromfile;
201 $subdir =~ s|^$qfrombase||;
202 $subdir =~ s|^(.*)/(.*?)$|$1|o;
203 $subdir =~ s|^/||gio;
204 $subdir =~ s|/$||gio;
205 $subdir =~ s|//+|/|gio;
207 my $destdir = "$destbase/$subdir";
208 $destdir =~ s|/$||gio;
209 $destdir =~ s|//+|/|gio;
211 $showonly || mkpath([$destdir], !$quiet, 0755);
218 my ( $from, $to ) = @_;
226 if ( ($#to < 0) || ($from[7] != $to[7]) || ($from[9] != $to[9]) )
228 $quiet || print "+ cp -p $from $to\n";
229 $showonly || system( "cp", "-p", $from, $to );