home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / lib / perl5 / Config.pm < prev    next >
Text File  |  1997-03-29  |  12KB  |  584 lines

  1. package Config;
  2. require Exporter;
  3. @ISA = (Exporter);
  4. @EXPORT = qw(%Config);
  5.  
  6. $] == 5.001 or die sprintf
  7.     "Perl lib version (5.001) doesn't match executable version (%.3f)\n", $];
  8.  
  9. # This file was created by configpm when Perl was built. Any changes
  10. # made to this file will be lost the next time perl is built.
  11.  
  12. =head1 NAME
  13.  
  14. Config - access Perl configuration option
  15.  
  16. =head1 SYNOPSIS
  17.  
  18.     use Config;
  19.     if ($Config{'cc'} =~ /gcc/) {
  20.     print "built by gcc\n";
  21.     } 
  22.  
  23. =head1 DESCRIPTION
  24.  
  25. The Config module contains everything that was available to the
  26. C<Configure> program at Perl build time.  Shell variables from
  27. F<config.sh> are stored in the readonly-variable C<%Config>, indexed by
  28. their names.
  29.  
  30. =head1 EXAMPLE
  31.  
  32. Here's a more sophisticated example of using %Config:
  33.  
  34.     use Config;
  35.  
  36.     defined $Config{sig_name} || die "No sigs?";
  37.     foreach $name (split(' ', $Config{sig_name})) {
  38.     $signo{$name} = $i;
  39.     $signame[$i] = $name;
  40.     $i++;
  41.     }   
  42.  
  43.     print "signal #17 = $signame[17]\n";
  44.     if ($signo{ALRM}) { 
  45.     print "SIGALRM is $signo{ALRM}\n";
  46.     }   
  47.  
  48. =head1 NOTE
  49.  
  50. This module contains a good example of how to make a variable
  51. readonly to those outside of it.  
  52.  
  53. =cut
  54.  
  55. ##
  56. ## This file was produced by running the Configure script. It holds all the
  57. ## definitions figured out by Configure. Should you modify one of these values,
  58. ## do not forget to propagate your changes by running "Configure -der". You may
  59. ## instead choose to run each of the .SH files by yourself, or "Configure -S".
  60. ##
  61. #
  62. ## Configuration time: Wed Dec  6 17:18:21 PST 1995
  63. ## Configured by: gvdl
  64. ## Target system: kiwi 
  65. #
  66. ## Variables propagated from previous config.sh file.
  67.  
  68. $config_sh=<<'!END!OF!CONFIG!';
  69. archlib='/usr/lib/perl5'
  70. ccflags='-dynamic -fno-common -DUSE_NEXT_CTYPE'
  71. cppflags='-dynamic -fno-common -DUSE_NEXT_CTYPE'
  72. dynamic_ext='Fcntl NDBM_File ODBM_File SDBM_File Socket'
  73. extensions='Fcntl NDBM_File ODBM_File SDBM_File Socket'
  74. intsize='4'
  75. libpth='/lib /usr/lib'
  76. osname='next'
  77. osvers='4_0'
  78. sharpbang='#!'
  79. shsharp='true'
  80. sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH LOST USR1 USR2'
  81. so='dylib'
  82. startsh='#!/bin/sh'
  83. static_ext=' '
  84. Author=''
  85. CONFIG='true'
  86. Date='$Date'
  87. Header=''
  88. Id='$Id'
  89. Locker=''
  90. Log='$Log'
  91. Mcc='Mcc'
  92. PATCHLEVEL='1'
  93. RCSfile='$RCSfile'
  94. Revision='$Revision'
  95. Source=''
  96. State=''
  97. afs='false'
  98. alignbytes='8'
  99. altmake='gnumake'
  100. aphostname=''
  101. archlibexp='/usr/lib/perl5'
  102. archname='none'
  103. awk='awk'
  104. baserev='5.0'
  105. bash=''
  106. bin='/usr/bin'
  107. binexp='/usr/bin'
  108. bison=''
  109. byacc='byacc'
  110. byteorder='4321'
  111. c=''
  112. castflags='0'
  113. cat='cat'
  114. cc='cc'
  115. cccdlflags=' '
  116. ccdlflags=' '
  117. cf_by='gvdl'
  118. cf_time='Wed Dec  6 17:18:21 PST 1995'
  119. chgrp=''
  120. chmod=''
  121. chown=''
  122. clocktype='int'
  123. comm='comm'
  124. compress=''
  125. contains='grep'
  126. cp='cp'
  127. cpio=''
  128. cpp='cpp'
  129. cpp_stuff='42'
  130. cpplast='-'
  131. cppminus='-'
  132. cpprun='cc -E'
  133. cppstdin='cc -E'
  134. cryptlib=''
  135. csh='csh'
  136. d_Gconvert='gcvt((x),(n),(b))'
  137. d_access='define'
  138. d_alarm='define'
  139. d_archlib='undef'
  140. d_attribut='define'
  141. d_bcmp='define'
  142. d_bcopy='define'
  143. d_bsd='undef'
  144. d_bsdpgrp='define'
  145. d_bzero='define'
  146. d_casti32='define'
  147. d_castneg='define'
  148. d_charvspr='undef'
  149. d_chown='define'
  150. d_chroot='define'
  151. d_chsize='undef'
  152. d_closedir='define'
  153. d_const='define'
  154. d_crypt='define'
  155. d_csh='define'
  156. d_cuserid='undef'
  157. d_dbl_dig='define'
  158. d_difftime='define'
  159. d_dirnamlen='undef'
  160. d_dlerror='undef'
  161. d_dlopen='undef'
  162. d_dlsymun='undef'
  163. d_dosuid='undef'
  164. d_dup2='define'
  165. d_eunice='undef'
  166. d_fchmod='define'
  167. d_fchown='define'
  168. d_fcntl='define'
  169. d_fd_macros='define'
  170. d_fd_set='define'
  171. d_fds_bits='undef'
  172. d_fgetpos='define'
  173. d_flexfnam='define'
  174. d_flock='define'
  175. d_fork='define'
  176. d_fpathconf='undef'
  177. d_fsetpos='define'
  178. d_getgrps='define'
  179. d_gethent='define'
  180. d_gethname='undef'
  181. d_getlogin='define'
  182. d_getpgrp2='undef'
  183. d_getpgrp='define'
  184. d_getppid='define'
  185. d_getprior='define'
  186. d_htonl='define'
  187. d_index='undef'
  188. d_isascii='define'
  189. d_killpg='define'
  190. d_link='define'
  191. d_locconv='define'
  192. d_lockf='define'
  193. d_lstat='define'
  194. d_mblen='define'
  195. d_mbstowcs='define'
  196. d_mbtowc='define'
  197. d_memcmp='define'
  198. d_memcpy='define'
  199. d_memmove='define'
  200. d_memset='define'
  201. d_mkdir='define'
  202. d_mkfifo='undef'
  203. d_mktime='define'
  204. d_msg='undef'
  205. d_msgctl='undef'
  206. d_msgget='undef'
  207. d_msgrcv='undef'
  208. d_msgsnd='undef'
  209. d_mymalloc='undef'
  210. d_nice='define'
  211. d_oldsock='undef'
  212. d_open3='define'
  213. d_pathconf='undef'
  214. d_pause='define'
  215. d_phostname='undef'
  216. d_pipe='define'
  217. d_portable='define'
  218. d_pwage='undef'
  219. d_pwchange='undef'
  220. d_pwclass='undef'
  221. d_pwcomment='define'
  222. d_pwexpire='undef'
  223. d_pwquota='define'
  224. d_readdir='define'
  225. d_readlink='define'
  226. d_rename='define'
  227. d_rewinddir='undef'
  228. d_rmdir='define'
  229. d_safebcpy='define'
  230. d_safemcpy='define'
  231. d_seekdir='define'
  232. d_select='define'
  233. d_sem='undef'
  234. d_semctl='undef'
  235. d_semget='undef'
  236. d_semop='undef'
  237. d_setegid='define'
  238. d_seteuid='define'
  239. d_setlinebuf='define'
  240. d_setlocale='define'
  241. d_setpgid='undef'
  242. d_setpgrp2='undef'
  243. d_setpgrp='define'
  244. d_setprior='define'
  245. d_setregid='define'
  246. d_setresgid='undef'
  247. d_setresuid='undef'
  248. d_setreuid='define'
  249. d_setrgid='define'
  250. d_setruid='define'
  251. d_setsid='undef'
  252. d_shm='undef'
  253. d_shmat='undef'
  254. d_shmatprototype='undef'
  255. d_shmctl='undef'
  256. d_shmdt='undef'
  257. d_shmget='undef'
  258. d_shrplib='define'
  259. d_sitelib='undef'
  260. d_socket='define'
  261. d_sockpair='define'
  262. d_statblks='define'
  263. d_stdio_cnt_lval='define'
  264. d_stdio_ptr_lval='define'
  265. d_stdiobase='define'
  266. d_stdstdio='define'
  267. d_strchr='define'
  268. d_strcoll='undef'
  269. d_strctcpy='define'
  270. d_strerrm='strerror(e)'
  271. d_strerror='define'
  272. d_strxfrm='undef'
  273. d_suidsafe='undef'
  274. d_symlink='define'
  275. d_syscall='define'
  276. d_sysconf='undef'
  277. d_sysernlst=''
  278. d_syserrlst='define'
  279. d_system='define'
  280. d_tcgetpgrp='undef'
  281. d_tcsetpgrp='undef'
  282. d_telldir='define'
  283. d_time='define'
  284. d_times='define'
  285. d_truncate='define'
  286. d_tzname='define'
  287. d_umask='define'
  288. d_uname='undef'
  289. d_vfork='undef'
  290. d_void_closedir='undef'
  291. d_voidsig='define'
  292. d_voidtty=''
  293. d_volatile='define'
  294. d_vprintf='define'
  295. d_wait4='define'
  296. d_waitpid='undef'
  297. d_wcstombs='define'
  298. d_wctomb='define'
  299. d_xenix='undef'
  300. date='date'
  301. db_hashtype='int'
  302. db_prefixtype='int'
  303. defvoidused='15'
  304. direntrytype='struct direct'
  305. dlext='bundle'
  306. dlsrc='dl_next.xs'
  307. echo='echo'
  308. egrep='egrep'
  309. emacs=''
  310. eunicefix=':'
  311. expr='expr'
  312. find='find'
  313. flex=''
  314. fpostype='fpos_t'
  315. freetype='void'
  316. full_csh='/bin/csh'
  317. full_sed='/bin/sed'
  318. gcc=''
  319. gccversion='NeXT DevKit-based CPP 4.0'
  320. gidtype='gid_t'
  321. glibpth='/usr/shlib  /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/local/lib '
  322. grep='grep'
  323. groupcat=''
  324. groupstype='int'
  325. h_fcntl='false'
  326. h_sysfile='true'
  327. hint='recommended'
  328. hostcat='nidump hosts .'
  329. huge=''
  330. i_bsdioctl=''
  331. i_db='undef'
  332. i_dbm='define'
  333. i_dirent='define'
  334. i_dld='undef'
  335. i_dlfcn='undef'
  336. i_fcntl='undef'
  337. i_float='define'
  338. i_gdbm='undef'
  339. i_grp='define'
  340. i_limits='define'
  341. i_malloc='undef'
  342. i_math='define'
  343. i_memory='undef'
  344. i_ndbm='define'
  345. i_neterrno='undef'
  346. i_niin='define'
  347. i_pwd='define'
  348. i_sgtty='define'
  349. i_stdarg='define'
  350. i_stddef='define'
  351. i_stdlib='define'
  352. i_string='define'
  353. i_sysdir='define'
  354. i_sysfile='define'
  355. i_sysfilio='undef'
  356. i_sysin='undef'
  357. i_sysioctl='define'
  358. i_sysndir='undef'
  359. i_sysparam='define'
  360. i_sysselct='undef'
  361. i_syssockio=''
  362. i_sysstat='define'
  363. i_systime='define'
  364. i_systimek='undef'
  365. i_systimes='define'
  366. i_systypes='define'
  367. i_termio='undef'
  368. i_termios='undef'
  369. i_time='undef'
  370. i_unistd='define'
  371. i_utime='undef'
  372. i_varargs='undef'
  373. i_varhdr='stdarg.h'
  374. i_vfork='undef'
  375. incpath=''
  376. inews=''
  377. installarchlib='/usr/lib/perl5'
  378. installbin='/usr/bin'
  379. installman1dir='/usr/man/man1'
  380. installman3dir='/usr/lib/perl5/man/man3'
  381. installprivlib='/usr/lib/perl5'
  382. installscript='/usr/bin'
  383. installsitelib=''
  384. isnext_4='define'
  385. known_extensions='DB_File Fcntl GDBM_File NDBM_File ODBM_File POSIX SDBM_File Socket'
  386. ksh=''
  387. large=''
  388. ld='cc'
  389. lddlflags='-dynamic -bundle -undefined suppress'
  390. ldflags='-dynamic -prebind'
  391. less=''
  392. libc='/NextLibrary/Frameworks/System.framework/System'
  393. libs=' '
  394. libswanted=' '
  395. line='line'
  396. lint=''
  397. lkflags=''
  398. ln='ln'
  399. lns='/bin/ln -s'
  400. lp=''
  401. lpr=''
  402. ls='ls'
  403. lseektype='off_t'
  404. mab='-arch m68k -arch i386 -arch sparc'
  405. mail=''
  406. mailx=''
  407. make=''
  408. mallocobj=''
  409. mallocsrc=''
  410. malloctype='void *'
  411. man1dir='/usr/man/man1'
  412. man1direxp='/usr/man/man1'
  413. man1ext='1'
  414. man3dir='/usr/lib/perl5/man/man3'
  415. man3direxp='/usr/lib/perl5/man/man3'
  416. man3ext='3'
  417. medium=''
  418. mips=''
  419. mips_type=''
  420. mkdir='mkdir'
  421. models='none'
  422. modetype='int'
  423. more=''
  424. mv=''
  425. myarchname='hppa-next'
  426. mydomain=''
  427. myhostname='kiwi'
  428. myuname='kiwi '
  429. n='-n'
  430. nm_opt=''
  431. nroff='nroff'
  432. optimize='-g -O'
  433. orderlib='false'
  434. package='perl5'
  435. passcat=''
  436. patchlevel='1'
  437. perl='perl'
  438. pg=''
  439. phostname='hostname'
  440. plibpth=''
  441. pmake=''
  442. pp_cflags='optimize="-g"'
  443. pr=''
  444. prefix='/usr'
  445. prefixexp='/usr'
  446. privlib='/usr/lib/perl5'
  447. privlibexp='/usr/lib/perl5'
  448. prototype='define'
  449. randbits='31'
  450. ranlib='sleep 5; /bin/ranlib'
  451. rm='rm'
  452. rmail=''
  453. runnm='true'
  454. scriptdir='/usr/bin'
  455. scriptdirexp='/usr/bin'
  456. sed='sed'
  457. selecttype='fd_set *'
  458. sendmail=''
  459. sh=''
  460. shar=''
  461. shmattype=''
  462. shrpdir='/usr/lib/perl5/CORE'
  463. signal_t='void'
  464. sitelib=''
  465. sitelibexp=''
  466. sizetype='size_t'
  467. sleep=''
  468. smail=''
  469. small=''
  470. sockethdr=''
  471. socketlib=''
  472. sort='sort'
  473. spackage='Perl5'
  474. spitshell='cat'
  475. split=''
  476. ssizetype='int'
  477. stdchar='char'
  478. stdio_base='((fp)->_base)'
  479. stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)'
  480. stdio_cnt='((fp)->_cnt)'
  481. stdio_ptr='((fp)->_ptr)'
  482. strings='/NextDeveloper/Headers/ansi/string.h'
  483. submit=''
  484. sysman='/usr/man/man1'
  485. tail=''
  486. tar=''
  487. tbl=''
  488. test='test'
  489. timeincl='/NextDeveloper/Headers/bsd/sys/time.h '
  490. timetype='time_t'
  491. touch='touch'
  492. tr='tr'
  493. troff=''
  494. uidtype='uid_t'
  495. uname='uname'
  496. uniq='uniq'
  497. usedl='define'
  498. usemymalloc='n'
  499. usenm='true'
  500. useposix='undef'
  501. usevfork='false'
  502. usrinc='/usr/include'
  503. uuname=''
  504. vi=''
  505. voidflags='15'
  506. xlibpth='/usr/lib/386 /lib/386'
  507. zcat=''
  508. !END!OF!CONFIG!
  509.  
  510.  
  511. tie %Config, Config;
  512. sub TIEHASH { bless {} }
  513. sub FETCH { 
  514.     # check for cached value (which maybe undef so we use exists not defined)
  515.     return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]});
  516.  
  517.     my($value); # search for the item in the big $config_sh string
  518.     return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m);
  519.  
  520.     $value = undef if $value eq 'undef'; # So we can say "if $Config{'foo'}".
  521.     $_[0]->{$_[1]} = $value; # cache it
  522.     return $value;
  523. }
  524.  
  525. sub FIRSTKEY {
  526.     $prevpos = 0;
  527.     my $key;
  528.     ($key) = $config_sh =~ m/^(.*)=/;
  529.     $key;
  530. }
  531.  
  532. sub NEXTKEY {
  533.     my ($pos, $len);
  534.     $pos = $prevpos;
  535.     $pos = index( $config_sh, "\n", $pos) + 1;
  536.     $prevpos = $pos;
  537.     $len = index( $config_sh, "=", $pos) - $pos;
  538.     $len > 0 ? substr( $config_sh, $pos, $len) : undef;
  539. }
  540.  
  541. sub EXISTS{ 
  542.      exists($_[0]->{$_[1]})  or  $config_sh =~ m/^$_[1]=/m; 
  543. }
  544.  
  545. sub readonly { die "\%Config::Config is read-only\n" }
  546.  
  547. sub myconfig {
  548.     my($output);
  549.     
  550.     $output = <<'END';
  551. Summary of my $package (patchlevel $PATCHLEVEL) configuration:
  552.   Platform:
  553.     osname=$osname, osver=$osvers, archname=$archname
  554.     uname='$myuname'
  555.     hint=$hint
  556.   Compiler:
  557.     cc='$cc', optimize='$optimize'
  558.     cppflags='$cppflags'
  559.     ccflags ='$ccflags'
  560.     ldflags ='$ldflags'
  561.     stdchar='$stdchar', d_stdstdio=$d_stdstdio, usevfork=$usevfork
  562.     voidflags=$voidflags, castflags=$castflags, d_casti32=$d_casti32, d_castneg=$d_castneg
  563.     intsize=$intsize, alignbytes=$alignbytes, usemymalloc=$usemymalloc, randbits=$randbits
  564.   Libraries:
  565.     so=$so
  566.     libpth=$libpth
  567.     libs=$libs
  568.     libc=$libc
  569.   Dynamic Linking:
  570.     dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun
  571.     cccdlflags='$cccdlflags', ccdlflags='$ccdlflags', lddlflags='$lddlflags'
  572.  
  573. END
  574.     $output =~ s/\$(\w+)/$Config{$1}/ge;
  575.     $output;
  576. }
  577.  
  578. sub STORE { &readonly }
  579. sub DELETE{ &readonly }
  580. sub CLEAR { &readonly }
  581.  
  582.  
  583. 1;
  584.