1*0Sstevel@tonic-gatecase $PERL_CONFIG_SH in 2*0Sstevel@tonic-gate'') 3*0Sstevel@tonic-gate if test -f config.sh; then TOP=.; 4*0Sstevel@tonic-gate elif test -f ../config.sh; then TOP=..; 5*0Sstevel@tonic-gate elif test -f ../../config.sh; then TOP=../..; 6*0Sstevel@tonic-gate elif test -f ../../../config.sh; then TOP=../../..; 7*0Sstevel@tonic-gate elif test -f ../../../../config.sh; then TOP=../../../..; 8*0Sstevel@tonic-gate else 9*0Sstevel@tonic-gate echo "Can't find config.sh."; exit 1 10*0Sstevel@tonic-gate fi 11*0Sstevel@tonic-gate . $TOP/config.sh 12*0Sstevel@tonic-gate ;; 13*0Sstevel@tonic-gateesac 14*0Sstevel@tonic-gate: This forces SH files to create target in same directory as SH file. 15*0Sstevel@tonic-gate: This is so that make depend always knows where to find SH derivatives. 16*0Sstevel@tonic-gatecase "$0" in 17*0Sstevel@tonic-gate*/*) cd `expr X$0 : 'X\(.*\)/'` ;; 18*0Sstevel@tonic-gateesac 19*0Sstevel@tonic-gateecho "Extracting writemain (with variable substitutions)" 20*0Sstevel@tonic-gate: This section of the file will have variable substitutions done on it. 21*0Sstevel@tonic-gate: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. 22*0Sstevel@tonic-gate: Protect any dollar signs and backticks that you do not want interpreted 23*0Sstevel@tonic-gate: by putting a backslash in front. You may delete these comments. 24*0Sstevel@tonic-gaterm -f writemain 25*0Sstevel@tonic-gate$spitshell >writemain <<!GROK!THIS! 26*0Sstevel@tonic-gate$startsh 27*0Sstevel@tonic-gate!GROK!THIS! 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate: In the following dollars and backticks do not need the extra backslash. 30*0Sstevel@tonic-gate$spitshell >>writemain <<'!NO!SUBS!' 31*0Sstevel@tonic-gate# This script takes the plain miniperlmain.c and writes out perlmain.c 32*0Sstevel@tonic-gate# which includes all the extensions. 33*0Sstevel@tonic-gate# The command line arguments name extensions to be used. 34*0Sstevel@tonic-gate# E.g.: sh writemain SDBM_File POSIX > perlmain.c 35*0Sstevel@tonic-gate# 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gateorig="$*" 38*0Sstevel@tonic-gateargs='' 39*0Sstevel@tonic-gate: Remove any .a suffixes and any leading path components 40*0Sstevel@tonic-gatefor file in $orig ; do 41*0Sstevel@tonic-gate case "$file" in 42*0Sstevel@tonic-gate *.a) file=`echo $file | sed 's/\.a//g'` 43*0Sstevel@tonic-gate ;; 44*0Sstevel@tonic-gate esac 45*0Sstevel@tonic-gate case "$file" in 46*0Sstevel@tonic-gate ext/*) file=`echo $file | sed 's:ext/\(.*\)/[^/]*:\1:'` 47*0Sstevel@tonic-gate ;; 48*0Sstevel@tonic-gate lib/auto/*) file=`echo $file | sed 's:lib/auto/\(.*\)/[^/]*:\1:'` 49*0Sstevel@tonic-gate ;; 50*0Sstevel@tonic-gate */*) 51*0Sstevel@tonic-gate file=`expr X$file : 'X.*/\(.*\)'` 52*0Sstevel@tonic-gate ;; 53*0Sstevel@tonic-gate esac 54*0Sstevel@tonic-gate args="$args $file" 55*0Sstevel@tonic-gatedone 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gatesed '/Do not delete this line--writemain depends on it/q' miniperlmain.c 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gateif test X"$args" != "X" ; then 62*0Sstevel@tonic-gate for ext in $args ; do 63*0Sstevel@tonic-gate: $ext will either be 'Name' or 'Name1/Name2' etc 64*0Sstevel@tonic-gate: convert ext into cname and mname 65*0Sstevel@tonic-gatemname=`echo $ext | sed 's!/!::!g'` 66*0Sstevel@tonic-gatecname=`echo $mname | sed 's!:!_!g'` 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gateecho "EXTERN_C void boot_${cname} (pTHX_ CV* cv);" 69*0Sstevel@tonic-gate done 70*0Sstevel@tonic-gatefi 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gatecat << 'EOP' 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gatestatic void 75*0Sstevel@tonic-gatexs_init(pTHX) 76*0Sstevel@tonic-gate{ 77*0Sstevel@tonic-gateEOP 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gateif test X"$args" != "X" ; then 80*0Sstevel@tonic-gate echo " char *file = __FILE__;" 81*0Sstevel@tonic-gate echo " dXSUB_SYS;" 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate ai='' 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate for ext in $args ; do 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate : $ext will either be 'Name' or 'Name1/Name2' etc 88*0Sstevel@tonic-gate : convert ext into cname and mname 89*0Sstevel@tonic-gate mname=`echo $ext | sed 's!/!::!g'` 90*0Sstevel@tonic-gate cname=`echo $mname | sed 's!:!_!g'` 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate if test "$ext" = "DynaLoader"; then 93*0Sstevel@tonic-gate : Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'! 94*0Sstevel@tonic-gate : boot_DynaLoader is called directly in DynaLoader.pm 95*0Sstevel@tonic-gate echo " newXS(\"${mname}::boot_${ext}\", boot_${cname}, file);" 96*0Sstevel@tonic-gate else 97*0Sstevel@tonic-gate echo " newXS(\"${mname}::bootstrap\", boot_${cname}, file);" 98*0Sstevel@tonic-gate fi 99*0Sstevel@tonic-gate done 100*0Sstevel@tonic-gatefi 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gatecat << 'EOP' 103*0Sstevel@tonic-gate} 104*0Sstevel@tonic-gateEOP 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate!NO!SUBS! 107*0Sstevel@tonic-gatechmod 755 writemain 108*0Sstevel@tonic-gate$eunicefix writemain 109