This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document BEGIN, END, etc. in perlsyn
[perl5.git] / x2p / Makefile.SH
CommitLineData
d136e0b2 1case $PERL_CONFIG_SH in
8d063cd8 2'')
a0d0e21e
LW
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 ;;
8d063cd8 13esac
a0d0e21e
LW
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
ff3fa5b4
NA
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;;
a0d0e21e
LW
25esac
26
8d063cd8 27echo "Extracting x2p/Makefile (with variable substitutions)"
bf10efe7 28rm -f Makefile
939767c9
AD
29
30# The .PL extractions use the Cwd extension. For statically-built
31# perls, we need perl, not just miniperl.
32case "$usedl" in
33 define) perl="../miniperl" ;;
34 *) perl="../perl" ;;
35esac
36
8d063cd8 37cat >Makefile <<!GROK!THIS!
1aef788c 38# $RCSfile: Makefile.SH,v $$Revision: 4.1 $$Date: 92/08/07 18:29:07 $
8d063cd8
LW
39#
40# $Log: Makefile.SH,v $
8d063cd8
LW
41
42CC = $cc
9c8d0b29 43BYACC = $byacc
8d063cd8 44LDFLAGS = $ldflags
5869b1f1 45# XXX Perl malloc temporarily unusable (declaration collisions with stdlib.h)
30e2e425
GS
46#mallocsrc = $mallocsrc
47#mallocobj = $mallocobj
bf10efe7 48shellflags = $shellflags
8d063cd8 49
ae7ff215 50libs = $perllibs
cc72480d 51
1aef788c 52$make_set_make
53# grrr
54SHELL = $sh
55
dfe9444c 56# These variables may need to be manually set for non-Unix systems.
cc72480d 57AR = $ar
b0d7393a 58EXE_EXT = $_exe
dfe9444c
AD
59LIB_EXT = $_a
60OBJ_EXT = $_o
61PATH_SEP = $p_
cc72480d 62
63FIRSTMAKEFILE = $firstmakefile
64
28e8609d
JH
65# how to tr(anslate) newlines
66
67TRNL = '$trnl'
68
40fee945
RB
69OPTIMIZE = $optimize
70
cc72480d 71.SUFFIXES: .c \$(OBJ_EXT)
72
6d4b7d88 73RUN = $run
939767c9 74PERL = $perl
6d4b7d88 75
8d063cd8
LW
76!GROK!THIS!
77
78cat >>Makefile <<'!NO!SUBS!'
79
52cebf5e 80REALPERL = ../perl
40fee945 81CCCMD = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
d48672a2 82
443a5b98 83public = a2p$(EXE_EXT) s2p find2perl
8d063cd8
LW
84
85private =
86
87manpages = a2p.man s2p.man
88
89util =
90
4633a7c4
LW
91sh = Makefile.SH cflags.SH
92shextract = Makefile cflags
8d063cd8 93
4633a7c4
LW
94pl = find2perl.PL s2p.PL
95plextract = find2perl s2p
52cebf5e
EP
96plexe = find2perl.exe s2p.exe
97plc = find2perl.c s2p.c
1cfa4ec7 98plm = a2p.loadmap
4633a7c4
LW
99
100addedbyconf = $(shextract) $(plextract)
16d20bd9 101
3b5ca523 102h = EXTERN.h INTERN.h ../config.h ../handy.h hash.h a2p.h str.h util.h
8d063cd8 103
3b5ca523 104c = hash.c $(mallocsrc) str.c util.c walk.c
8d063cd8 105
cc72480d 106obj = hash$(OBJ_EXT) $(mallocobj) str$(OBJ_EXT) util$(OBJ_EXT) walk$(OBJ_EXT)
8d063cd8
LW
107
108lintflags = -phbvxac
109
1aef788c 110
cc72480d 111.c$(OBJ_EXT):
1aef788c 112 $(CCCMD) -DPERL_FOR_X2P $*.c
8d063cd8
LW
113
114all: $(public) $(private) $(util)
30b346b1 115 @echo " "
8d063cd8 116
443a5b98 117a2p$(EXE_EXT): $(obj) a2p$(OBJ_EXT)
87563a30 118 $(CC) -o a2p $(LDFLAGS) $(obj) a2p$(OBJ_EXT) $(libs)
8d063cd8 119
9c8d0b29 120# I now supply a2p.c with the kits, so the following section is
56febc5e 121# used only if you force byacc to run by saying
4cec2b33
BD
122# make run_byacc
123# byacc 1.8.2 or 1.9 are recommended.
56febc5e 124
4cec2b33 125run_byacc: FORCE
56febc5e
AD
126 @ echo Expect many shift/reduce and reduce/reduce conflicts
127 $(BYACC) a2p.y
28e8609d 128 rm -f a2p.c
08e61bcc 129 sed -e 's/(yyn = yydefred\[yystate\])/((yyn = yydefred[yystate]))/' \
caf640e2 130 -e 's/(yys = getenv("YYDEBUG"))/((yys = getenv("YYDEBUG")))/' \
08e61bcc
JH
131 -e 's/^yyerrlab://' \
132 -e 's/^ goto yyerrlab;//' \
133 -e 's/^yynewerror://' \
134 -e 's/^ goto yynewerror;//' \
135 -e 's|^static char yysccsid\(.*\)|/* static char yysccsid\1 */|' \
aab39148
RB
136 -e 's/^\(char \*yyname\[\]\)/const \1/' \
137 -e 's/^\(char \*yyrule\[\]\)/const \1/' \
138 -e 's/^\( register\) \(char \*yys;\)/\1 const \2/' \
08e61bcc 139 < y.tab.c > a2p.c
56febc5e 140
2efaeb47
AD
141FORCE:
142
56febc5e
AD
143# We don't want to regenerate a2p.c, but it might appear out-of-date
144# after a patch is applied or a new distribution is made.
145a2p.c: a2p.y
30b346b1 146 -@sh -c true
8d063cd8 147
55497cff 148a2p$(OBJ_EXT): a2p.c a2py.c a2p.h EXTERN.h util.h INTERN.h \
149 ../handy.h ../config.h str.h hash.h
5869b1f1 150 $(CCCMD) a2p.c
8d063cd8 151
8d063cd8 152clean:
6189dba1 153 rm -f a2p$(EXE_EXT) psed *$(OBJ_EXT) $(plexe) $(plc) $(plm)
8d063cd8 154
95aef5ce
JV
155distclean: veryclean
156
b6ccd89c 157realclean: clean
882d9136 158 -rmdir .depending
56acea6f 159 rm -f core $(addedbyconf) all malloc.c
0eb4e931 160 rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old makefile.old
8d063cd8 161
2edbd6da
JH
162veryclean: realclean
163 rm -f *~ *.orig
164
8d063cd8
LW
165# The following lint has practically everything turned on. Unfortunately,
166# you have to wade through a lot of mumbo jumbo that can't be suppressed.
167# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
168# for that spot.
169
170lint:
171 lint $(lintflags) $(defs) $(c) > a2p.fuzz
172
f1ca563b 173depend: $(mallocsrc) ../makedepend
3b5ca523 174 sh ../makedepend MAKE=$(MAKE)
8d063cd8
LW
175
176clist:
28e8609d 177 echo $(c) | tr ' ' $(TRNL) >.clist
8d063cd8
LW
178
179hlist:
28e8609d 180 echo $(h) | tr ' ' $(TRNL) >.hlist
8d063cd8
LW
181
182shlist:
28e8609d 183 echo $(sh) | tr ' ' $(TRNL) >.shlist
8d063cd8 184
4633a7c4 185$(plextract):
939767c9 186 $(RUN) $(PERL) -I../lib $@.PL
4633a7c4 187
bdec6fb9 188find2perl: find2perl.PL ../config.sh
1b641bfc 189
bdec6fb9 190s2p: s2p.PL ../config.sh
1b641bfc 191
f1ca563b 192malloc.c: ../malloc.c
748a9306 193 rm -f malloc.c
79072805 194 sed <../malloc.c >malloc.c \
14bd2ed1 195 -e 's/"EXTERN.h"/"..\/EXTERN.h"/' \
79072805 196 -e 's/"perl.h"/"..\/perl.h"/' \
5538b580 197 -e 's/my_exit/exit/' \
8611d51e 198 -e 's/MUTEX_[A-Z_]*(&PL_malloc_mutex);//'
f1ca563b 199
8d063cd8
LW
200# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
201$(obj):
202 @ echo "You haven't done a "'"make depend" yet!'; exit 1
a0d0e21e 203makedepend: depend
8d063cd8
LW
204!NO!SUBS!
205$eunicefix Makefile
206case `pwd` in
207*SH)
208 $rm -f ../Makefile
cc72480d 209 $ln Makefile ../Makefile
8d063cd8
LW
210 ;;
211esac
cc72480d 212rm -f $firstmakefile