1case $PERL_CONFIG_SH 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	;;
13esac
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.
16case "$0" in
17*/Makefile.SH) cd `expr X$0 : 'X\(.*\)/'` ;;
18Makefile.SH) ;;
19*) case `pwd` in
20   */x2p) ;;
21   *) if test -d x2p; then cd x2p
22      else echo "Can't figure out where to write output."; exit 1
23	  fi;;
24   esac;;
25esac
26
27echo "Extracting x2p/Makefile (with variable substitutions)"
28rm -f Makefile
29cat >Makefile <<!GROK!THIS!
30# $RCSfile: Makefile.SH,v $$Revision: 1.10 $$Date: 2006/03/28 19:23:15 $
31#
32# $Log: Makefile.SH,v $
33# Revision 1.10  2006/03/28 19:23:15  millert
34# merge in perl 5.8.8
35#
36# Revision 1.9  2003/12/03 03:02:53  millert
37# Resolve conflicts for perl 5.8.2, remove old files, and add OpenBSD-specific scaffolding
38#
39
40CC = $cc
41BYACC = $byacc
42LDFLAGS = $ldflags
43# XXX Perl malloc temporarily unusable (declaration collisions with stdlib.h)
44#mallocsrc = $mallocsrc
45#mallocobj = $mallocobj
46shellflags = $shellflags
47
48libs = $perllibs
49
50$make_set_make
51# grrr
52SHELL = $sh
53
54# These variables may need to be manually set for non-Unix systems.
55AR = $ar
56EXE_EXT = $_ext
57LIB_EXT = $_a
58OBJ_EXT = $_o
59PATH_SEP = $p_
60
61FIRSTMAKEFILE = $firstmakefile
62
63# how to tr(anslate) newlines
64
65TRNL = '$trnl'
66
67OPTIMIZE = $optimize
68
69.SUFFIXES: .c \$(OBJ_EXT)
70
71!GROK!THIS!
72
73cat >>Makefile <<'!NO!SUBS!'
74
75REALPERL = ../perl
76CCCMD = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
77
78public = a2p$(EXE_EXT) s2p find2perl
79
80private =
81
82manpages = a2p.man s2p.man
83
84util =
85
86sh = Makefile.SH cflags.SH
87shextract = Makefile cflags
88
89pl = find2perl.PL s2p.PL
90plextract = find2perl s2p
91plexe = find2perl.exe s2p.exe
92plc   = find2perl.c s2p.c
93plm   = a2p.loadmap
94
95addedbyconf = $(shextract) $(plextract)
96
97h = EXTERN.h INTERN.h ../config.h ../handy.h hash.h a2p.h str.h util.h
98
99c = hash.c $(mallocsrc) str.c util.c walk.c
100
101obj = hash$(OBJ_EXT) $(mallocobj) str$(OBJ_EXT) util$(OBJ_EXT) walk$(OBJ_EXT)
102
103lintflags = -phbvxac
104
105
106.c$(OBJ_EXT):
107	$(CCCMD) -DPERL_FOR_X2P $*.c
108
109all: $(public) $(private) $(util)
110	@echo " "
111
112compile: all
113	$(REALPERL) -I../lib ../utils/perlcc -I .. -L .. $(plextract) -v -log ../compilelog;
114
115a2p$(EXE_EXT): $(obj) a2p$(OBJ_EXT)
116	$(CC) -o a2p $(LDFLAGS) $(obj) a2p$(OBJ_EXT) $(libs)
117
118# I now supply a2p.c with the kits, so the following section is
119# used only if you force byacc to run by saying
120#    make run_byacc
121# byacc 1.8.2 or 1.9 are recommended.
122
123run_byacc:	FORCE
124	@ echo Expect many shift/reduce and reduce/reduce conflicts
125	$(BYACC) a2p.y
126	rm -f a2p.c
127	sed -e 's/(yyn = yydefred\[yystate\])/((yyn = yydefred[yystate]))/' \
128	    -e 's/(yys = getenv("YYDEBUG"))/((yys = getenv("YYDEBUG")))/' \
129	    -e 's/^yyerrlab://' \
130	    -e 's/^    goto yyerrlab;//' \
131	    -e 's/^yynewerror://' \
132	    -e 's/^    goto yynewerror;//' \
133	    -e 's|^static char yysccsid\(.*\)|/* static char yysccsid\1 */|' \
134	    < y.tab.c > a2p.c
135
136FORCE:
137
138# We don't want to regenerate a2p.c, but it might appear out-of-date
139# after a patch is applied or a new distribution is made.
140a2p.c: a2p.y
141	-@sh -c true
142
143a2p$(OBJ_EXT): a2p.c a2py.c a2p.h EXTERN.h util.h INTERN.h \
144		../handy.h ../config.h str.h hash.h
145	$(CCCMD) a2p.c
146
147clean:
148	rm -f a2p$(EXE_EXT) psed *$(OBJ_EXT) $(plexe) $(plc) $(plm)
149
150realclean: clean
151	-rmdir .depending
152	rm -f core $(addedbyconf) all malloc.c
153	rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old makefile.old
154
155veryclean: realclean
156	rm -f *~ *.orig
157
158# The following lint has practically everything turned on.  Unfortunately,
159# you have to wade through a lot of mumbo jumbo that can't be suppressed.
160# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
161# for that spot.
162
163lint:
164	lint $(lintflags) $(defs) $(c) > a2p.fuzz
165
166depend: $(mallocsrc) ../makedepend
167	sh ../makedepend MAKE=$(MAKE)
168
169clist:
170	echo $(c) | tr ' ' $(TRNL) >.clist
171
172hlist:
173	echo $(h) | tr ' ' $(TRNL) >.hlist
174
175shlist:
176	echo $(sh) | tr ' ' $(TRNL) >.shlist
177
178# These should be automatically generated
179
180$(plextract):
181	../miniperl -I../lib $@.PL
182
183find2perl: find2perl.PL
184
185s2p: s2p.PL
186
187malloc.c: ../malloc.c
188	rm -f malloc.c
189	sed <../malloc.c >malloc.c \
190	    -e 's/"EXTERN.h"/"..\/EXTERN.h"/' \
191	    -e 's/"perl.h"/"..\/perl.h"/' \
192	    -e 's/my_exit/exit/' \
193	    -e 's/MUTEX_[A-Z_]*(&PL_malloc_mutex);//'
194
195# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
196$(obj):
197	@ echo "You haven't done a "'"make depend" yet!'; exit 1
198makedepend: depend
199!NO!SUBS!
200$eunicefix Makefile
201case `pwd` in
202*SH)
203    $rm -f ../Makefile
204    $ln Makefile ../Makefile
205    ;;
206esac
207rm -f $firstmakefile
208