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