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