Commit | Line | Data |
---|---|---|
396e9e6f | 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 lutherh@stratcom.com | |
10 | # | |
11 | ||
12 | #==== Locations of installed Perl components | |
760ac839 | 13 | $p9pvers="_P9P_VERSION"; |
396e9e6f | 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' | |
396e9e6f | 85 | shrplib='define' |
86 | usemymalloc='n' | |
87 | usevfork='true' | |
88 | useposix='true' | |
89 | spitshell='cat' | |
90 | dlsrc='dl_none.c' | |
91 | binexp='$installbin' | |
92 | man1ext='' | |
93 | man3ext='' | |
94 | arch='$archname' | |
95 | archname='$archname' | |
96 | osname='plan9' | |
97 | extensions='IO Socket Opcode Fcntl POSIX DynaLoader FileHandle' | |
98 | osvers='$osvers' | |
99 | sig_maxsig='19' | |
100 | sig_name='ZERO HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM USR1 USR2 CHLD CONT STOP TSTP TTIN TTOU' | |
101 | sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19' | |
102 | sig_numsig='20' | |
103 | prefix='$prefix' | |
104 | builddir='$builddir' | |
105 | installbin='$installbin' | |
106 | installman1dir='$installman1dir' | |
107 | installman3dir='$installman3dir' | |
108 | installprivlib='$installprivlib' | |
109 | installarchlib='$installarchlib' | |
110 | installsitelib='$installsitelib' | |
111 | installsitearch='$installsitearch' | |
112 | installscript='$installscript' | |
113 | scriptdir='$installscript' | |
114 | scriptdirexp='$installscript' | |
115 | EndOfIntro | |
116 | ||
117 | # Plan 9 compiler stuff | |
118 | print OUT "cc='pcc'\n"; | |
119 | print OUT "d_attribut='undef'\n"; | |
120 | print OUT "d_socket='define'\n"; | |
121 | print OUT "d_sockpair='define'\n"; | |
122 | print OUT "d_sigsetjmp='define'\n"; | |
123 | print OUT "sigjmp_buf='sigjmp_buf'\n"; | |
124 | print OUT "sigsetjmp='sigsetjmp(buf,save_mask)'\n"; | |
125 | print OUT "siglongjmp='siglongjmp(buf,retval) '\n"; | |
126 | print OUT "exe_ext=''\n"; | |
127 | if ($p9p_objtype eq '386') { | |
128 | $objext = '.8'; | |
16da7c01 LH |
129 | $alignbytes = '4'; |
130 | $cstflags = 2; | |
396e9e6f | 131 | } |
132 | elsif ($p9p_objtype eq '68020') { | |
133 | $objext = '.2'; | |
16da7c01 LH |
134 | $alignbytes = '2'; |
135 | $cstflags = 0; | |
396e9e6f | 136 | } |
137 | elsif ($p9p_objtype eq 'mips') { | |
138 | $objext = '.v'; | |
16da7c01 LH |
139 | $alignbytes = '8'; |
140 | $cstflags = 0; | |
396e9e6f | 141 | } |
142 | elsif ($p9p_objtype eq 'sparc') { | |
143 | $objext = '.k'; | |
16da7c01 | 144 | $alignbytes = '4'; |
396e9e6f | 145 | $cstflags = 0; |
146 | } | |
16da7c01 LH |
147 | print OUT "obj_ext='$objext'\n"; |
148 | print OUT "alignbytes='$alignbytes'\n"; | |
396e9e6f | 149 | print OUT "castflags='$cstflags'\n"; |
150 | ||
151 | $myname = $ENV{'site'} ; | |
152 | ($myhostname,$mydomain) = split(/\./,$myname,2); | |
153 | print OUT "myhostname='$myhostname'\n" if $myhostname; | |
154 | if ($mydomain) { | |
155 | print OUT "mydomain='.$mydomain'\n"; | |
156 | print OUT "perladmin='$cf_by\@$myhostname.$mydomain'\n"; | |
157 | print OUT "cf_email='$cf_by\@$myhostname.$mydomain'\n"; | |
158 | } | |
159 | else { | |
160 | print OUT "perladmin='$cf_by'\n"; | |
161 | print OUT "cf_email='$cf_by'\n"; | |
162 | } | |
163 | print OUT "myuname='Plan9 $myname $osvers $p9p_objtype'\n"; | |
164 | ||
165 | # Before we read the C header file, find out what config.sh constants are | |
166 | # equivalent to the C preprocessor macros | |
167 | if (open(SH,"${outdir}config_h.SH")) { | |
168 | while (<SH>) { | |
169 | next unless m%^#(?!if).*\$%; | |
170 | s/^#//; s!(.*?)\s*/\*.*!$1!; | |
171 | my(@words) = split; | |
172 | $words[1] =~ s/\(.*//; # Clip off args from macro | |
173 | # Did we use a shell variable for the preprocessor directive? | |
174 | if ($words[0] =~ m!^\$(\w+)!) { $pp_vars{$words[1]} = $1; } | |
175 | if (@words > 2) { # We may also have a shell var in the value | |
176 | shift @words; # Discard preprocessor directive | |
177 | my($token) = shift @words; # and keep constant name | |
178 | my($word); | |
179 | foreach $word (@words) { | |
180 | next unless $word =~ m!\$(\w+)!; | |
181 | $val_vars{$token} = $1; | |
182 | last; | |
183 | } | |
184 | } | |
185 | } | |
186 | close SH; | |
187 | } | |
188 | else { warn "Couldn't read ${outfile}config_h.SH: $!\n"; } | |
189 | $pp_vars{PLAN9} = 'define'; #Plan 9 specific | |
190 | ||
191 | # OK, now read the C header file, and retcon statements into config.sh | |
192 | while (<IN>) { # roll through the comment header in config.h | |
193 | last if /config-start/; | |
194 | } | |
195 | ||
196 | while (<IN>) { | |
197 | chop; | |
198 | while (/\\\s*$/) { # pick up contination lines | |
199 | my $line = $_; | |
200 | $line =~ s/\\\s*$//; | |
201 | $_ = <IN>; | |
202 | s/^\s*//; | |
203 | $_ = $line . $_; | |
204 | } | |
205 | next unless my ($blocked,$un,$token,$val) = | |
206 | m%^(\/\*)?\s*\#\s*(un)?def\w*\s+([A-Za-z0-9]\w+)\S*\s*(.*)%; | |
207 | if (/config-skip/) { | |
208 | delete $pp_vars{$token} if exists $pp_vars{$token}; | |
209 | delete $val_vars{$token} if exists $val_vars{$token}; | |
210 | next; | |
211 | } | |
212 | $val =~ s!\s*/\*.*!!; # strip off trailing comment | |
213 | my($had_val); # Maybe a macro with args that we just #undefd or commented | |
214 | if (!length($val) and $val_vars{$token} and ($un || $blocked)) { | |
215 | print OUT "$val_vars{$token}=''\n"; | |
216 | delete $val_vars{$token}; | |
217 | $had_val = 1; | |
218 | } | |
219 | $state = ($blocked || $un) ? 'undef' : 'define'; | |
220 | if ($pp_vars{$token}) { | |
221 | print OUT "$pp_vars{$token}='$state'\n"; | |
222 | delete $pp_vars{$token}; | |
223 | } | |
224 | elsif (not length $val and not $had_val) { | |
225 | # Wups -- should have been shell var for C preprocessor directive | |
226 | warn "Constant $token not found in config_h.SH\n"; | |
227 | $token =~ tr/A-Z/a-z/; | |
228 | $token = "d_$token" unless $token =~ /^i_/; | |
229 | print OUT "$token='$state'\n"; | |
230 | } | |
231 | next unless length $val; | |
232 | $val =~ s/^"//; $val =~ s/"$//; # remove end quotes | |
233 | $val =~ s/","/ /g; # make signal list look nice | |
234 | ||
235 | if ($val_vars{$token}) { | |
236 | print OUT "$val_vars{$token}='$val'\n"; | |
237 | if ($val_vars{$token} =~ s/exp$//) {print OUT "$val_vars{$token}='$val'\n";} | |
238 | delete $val_vars{$token}; | |
239 | } | |
240 | elsif (!$pp_vars{$token}) { # Haven't seen it previously, either | |
241 | warn "Constant $token not found in config_h.SH (val=|$val|)\n"; | |
242 | $token =~ tr/A-Z/a-z/; | |
243 | print OUT "$token='$val'\n"; | |
244 | if ($token =~ s/exp$//) {print OUT "$token='$val'\n";} | |
245 | } | |
246 | } | |
247 | close IN; | |
248 | ||
249 | foreach (sort keys %pp_vars) { | |
250 | warn "Didn't see $_ in $infile\n"; | |
251 | } | |
252 | foreach (sort keys %val_vars) { | |
253 | warn "Didn't see $_ in $infile(val)\n"; | |
254 | } | |
255 | ||
256 | ||
257 | # print OUT "libs='",join(' ',@libs),"'\n"; | |
258 | # print OUT "libc='",join(' ',@crtls),"'\n"; | |
259 | ||
260 | if (open(PL,"${outdir}patchlevel.h")) { | |
261 | while (<PL>) { | |
262 | if (/^#define PATCHLEVEL\s+(\S+)/) { print OUT "PATCHLEVEL='$1'\n"; } | |
263 | elsif (/^#define SUBVERSION\s+(\S+)/) { print OUT "SUBVERSION='$1'\n"; } | |
264 | } | |
265 | close PL; | |
266 | } | |
267 | else { warn "Can't read ${outdir}patchlevel.h - skipping 'PATCHLEVEL'"; } | |
268 | ||
269 | print OUT "pager='/bin/p'\n"; | |
270 | ||
271 | close OUT; | |
272 | ||
273 |