#!../miniperl # Habit . . . # # Extract info from config.h, and add extra data here, to generate config.sh # Edit the static information after __END__ to reflect your site and options # that went into your perl binary. In addition, values which change from run # to run may be supplied on the command line as key=val pairs. # # Last Modified: 28-Jun-1996 Luther Huffman lutherh@stratcom.com # #==== Locations of installed Perl components $p9pvers="_P9P_VERSION"; $prefix=''; $p9p_objtype=$ENV{'objtype'}; $builddir="/sys/src/cmd/perl/$p9pvers"; $installbin="/$p9p_objtype/bin"; $installman1dir="/sys/man/1"; $installman3dir="/sys/man/2"; $installprivlib="/sys/lib/perl"; $installarchlib = "/$p9p_objtype/lib/perl/$p9pvers"; $archname="plan9_$p9p_objtype"; $installsitelib="$installprivlib/site_perl"; $installsitearch="$installarchlib/site_perl"; $installscript="/bin"; unshift(@INC,'lib'); # In case someone didn't define Perl_Root # before the build if ($ARGV[0] eq '-f') { open(ARGS,$ARGV[1]) or die "Can't read data from $ARGV[1]: $!\n"; @ARGV = (); while () { push(@ARGV,split(/\|/,$_)); } close ARGS; } if (-f "config.h") { $infile = "config.h"; $outdir = "../"; } elsif (-f "plan9/config.h") { $infile = "plan9/config.h"; $outdir = "./"; } if ($infile) { print "Generating config.sh from $infile . . .\n"; } else { die <${outdir}config.sh") || die "Can't open ${outdir}config.sh: $!\n"; $time = localtime; $cf_by = $ENV{'user'}; ($vers = $]) =~ tr/./_/; # Plan 9 doesn't actually use version numbering. Following the original Unix # precedent of assigning a Unix edition number based on the edition number # of the manuals, I am referring to this as Plan 9, 1st edition. $osvers = '1'; print OUT <) { next unless m%^#(?!if).*\$%; s/^#//; s!(.*?)\s*/\*.*!$1!; my(@words) = split; $words[1] =~ s/\(.*//; # Clip off args from macro # Did we use a shell variable for the preprocessor directive? if ($words[0] =~ m!^\$(\w+)!) { $pp_vars{$words[1]} = $1; } if (@words > 2) { # We may also have a shell var in the value shift @words; # Discard preprocessor directive my($token) = shift @words; # and keep constant name my($word); foreach $word (@words) { next unless $word =~ m!\$(\w+)!; $val_vars{$token} = $1; last; } } } close SH; } else { warn "Couldn't read ${outfile}config_h.SH: $!\n"; } $pp_vars{PLAN9} = 'define'; #Plan 9 specific # OK, now read the C header file, and retcon statements into config.sh while () { # roll through the comment header in config.h last if /config-start/; } while () { chop; while (/\\\s*$/) { # pick up contination lines my $line = $_; $line =~ s/\\\s*$//; $_ = ; s/^\s*//; $_ = $line . $_; } next unless my ($blocked,$un,$token,$val) = m%^(\/\*)?\s*\#\s*(un)?def\w*\s+([A-Za-z0-9]\w+)\S*\s*(.*)%; if (/config-skip/) { delete $pp_vars{$token} if exists $pp_vars{$token}; delete $val_vars{$token} if exists $val_vars{$token}; next; } $val =~ s!\s*/\*.*!!; # strip off trailing comment my($had_val); # Maybe a macro with args that we just #undefd or commented if (!length($val) and $val_vars{$token} and ($un || $blocked)) { print OUT "$val_vars{$token}=''\n"; delete $val_vars{$token}; $had_val = 1; } $state = ($blocked || $un) ? 'undef' : 'define'; if ($pp_vars{$token}) { print OUT "$pp_vars{$token}='$state'\n"; delete $pp_vars{$token}; } elsif (not length $val and not $had_val) { # Wups -- should have been shell var for C preprocessor directive warn "Constant $token not found in config_h.SH\n"; $token =~ tr/A-Z/a-z/; $token = "d_$token" unless $token =~ /^i_/; print OUT "$token='$state'\n"; } next unless length $val; $val =~ s/^"//; $val =~ s/"$//; # remove end quotes $val =~ s/","/ /g; # make signal list look nice if ($val_vars{$token}) { print OUT "$val_vars{$token}='$val'\n"; if ($val_vars{$token} =~ s/exp$//) {print OUT "$val_vars{$token}='$val'\n";} delete $val_vars{$token}; } elsif (!$pp_vars{$token}) { # Haven't seen it previously, either warn "Constant $token not found in config_h.SH (val=|$val|)\n"; $token =~ tr/A-Z/a-z/; print OUT "$token='$val'\n"; if ($token =~ s/exp$//) {print OUT "$token='$val'\n";} } } close IN; foreach (sort keys %pp_vars) { warn "Didn't see $_ in $infile\n"; } foreach (sort keys %val_vars) { warn "Didn't see $_ in $infile(val)\n"; } # print OUT "libs='",join(' ',@libs),"'\n"; # print OUT "libc='",join(' ',@crtls),"'\n"; if (open(PL,"${outdir}patchlevel.h")) { while () { if (/^#define PATCHLEVEL\s+(\S+)/) { print OUT "PATCHLEVEL='$1'\n"; } elsif (/^#define SUBVERSION\s+(\S+)/) { print OUT "SUBVERSION='$1'\n"; } } close PL; } else { warn "Can't read ${outdir}patchlevel.h - skipping 'PATCHLEVEL'"; } print OUT "pager='/bin/p'\n"; close OUT;