| 1 | #!../miniperl
|
|---|
| 2 | # Habit . . .
|
|---|
| 3 | #
|
|---|
| 4 | # Extract info from config.h, and add extra data here, to generate config.sh
|
|---|
| 5 | # Edit the static information after __END__ to reflect your site and options
|
|---|
| 6 | # that went into your perl binary. In addition, values which change from run
|
|---|
| 7 | # to run may be supplied on the command line as key=val pairs.
|
|---|
| 8 | #
|
|---|
| 9 | # Last Modified: 28-Jun-1996 Luther Huffman [email protected]
|
|---|
| 10 | #
|
|---|
| 11 |
|
|---|
| 12 | #==== Locations of installed Perl components
|
|---|
| 13 | $p9pvers="_P9P_VERSION";
|
|---|
| 14 | $prefix='';
|
|---|
| 15 | $p9p_objtype=$ENV{'objtype'};
|
|---|
| 16 | $builddir="/sys/src/cmd/perl/$p9pvers";
|
|---|
| 17 | $installbin="/$p9p_objtype/bin";
|
|---|
| 18 | $installman1dir="/sys/man/1";
|
|---|
| 19 | $installman3dir="/sys/man/2";
|
|---|
| 20 | $installprivlib="/sys/lib/perl";
|
|---|
| 21 | $installarchlib = "/$p9p_objtype/lib/perl/$p9pvers";
|
|---|
| 22 | $archname="plan9_$p9p_objtype";
|
|---|
| 23 | $installsitelib="$installprivlib/site_perl";
|
|---|
| 24 | $installsitearch="$installarchlib/site_perl";
|
|---|
| 25 | $installscript="/bin";
|
|---|
| 26 |
|
|---|
| 27 | unshift(@INC,'lib'); # In case someone didn't define Perl_Root
|
|---|
| 28 | # before the build
|
|---|
| 29 |
|
|---|
| 30 | if ($ARGV[0] eq '-f') {
|
|---|
| 31 | open(ARGS,$ARGV[1]) or die "Can't read data from $ARGV[1]: $!\n";
|
|---|
| 32 | @ARGV = ();
|
|---|
| 33 | while (<ARGS>) {
|
|---|
| 34 | push(@ARGV,split(/\|/,$_));
|
|---|
| 35 | }
|
|---|
| 36 | close ARGS;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | if (-f "config.h") { $infile = "config.h"; $outdir = "../"; }
|
|---|
| 40 | elsif (-f "plan9/config.h") { $infile = "plan9/config.h"; $outdir = "./"; }
|
|---|
| 41 |
|
|---|
| 42 | if ($infile) { print "Generating config.sh from $infile . . .\n"; }
|
|---|
| 43 | else { die <<EndOfGasp;
|
|---|
| 44 | Can't find config.h to read!
|
|---|
| 45 | Please run this script from the perl source directory or
|
|---|
| 46 | the plan9 subdirectory in the distribution.
|
|---|
| 47 | EndOfGasp
|
|---|
| 48 | }
|
|---|
| 49 | $outdir = '';
|
|---|
| 50 | open(IN,"$infile") || die "Can't open $infile: $!\n";
|
|---|
| 51 | open(OUT,">${outdir}config.sh") || die "Can't open ${outdir}config.sh: $!\n";
|
|---|
| 52 |
|
|---|
| 53 | $time = localtime;
|
|---|
| 54 | $cf_by = $ENV{'user'};
|
|---|
| 55 | ($vers = $]) =~ tr/./_/;
|
|---|
| 56 |
|
|---|
| 57 | # Plan 9 doesn't actually use version numbering. Following the original Unix
|
|---|
| 58 | # precedent of assigning a Unix edition number based on the edition number
|
|---|
| 59 | # of the manuals, I am referring to this as Plan 9, 1st edition.
|
|---|
| 60 | $osvers = '1';
|
|---|
| 61 |
|
|---|
| 62 | print OUT <<EndOfIntro;
|
|---|
| 63 | # This file generated by genconfig.pl on a Plan 9 system.
|
|---|
| 64 | # Input obtained from:
|
|---|
| 65 | # $infile
|
|---|
| 66 | # $0
|
|---|
| 67 | # Time: $time
|
|---|
| 68 |
|
|---|
| 69 | package='perl5'
|
|---|
| 70 | CONFIG='true'
|
|---|
| 71 | cf_time='$time'
|
|---|
| 72 | cf_by='$cf_by'
|
|---|
| 73 | ccdlflags=''
|
|---|
| 74 | cccdlflags=''
|
|---|
| 75 | libpth='$installprivlib'
|
|---|
| 76 | ld='pcc'
|
|---|
| 77 | lddlflags=''
|
|---|
| 78 | ranlib=''
|
|---|
| 79 | ar='ar'
|
|---|
| 80 | nroff='/bin/nroff'
|
|---|
| 81 | eunicefix=':'
|
|---|
| 82 | hint='none'
|
|---|
| 83 | hintfile=''
|
|---|
| 84 | intsize='4'
|
|---|
| 85 | longsize='4'
|
|---|
| 86 | shortsize='2'
|
|---|
| 87 | shrplib='define'
|
|---|
| 88 | usemymalloc='n'
|
|---|
| 89 | usevfork='true'
|
|---|
| 90 | useposix='true'
|
|---|
| 91 | spitshell='cat'
|
|---|
| 92 | dlsrc='dl_none.c'
|
|---|
| 93 | binexp='$installbin'
|
|---|
| 94 | man1ext=''
|
|---|
| 95 | man3ext=''
|
|---|
| 96 | arch='$archname'
|
|---|
| 97 | archname='$archname'
|
|---|
| 98 | osname='plan9'
|
|---|
| 99 | extensions='IO Socket Opcode Fcntl POSIX DynaLoader FileHandle'
|
|---|
| 100 | osvers='$osvers'
|
|---|
| 101 | sig_maxsig='19'
|
|---|
| 102 | sig_name='ZERO HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM USR1 USR2 CHLD CONT STOP TSTP TTIN TTOU'
|
|---|
| 103 | sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19'
|
|---|
| 104 | sig_numsig='20'
|
|---|
| 105 | prefix='$prefix'
|
|---|
| 106 | builddir='$builddir'
|
|---|
| 107 | installbin='$installbin'
|
|---|
| 108 | installman1dir='$installman1dir'
|
|---|
| 109 | installman3dir='$installman3dir'
|
|---|
| 110 | installprivlib='$installprivlib'
|
|---|
| 111 | installarchlib='$installarchlib'
|
|---|
| 112 | installsitelib='$installsitelib'
|
|---|
| 113 | installsitearch='$installsitearch'
|
|---|
| 114 | installscript='$installscript'
|
|---|
| 115 | scriptdir='$installscript'
|
|---|
| 116 | scriptdirexp='$installscript'
|
|---|
| 117 | EndOfIntro
|
|---|
| 118 |
|
|---|
| 119 | # Plan 9 compiler stuff
|
|---|
| 120 | print OUT "cc='pcc'\n";
|
|---|
| 121 | print OUT "d_attribute_format='undef'\n";
|
|---|
| 122 | print OUT "d_attribute_malloc='undef'\n";
|
|---|
| 123 | print OUT "d_attribute_nonnull='undef'\n";
|
|---|
| 124 | print OUT "d_attribute_noreturn='undef'\n";
|
|---|
| 125 | print OUT "d_attribute_pure='undef'\n";
|
|---|
| 126 | print OUT "d_attribute_unused='undef'\n";
|
|---|
| 127 | print OUT "d_attribute_warn_unused_result='undef'\n";
|
|---|
| 128 | print OUT "d_socket='define'\n";
|
|---|
| 129 | print OUT "d_sockpair='define'\n";
|
|---|
| 130 | print OUT "d_sigsetjmp='define'\n";
|
|---|
| 131 | print OUT "sigjmp_buf='sigjmp_buf'\n";
|
|---|
| 132 | print OUT "sigsetjmp='sigsetjmp(buf,save_mask)'\n";
|
|---|
| 133 | print OUT "siglongjmp='siglongjmp(buf,retval) '\n";
|
|---|
| 134 | print OUT "exe_ext=''\n";
|
|---|
| 135 | if ($p9p_objtype eq '386') {
|
|---|
| 136 | $objext = '.8';
|
|---|
| 137 | $alignbytes = '4';
|
|---|
| 138 | $cstflags = 2;
|
|---|
| 139 | }
|
|---|
| 140 | elsif ($p9p_objtype eq '68020') {
|
|---|
| 141 | $objext = '.2';
|
|---|
| 142 | $alignbytes = '2';
|
|---|
| 143 | $cstflags = 0;
|
|---|
| 144 | }
|
|---|
| 145 | elsif ($p9p_objtype eq 'mips') {
|
|---|
| 146 | $objext = '.v';
|
|---|
| 147 | $alignbytes = '8';
|
|---|
| 148 | $cstflags = 0;
|
|---|
| 149 | }
|
|---|
| 150 | elsif ($p9p_objtype eq 'sparc') {
|
|---|
| 151 | $objext = '.k';
|
|---|
| 152 | $alignbytes = '4';
|
|---|
| 153 | $cstflags = 0;
|
|---|
| 154 | }
|
|---|
| 155 | print OUT "obj_ext='$objext'\n";
|
|---|
| 156 | print OUT "alignbytes='$alignbytes'\n";
|
|---|
| 157 | print OUT "castflags='$cstflags'\n";
|
|---|
| 158 |
|
|---|
| 159 | $myname = $ENV{'site'} ;
|
|---|
| 160 | ($myhostname,$mydomain) = split(/\./,$myname,2);
|
|---|
| 161 | print OUT "myhostname='$myhostname'\n" if $myhostname;
|
|---|
| 162 | if ($mydomain) {
|
|---|
| 163 | print OUT "mydomain='.$mydomain'\n";
|
|---|
| 164 | print OUT "perladmin='$cf_by\@$myhostname.$mydomain'\n";
|
|---|
| 165 | print OUT "cf_email='$cf_by\@$myhostname.$mydomain'\n";
|
|---|
| 166 | }
|
|---|
| 167 | else {
|
|---|
| 168 | print OUT "perladmin='$cf_by'\n";
|
|---|
| 169 | print OUT "cf_email='$cf_by'\n";
|
|---|
| 170 | }
|
|---|
| 171 | print OUT "myuname='Plan9 $myname $osvers $p9p_objtype'\n";
|
|---|
| 172 |
|
|---|
| 173 | # Before we read the C header file, find out what config.sh constants are
|
|---|
| 174 | # equivalent to the C preprocessor macros
|
|---|
| 175 | if (open(SH,"${outdir}config_h.SH")) {
|
|---|
| 176 | while (<SH>) {
|
|---|
| 177 | next unless m%^#(?!if).*\$%;
|
|---|
| 178 | s/^#//; s!(.*?)\s*/\*.*!$1!;
|
|---|
| 179 | my(@words) = split;
|
|---|
| 180 | $words[1] =~ s/\(.*//; # Clip off args from macro
|
|---|
| 181 | # Did we use a shell variable for the preprocessor directive?
|
|---|
| 182 | if ($words[0] =~ m!^\$(\w+)!) { $pp_vars{$words[1]} = $1; }
|
|---|
| 183 | if (@words > 2) { # We may also have a shell var in the value
|
|---|
| 184 | shift @words; # Discard preprocessor directive
|
|---|
| 185 | my($token) = shift @words; # and keep constant name
|
|---|
| 186 | my($word);
|
|---|
| 187 | foreach $word (@words) {
|
|---|
| 188 | next unless $word =~ m!\$(\w+)!;
|
|---|
| 189 | $val_vars{$token} = $1;
|
|---|
| 190 | last;
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 | close SH;
|
|---|
| 195 | }
|
|---|
| 196 | else { warn "Couldn't read ${outfile}config_h.SH: $!\n"; }
|
|---|
| 197 | $pp_vars{PLAN9} = 'define'; #Plan 9 specific
|
|---|
| 198 |
|
|---|
| 199 | # OK, now read the C header file, and retcon statements into config.sh
|
|---|
| 200 | while (<IN>) { # roll through the comment header in config.h
|
|---|
| 201 | last if /config-start/;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | while (<IN>) {
|
|---|
| 205 | chop;
|
|---|
| 206 | while (/\\\s*$/) { # pick up contination lines
|
|---|
| 207 | my $line = $_;
|
|---|
| 208 | $line =~ s/\\\s*$//;
|
|---|
| 209 | $_ = <IN>;
|
|---|
| 210 | s/^\s*//;
|
|---|
| 211 | $_ = $line . $_;
|
|---|
| 212 | }
|
|---|
| 213 | next unless my ($blocked,$un,$token,$val) =
|
|---|
| 214 | m%^(\/\*)?\s*\#\s*(un)?def\w*\s+([A-Za-z0-9]\w+)\S*\s*(.*)%;
|
|---|
| 215 | if (/config-skip/) {
|
|---|
| 216 | delete $pp_vars{$token} if exists $pp_vars{$token};
|
|---|
| 217 | delete $val_vars{$token} if exists $val_vars{$token};
|
|---|
| 218 | next;
|
|---|
| 219 | }
|
|---|
| 220 | $val =~ s!\s*/\*.*!!; # strip off trailing comment
|
|---|
| 221 | my($had_val); # Maybe a macro with args that we just #undefd or commented
|
|---|
| 222 | if (!length($val) and $val_vars{$token} and ($un || $blocked)) {
|
|---|
| 223 | print OUT "$val_vars{$token}=''\n";
|
|---|
| 224 | delete $val_vars{$token};
|
|---|
| 225 | $had_val = 1;
|
|---|
| 226 | }
|
|---|
| 227 | $state = ($blocked || $un) ? 'undef' : 'define';
|
|---|
| 228 | if ($pp_vars{$token}) {
|
|---|
| 229 | print OUT "$pp_vars{$token}='$state'\n";
|
|---|
| 230 | delete $pp_vars{$token};
|
|---|
| 231 | }
|
|---|
| 232 | elsif (not length $val and not $had_val) {
|
|---|
| 233 | # Wups -- should have been shell var for C preprocessor directive
|
|---|
| 234 | warn "Constant $token not found in config_h.SH\n";
|
|---|
| 235 | $token =~ tr/A-Z/a-z/;
|
|---|
| 236 | $token = "d_$token" unless $token =~ /^i_/;
|
|---|
| 237 | print OUT "$token='$state'\n";
|
|---|
| 238 | }
|
|---|
| 239 | next unless length $val;
|
|---|
| 240 | $val =~ s/^"//; $val =~ s/"$//; # remove end quotes
|
|---|
| 241 | $val =~ s/","/ /g; # make signal list look nice
|
|---|
| 242 |
|
|---|
| 243 | if ($val_vars{$token}) {
|
|---|
| 244 | print OUT "$val_vars{$token}='$val'\n";
|
|---|
| 245 | if ($val_vars{$token} =~ s/exp$//) {print OUT "$val_vars{$token}='$val'\n";}
|
|---|
| 246 | delete $val_vars{$token};
|
|---|
| 247 | }
|
|---|
| 248 | elsif (!$pp_vars{$token}) { # Haven't seen it previously, either
|
|---|
| 249 | warn "Constant $token not found in config_h.SH (val=|$val|)\n";
|
|---|
| 250 | $token =~ tr/A-Z/a-z/;
|
|---|
| 251 | print OUT "$token='$val'\n";
|
|---|
| 252 | if ($token =~ s/exp$//) {print OUT "$token='$val'\n";}
|
|---|
| 253 | }
|
|---|
| 254 | }
|
|---|
| 255 | close IN;
|
|---|
| 256 |
|
|---|
| 257 | foreach (sort keys %pp_vars) {
|
|---|
| 258 | warn "Didn't see $_ in $infile\n";
|
|---|
| 259 | }
|
|---|
| 260 | foreach (sort keys %val_vars) {
|
|---|
| 261 | warn "Didn't see $_ in $infile(val)\n";
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 | # print OUT "libs='",join(' ',@libs),"'\n";
|
|---|
| 266 | # print OUT "libc='",join(' ',@crtls),"'\n";
|
|---|
| 267 |
|
|---|
| 268 | if (open(PL,"${outdir}patchlevel.h")) {
|
|---|
| 269 | while (<PL>) {
|
|---|
| 270 | if (/^#define PERL_VERSION\s+(\S+)/) {
|
|---|
| 271 | print OUT "PERL_VERSION='$1'\n";
|
|---|
| 272 | print OUT "PATCHLEVEL='$1'\n"; # XXX compat
|
|---|
| 273 | }
|
|---|
| 274 | elsif (/^#define PERL_SUBVERSION\s+(\S+)/) {
|
|---|
| 275 | print OUT "PERL_SUBVERSION='$1'\n";
|
|---|
| 276 | print OUT "SUBVERSION='$1'\n"; # XXX compat
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 | close PL;
|
|---|
| 280 | }
|
|---|
| 281 | else { warn "Can't read ${outdir}patchlevel.h - skipping 'PERL_VERSION'"; }
|
|---|
| 282 |
|
|---|
| 283 | print OUT "pager='/bin/p'\n";
|
|---|
| 284 |
|
|---|
| 285 | close OUT;
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|