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