2 case $PERL_CONFIG_SH in
4 if 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 elif test -f ../../../../config.sh; then TOP=../../../..;
10 echo "Can't find config.sh."; exit 1
15 : This forces SH files to create target in same directory as SH file.
16 : This is so that make depend always knows where to find SH derivatives.
18 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
21 echo "Extracting makedepend_file (with variable substitutions)"
23 $spitshell >makedepend_file <<!GROK!THIS!
30 $spitshell >>makedepend_file <<'!NO!SUBS!'
37 case $PERL_CONFIG_SH in
39 if test -f config.sh; then TOP=.;
40 elif test -f ../config.sh; then TOP=..;
41 elif test -f ../../config.sh; then TOP=../..;
42 elif test -f ../../../config.sh; then TOP=../../..;
43 elif test -f ../../../../config.sh; then TOP=../../../..;
45 echo "Can't find config.sh."; exit 1
51 # Avoid localized gcc messages
53 gcc) LC_ALL=C ; export LC_ALL ;;
56 # We need .. when we are in the x2p directory if we are using the
57 # cppstdin wrapper script.
58 # Put .. and . first so that we pick up the present cppstdin, not
59 # an older one lying about in /usr/local/bin.
60 PATH=".$path_sep..$path_sep$PATH"
64 amigaos) cat=/bin/cat ;; # must be absolute
68 os2) uwinfix="-e s,\\\\\\\\,/,g" ;;
69 cygwin) uwinfix="-e s,\\\\\\\\,/,g" ;;
70 posix-bc) uwinfix="-e s/\\*POSIX(\\(.*\\))/\\1/" ;;
71 vos) uwinfix="-e s/\#/\\\#/" ;;
75 *.c) filebase=`basename $file .c` ;;
76 *.y) filebase=`basename $file .y` ;;
79 */*) finc="-I`echo $file | sed 's#/[^/]*$##'`" ;;
82 $echo "Finding dependencies for $filebase$_o"
83 # Below, we strip out all but preprocessor directives.
84 # We have to take care of situations like
85 # #if defined(FOO) BAR /* comment line 1
86 # more comment lines */
87 # If we just delete text starting from the '/*' to the end of line, we will
89 # #if defined(FOO) /* comment */ \
90 # && defined(BAR) /* comment */ \
91 # && defined(BAZ) /* comment */ \
94 # #defined FOO(a,b) a/**/b
95 # the comment may be important and so needs to be retained.
96 # This code processes the single-line comments first; it assumes there is
97 # at most one straightforward comment per continued preprocessor line,
98 # replacing each non-empty comment (and its surrounding white space) by a
99 # single space. (sed only has a greedy '*' quantifier, so this doesn't
100 # work right if there are multiple comments per line, and strings can look
101 # like comments to it; both are unlikely in a preprocessor statement.) Any
102 # continuation line is joined, and the process repeated on the enlarged
103 # line as long as there are continuations. At the end, if there are any
104 # comments remaining, they are either completely empty or are like the
105 # first situation. The latter are just deleted by first deleting to the
106 # end of line (including preceding white space) things that start with '/*'
107 # and the next char isn't a '*'; then things that start with '/**', but the
108 # next char isn't a '/'. (Subsequent lines of the comment are irrelevant
109 # and get dropped.) At the end, we unjoin very long lines to avoid
110 # preprocessor limitations
111 ( $echo "#line 2 \"$file\""; \
113 -e "/^${filebase}_init(/q" \
115 -e '/^[ ]*#/s|[ ]*/\*..*\*/[ ]*| |' \
123 -e 's|[ ]*/\*[^*].*$||' \
124 -e 's|[ ]*/\*\*[^/].*$||' \
125 -e 's/.\{255\}/&\\\n/g' \
127 -e '}' | $grep -v ":" ) >UU/$file.c
129 # We're not sure why this was there; the #endif is extraneous on modern z/OS
130 #if [ "$osname" = os390 -a "$file" = perly.c ]; then
131 # $echo '#endif' >>UU/$file.c
134 if [ "$osname" = os390 ]; then
135 $cppstdin -DPERL_CORE $finc -I. $cppflags $cppminus <UU/$file.c |
137 -e '/^#.*<stdin>/d' \
139 -e '/^#.*git_version\.h/d' \
140 -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
141 -e 's/^[ ]*#[ ]*line/#/' \
142 -e '/^# *[0-9][0-9]* *[".\/]/!d' \
143 -e 's/^.*"\(.*\)".*$/'$filebase'\$(OBJ_EXT): \1/' \
144 -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'\$(OBJ_EXT): \1/' \
146 -e 's|\.c\.c|.c|' $uwinfix | \
147 $uniq | $sort | $uniq >>$outfile
149 $cppstdin -DPERL_CORE $finc -I. $cppflags $cppminus <UU/$file.c >$$.cout 2>$$.cerr
152 -e '/^#.*<stdin>/d' \
153 -e '/^#.*<builtin>/d' \
154 -e '/^#.*<built-in>/d' \
155 -e '/^#.*<command line>/d' \
156 -e '/^#.*<command-line>/d' \
158 -e '/^#.*"\/.*\/"/d' \
159 -e '/: file path prefix .* never used$/d' \
160 -e '/^#.*git_version\.h/d' \
161 -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
162 -e 's/^[ ]*#[ ]*line/#/' \
163 -e '/^# *[0-9][0-9]* *[".\/]/!d' \
164 -e 's/^.*"\(.*\)".*$/'$filebase'\$(OBJ_EXT): \1/' \
165 -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'\$(OBJ_EXT): \1/' \
167 -e 's|\.c\.c|.c|' $uwinfix $$.cout $$.cerr| \
168 $uniq | $sort | $uniq >>$outfile
172 $echo "$filebase\$(OBJ_EXT): $@" >>$outfile
175 $eunicefix makedepend_file
176 chmod +x makedepend_file