home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl501m.zip / lib / Config.pm < prev    next >
Text File  |  1995-07-04  |  11KB  |  569 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: Sat Dec 10 13:00:00 CET 1994
  63. ## Configured by: ak
  64. ## Target system: OS/2 2.11 - EMX 0.9
  65. #
  66. #
  67. ## AK's extensions
  68. #
  69.  
  70. $config_sh=<<'!END!OF!CONFIG!';
  71. dynamic_ext='Fcntl GDBM_File SDBM_File POSIX Socket OS2::UPM OS2::REXX OS2::FTP'
  72. extensions='Fcntl GDBM_File SDBM_File POSIX Socket OS2::UPM OS2::REXX OS2::FTP'
  73. static_ext=''
  74. osname='OS/2'
  75. osvers='2.11'
  76. archlib='c:/usr/lib/perl5/os2'
  77. ccflags='-Zomf'
  78. cppflags='-DDOSISH -DOS2=2 -DEMBED -I. -Ios2'
  79. intsize='4'
  80. libpth='c:/usr/lib/emx h:/emx/lib'
  81. sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM USR1 USR2 CHLD 19 20 BREAK'
  82. so='dll'
  83. sharpbang='extproc '
  84. shsharp='false'
  85. startsh='extproc ksh\\n#! sh'
  86. Author=''
  87. CONFIG='true'
  88. Date='$Date'
  89. Header=''
  90. Id='$Id'
  91. Locker=''
  92. Log='$Log'
  93. Mcc='Mcc'
  94. PATCHLEVEL='0'
  95. RCSfile='$RCSfile'
  96. Revision='$Revision'
  97. Source=''
  98. State=''
  99. afs='false'
  100. alignbytes='8'
  101. aphostname=''
  102. archlibexp='c:/usr/lib/perl5/os2'
  103. archname='os2'
  104. awk='awk'
  105. bash=''
  106. bin='c:/usr/binp'
  107. binexp='c:/usr/binp'
  108. bison='bison'
  109. byacc=''
  110. byteorder='1234'
  111. c='\c'
  112. castflags='0'
  113. cat='cat'
  114. cc='gcc'
  115. cccdlflags='-Zdll'
  116. ccdlflags=''
  117. cf_by='src'
  118. cf_time='Sat Dec 10 13:00:00 CET 1994'
  119. chgrp=''
  120. chmod=''
  121. chown=''
  122. clocktype='clock_t'
  123. compress='compress'
  124. contains='grep'
  125. cp='cp'
  126. cpio='cpio'
  127. cpp='cpp'
  128. cpp_stuff='42'
  129. cpplast=''
  130. cppminus=''
  131. cpprun='cpp'
  132. cppstdin='cpp'
  133. cryptlib=''
  134. csh=''
  135. d_Gconvert='sprintf((b),"%.*g",(n),(x))'
  136. d_access='define'
  137. d_alarm='define'
  138. d_archlib='define'
  139. d_attrib='define'
  140. d_attribut='define'
  141. d_bcmp='define'
  142. d_bcopy='define'
  143. d_bsdpgrp='undef'
  144. d_bzero='define'
  145. d_casti32='define'
  146. d_castneg='define'
  147. d_charsprf='undef'
  148. d_charvspr='undef'
  149. d_chown='undef'
  150. d_chroot='undef'
  151. d_chsize='define'
  152. d_closedir='define'
  153. d_const='define'
  154. d_crypt='undef'
  155. d_csh='undef'
  156. d_cuserid='define'
  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_drem='undef'
  165. d_dup2='define'
  166. d_eunice='undef'
  167. d_fchmod='undef'
  168. d_fchown='undef'
  169. d_fcntl='define'
  170. d_fd_macros='define'
  171. d_fd_set='define'
  172. d_fds_bits='define'
  173. d_fgetpos='define'
  174. d_flexfnam='define'
  175. d_flock='define'
  176. d_fmod='define'
  177. d_fork='undef'
  178. d_fpathconf='define'
  179. d_fsetpos='define'
  180. d_getgrps='undef'
  181. d_gethent='define'
  182. d_gethname='undef'
  183. d_getlogin='define'
  184. d_getpgrp2='undef'
  185. d_getpgrp='undef'
  186. d_getppid='define'
  187. d_getprior='define'
  188. d_group='undef'
  189. d_htonl='define'
  190. d_index='undef'
  191. d_isascii='define'
  192. d_killpg='undef'
  193. d_link='undef'
  194. d_linuxstd='undef'
  195. d_locconv='define'
  196. d_lockf='undef'
  197. d_lstat='undef'
  198. d_mblen='define'
  199. d_mbstowcs='define'
  200. d_mbtowc='define'
  201. d_memcmp='define'
  202. d_memcpy='define'
  203. d_memmove='define'
  204. d_memset='define'
  205. d_mkdir='define'
  206. d_mkfifo='undef'
  207. d_mktime='define'
  208. d_msg='undef'
  209. d_msgctl='undef'
  210. d_msgget='undef'
  211. d_msgrcv='undef'
  212. d_msgsnd='undef'
  213. d_mymalloc='define'
  214. d_nice='undef'
  215. d_oldsock='undef'
  216. d_open3='define'
  217. d_passwd='undef'
  218. d_pathconf='define'
  219. d_pause='define'
  220. d_phostname='undef'
  221. d_pipe='define'
  222. d_portable='define'
  223. d_pwage='undef'
  224. d_pwchange='undef'
  225. d_pwclass='undef'
  226. d_pwcomment='undef'
  227. d_pwexpire='undef'
  228. d_pwquota='undef'
  229. d_readdir='define'
  230. d_readlink='undef'
  231. d_rename='define'
  232. d_rewinddir='define'
  233. d_rmdir='define'
  234. d_safebcpy='undef'
  235. d_safemcpy='undef'
  236. d_seekdir='define'
  237. d_select='define'
  238. d_sem='undef'
  239. d_semctl='undef'
  240. d_semget='undef'
  241. d_semop='undef'
  242. d_setegid='undef'
  243. d_seteuid='undef'
  244. d_setlinebuf='undef'
  245. d_setlocale='define'
  246. d_setpgid='undef'
  247. d_setpgrp2='undef'
  248. d_setpgrp='undef'
  249. d_setprior='define'
  250. d_setregid='undef'
  251. d_setresgid='undef'
  252. d_setresuid='undef'
  253. d_setreuid='undef'
  254. d_setrgid='undef'
  255. d_setruid='undef'
  256. d_setsid='undef'
  257. d_shm='undef'
  258. d_shmat='undef'
  259. d_shmatprototype='undef'
  260. d_shmctl='undef'
  261. d_shmdt='undef'
  262. d_shmget='undef'
  263. d_sitelib='undef'
  264. d_socket='define'
  265. d_sockpair='undef'
  266. d_statblks='undef'
  267. d_stdiobase='undef'
  268. d_stdstdio='undef'
  269. d_strchr='define'
  270. d_strcoll='define'
  271. d_strctcpy='define'
  272. d_strerrm='strerror(e)'
  273. d_strerror='define'
  274. d_strxfrm='define'
  275. d_suidsafe='undef'
  276. d_symlink='undef'
  277. d_syscall='undef'
  278. d_sysconf='define'
  279. d_sysernlst=''
  280. d_syserrlst='define'
  281. d_system='define'
  282. d_tcgetpgrp='define'
  283. d_tcsetpgrp='define'
  284. d_telldir='define'
  285. d_time='define'
  286. d_times='define'
  287. d_truncate='define'
  288. d_tzname='define'
  289. d_umask='define'
  290. d_uname='define'
  291. d_vfork='undef'
  292. d_void_closedir='define'
  293. d_voidsig='define'
  294. d_voidtty=''
  295. d_volatile='define'
  296. d_vprintf='define'
  297. d_wait4='undef'
  298. d_waitpid='define'
  299. d_wcstombs='define'
  300. d_wctomb='define'
  301. d_xenix='undef'
  302. date=''
  303. defvoidused='15'
  304. direntrytype='struct dirent'
  305. dirsep='\'
  306. dlext='dll'
  307. dlsrc='dl_os2.xs'
  308. echo=''
  309. egrep='egrep'
  310. emacs=''
  311. eunicefix=':'
  312. exeext='.exe'
  313. expr='expr'
  314. find='find'
  315. flex='flex'
  316. fpostype='fpos_t'
  317. freetype='void'
  318. gcc='gcc'
  319. gccversion='2.6.3'
  320. gidtype='gid_t'
  321. glibpth='c:/usr/lib/emx h:/emx/lib'
  322. grep='grep'
  323. groupcat=''
  324. groupstype='gid_t'
  325. h_fcntl='true'
  326. h_sysfile='true'
  327. hint='recommended'
  328. hostcat=''
  329. huge=''
  330. i_bsdioctl=''
  331. i_db='undef'
  332. i_dbm='undef'
  333. i_dirent='define'
  334. i_dld='undef'
  335. i_dlfcn='undef'
  336. i_fcntl='define'
  337. i_float='define'
  338. i_gdbm='define'
  339. i_grp='undef'
  340. i_limits='define'
  341. i_malloc='define'
  342. i_math='define'
  343. i_memory='undef'
  344. i_ndbm='undef'
  345. i_neterrno='undef'
  346. i_niin='define'
  347. i_pwd='undef'
  348. i_sgtty='undef'
  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='define'
  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_sysutime='undef'
  368. i_termio='undef'
  369. i_termios='define'
  370. i_time='define'
  371. i_unistd='define'
  372. i_utime='undef'
  373. i_varargs='undef'
  374. i_varhdr='stdarg.h'
  375. i_vfork='undef'
  376. incpath=''
  377. inews=''
  378. installarchlib='c:/usr/lib/perl5/os2'
  379. installbin='c:/usr/binp'
  380. installmansrc='/usr/local/man/man1'
  381. installprivlib=''
  382. installscript=''
  383. known_extensions='DB_File Fcntl GDBM_File NDBM_File ODBM_File POSIX SDBM_File Socket UPM REXXCALL'
  384. ksh=''
  385. large=''
  386. lddlflags='-Zdll'
  387. ldflags='-Zomf'
  388. less=''
  389. libc=''
  390. libs='-lm -lbsd'
  391. libswanted='net socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x'
  392. line=''
  393. lint=''
  394. lkflags=''
  395. ln=''
  396. lns=''
  397. lp=''
  398. lpr=''
  399. ls='ls'
  400. lseektype='off_t'
  401. mail='mail'
  402. mailx=''
  403. make='dmake'
  404. mallocobj=''
  405. mallocsrc=''
  406. malloctype='void *'
  407. manext='1'
  408. mansrc='/usr/local/man/man1'
  409. mansrcexp='/usr/local/man/man1'
  410. medium=''
  411. mips=''
  412. mips_type=''
  413. mkdir='mkdir'
  414. models='none'
  415. modetype='mode_t'
  416. more='more'
  417. mv='mv'
  418. mydomain='s.bawue.de'
  419. myhostname='ananke'
  420. myuname='OS/2 2.11 - EMX 0.9'
  421. n=''
  422. nm_opt='-p'
  423. nroff=''
  424. optimize='-O'
  425. orderlib='false'
  426. package='perl5'
  427. passcat=''
  428. pathsep='\;'
  429. perl='perl5'
  430. pg='pg'
  431. phostname='hostname'
  432. plibpth=''
  433. pmake=''
  434. pr='pr'
  435. prefix='c:/usr'
  436. privlib='c:/local/lib/perl5'
  437. privlibexp='c:/local/lib/perl5'
  438. prototype='define'
  439. randbits='15'
  440. ranlib='ar s'
  441. rm='rm'
  442. rmail=''
  443. runnm='true'
  444. scriptdir='c:/usr/binp'
  445. scriptdirexp='c:/usr/binp'
  446. sed='sed'
  447. selecttype='fd_set *'
  448. sendmail=''
  449. sh=''
  450. shar=''
  451. shmattype=''
  452. signal_t='void'
  453. sizetype='size_t'
  454. sleep='sleep'
  455. smail=''
  456. small=''
  457. sockethdr=''
  458. socketlib='-lsocket'
  459. sort='sort'
  460. spackage=''
  461. spitshell='cat'
  462. split=''
  463. ssizetype='ssize_t'
  464. stdchar='char'
  465. strings='/usr/include/string.h'
  466. submit=''
  467. sysman='/usr/man/man1'
  468. tail=''
  469. tar='tar'
  470. tbl=''
  471. test=''
  472. timeincl=''
  473. timetype='time_t'
  474. touch='touch'
  475. tr=''
  476. troff=''
  477. uidtype='uid_t'
  478. uname=''
  479. uniq=''
  480. usedl='define'
  481. usemymalloc='y'
  482. usenm='true'
  483. useposix='true'
  484. usevfork='false'
  485. usrinc='c:/usr/inc'
  486. uuname=''
  487. vi=''
  488. voidflags='15'
  489. xlibpth=''
  490. yacc='yacc'
  491. yaccflags=''
  492. zcat='zcat'
  493. !END!OF!CONFIG!
  494.  
  495.  
  496. tie %Config, Config;
  497. sub TIEHASH { bless {} }
  498. sub FETCH { 
  499.     # check for cached value (which maybe undef so we use exists not defined)
  500.     return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]});
  501.  
  502.     my($value); # search for the item in the big $config_sh string
  503.     return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m);
  504.  
  505.     $value = undef if $value eq 'undef'; # So we can say "if $Config{'foo'}".
  506.     $_[0]->{$_[1]} = $value; # cache it
  507.     return $value;
  508. }
  509.  
  510. sub FIRSTKEY {
  511.     $prevpos = 0;
  512.     my $key;
  513.     ($key) = $config_sh =~ m/^(.*)=/;
  514.     $key;
  515. }
  516.  
  517. sub NEXTKEY {
  518.     my ($pos, $len);
  519.     $pos = $prevpos;
  520.     $pos = index( $config_sh, "\n", $pos) + 1;
  521.     $prevpos = $pos;
  522.     $len = index( $config_sh, "=", $pos) - $pos;
  523.     $len > 0 ? substr( $config_sh, $pos, $len) : undef;
  524. }
  525.  
  526. sub EXISTS{ 
  527.      exists($_[0]->{$_[1]})  or  $config_sh =~ m/^$_[1]=/m; 
  528. }
  529.  
  530. sub readonly { die "\%Config::Config is read-only\n" }
  531.  
  532. sub myconfig {
  533.     my($output);
  534.     
  535.     $output = <<'END';
  536. Summary of my $package (patchlevel $PATCHLEVEL) configuration:
  537.   Platform:
  538.     osname=$osname, osver=$osvers, archname=$archname
  539.     uname='$myuname'
  540.     hint=$hint
  541.   Compiler:
  542.     cc='$cc', optimize='$optimize'
  543.     cppflags='$cppflags'
  544.     ccflags ='$ccflags'
  545.     ldflags ='$ldflags'
  546.     stdchar='$stdchar', d_stdstdio=$d_stdstdio, usevfork=$usevfork
  547.     voidflags=$voidflags, castflags=$castflags, d_casti32=$d_casti32, d_castneg=$d_castneg
  548.     intsize=$intsize, alignbytes=$alignbytes, usemymalloc=$usemymalloc, randbits=$randbits
  549.   Libraries:
  550.     so=$so
  551.     libpth=$libpth
  552.     libs=$libs
  553.     libc=$libc
  554.   Dynamic Linking:
  555.     dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun
  556.     cccdlflags='$cccdlflags', ccdlflags='$ccdlflags', lddlflags='$lddlflags'
  557.  
  558. END
  559.     $output =~ s/\$(\w+)/$Config{$1}/ge;
  560.     $output;
  561. }
  562.  
  563. sub STORE { &readonly }
  564. sub DELETE{ &readonly }
  565. sub CLEAR { &readonly }
  566.  
  567.  
  568. 1;
  569.