Re: sh Configure?
[p5sagit/p5-mst-13.2.git] / Makefile.SH
1 #! /bin/sh
2 case $CONFIG in
3 '')
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=../../../..;
9         else
10                 echo "Can't find config.sh."; exit 1
11         fi
12         . $TOP/config.sh
13         ;;
14 esac
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.
17 case "$0" in
18 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
19 esac
20
21 case "$d_dosuid" in
22 *define*) suidperl='suidperl' ;;
23 *) suidperl='';;
24 esac
25
26 case "$useshrplib" in
27 true)
28     pldlflags="$cccdlflags"
29         # NeXT-4 specific stuff.  Can't we do this in the hint file?
30         case "${osname}${osvers}" in
31         next4*)
32                 ld='libtool -dynamic -undefined warning -framework System \
33                 -compatibility_version 1 -current_version $(PATCHLEVEL) \
34                 -prebind -seg1addr 0x27000000 -install_name $(SHRPDIR)/$@'
35                 ;;
36         esac
37     ;;
38 *)      pldlflags=''
39         ;;
40 esac
41
42 : Prepare dependency lists for Makefile.
43 dynamic_list=' '
44 for f in $dynamic_ext; do
45     : the dependency named here will never exist
46       base=`echo "$f" | sed 's/.*\///'`
47     dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
48 done
49
50 static_list=' '
51 for f in $static_ext; do
52         base=`echo "$f" | sed 's/.*\///'`
53         static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
54 done
55
56 echo "Extracting Makefile (with variable substitutions)"
57 $spitshell >Makefile <<!GROK!THIS!
58 # Makefile.SH
59 # This file is derived from Makefile.SH.  Any changes made here will
60 # be lost the next time you run Configure.
61 #  Makefile is used to generate $firstmakefile.  The only difference
62 #  is that $firstmakefile has the dependencies filled in at the end.
63 #
64 #
65 # I now supply perly.c with the kits, so don't remake perly.c without byacc
66 BYACC = $byacc
67 CC = $cc
68 LD = $ld
69
70 LDFLAGS = $ldflags
71 CLDFLAGS = $ldflags
72
73 SMALL = $small
74 LARGE = $large $split
75 mallocsrc = $mallocsrc
76 mallocobj = $mallocobj
77 LNS = $lns
78 RMS = rm -f
79 ranlib = $ranlib
80
81 # The following are mentioned only to make metaconfig include the
82 # appropriate questions in Configure.  If you want to change these,
83 # edit config.sh instead, or specify --man1dir=/wherever on
84 # installman commandline.
85 bin = $installbin
86 scriptdir = $scriptdir
87 shrpdir = $archlibexp/CORE
88 privlib = $installprivlib
89 man1dir = $man1dir
90 man1ext = $man1ext
91 man3dir = $man3dir
92 man3ext = $man3ext
93
94 # The following are used to build and install shared libraries for
95 # dynamic loading.
96 LDDLFLAGS = $lddlflags
97 CCDLFLAGS = $ccdlflags
98 DLSUFFIX = .$dlext
99 PLDLFLAGS = $pldlflags
100 LIBPERL = $libperl
101 SHRPENV = $shrpenv
102
103 dynamic_ext = $dynamic_list
104 static_ext = $static_list
105 ext = \$(dynamic_ext) \$(static_ext)
106 DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
107
108 libs = $libs $cryptlib
109
110 public = perl $suidperl utilities translators
111
112 shellflags = $shellflags
113
114 # This is set to  MAKE=$make if your $make command doesn't
115 # do it for you.
116 $make_set_make
117
118 # These variables will be used in a future version to make
119 # the make file more portable to non-unix systems.
120 AR = $ar
121 EXE_EXT = $exe_ext
122 LIB_EXT = $lib_ext
123 OBJ_EXT = $obj_ext
124 PATH_SEP = $path_sep
125
126 FIRSTMAKEFILE = $firstmakefile
127
128 # Any special object files needed by this architecture, e.g. os2/os2.obj
129 ARCHOBJS = $archobjs
130
131 .SUFFIXES: .c \$(OBJ_EXT)
132
133 # grrr
134 SHELL = $sh
135
136 !GROK!THIS!
137
138 ## In the following dollars and backticks do not need the extra backslash.
139 $spitshell >>Makefile <<'!NO!SUBS!'
140
141 CCCMD = `sh $(shellflags) cflags $(LIBPERL) $@`
142
143 private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
144
145 # Files to be built with variable substitution before miniperl
146 # is available.
147 sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
148         makedir.SH perl_exp.SH writemain.SH
149
150 shextract = Makefile cflags config.h makeaperl makedepend \
151         makedir perl.exp writemain
152
153 # Files to be built with variable substitution after miniperl is
154 # available.  Dependencies handled manually below (for now).
155
156 pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL
157
158 plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text
159
160 addedbyconf = UU $(shextract) $(plextract) pstruct
161
162 h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
163 h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
164 h3 = opcode.h patchlevel.h perl.h perly.h pp.h proto.h regcomp.h
165 h4 = regexp.h scope.h sv.h unixish.h util.h perlio.h
166 h = $(h1) $(h2) $(h3) $(h4)
167
168 c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
169 c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c
170 c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c universal.c globals.c perlio.c
171
172 c = $(c1) $(c2) $(c3) miniperlmain.c perlmain.c
173
174 obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) op$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT)
175 obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
176 obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT)
177
178 obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
179
180 # Once perl has been Configure'd and built ok you build different
181 # perl variants (Debugging, Embedded, Multiplicity etc) by saying:
182 #       make clean; make LIBPERL=libperl<type>.a
183 # where <type> is some combination of 'd' and(or) 'e' or 'm'.
184 # See cflags to understand how this works.
185 #
186 # This mechanism is getting clunky and might not even work any more.
187 # EMBEDDING is on by default, and MULTIPLICITY doesn't work.
188 #
189
190 lintflags = -hbvxac
191
192 .c$(OBJ_EXT):
193         $(CCCMD) $(PLDLFLAGS) $*.c
194
195 all: $(FIRSTMAKEFILE) miniperl $(private) $(plextract) $(public) $(dynamic_ext)
196         @echo " "; echo "       Everything is up to date."
197
198 translators:    miniperl lib/Config.pm FORCE
199         @echo " "; echo "       Making x2p stuff"; cd x2p; $(MAKE) all
200
201 utilities:      miniperl lib/Config.pm FORCE
202         @echo " "; echo "       Making utilities"; cd utils; $(MAKE) all
203
204
205 # This is now done by installman only if you actually want the man pages.
206 #       @echo " "; echo "       Making docs"; cd pod; $(MAKE) all;
207
208 # Phony target to force checking subdirectories.
209 # Apparently some makes require an action for the FORCE target.
210 FORCE:
211         @sh -c true
212
213 miniperlmain$(OBJ_EXT): miniperlmain.c
214         $(CCCMD) $(PLDLFLAGS) $*.c
215
216 perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
217         sh writemain $(DYNALOADER) $(static_ext) > tmp
218         sh mv-if-diff tmp perlmain.c
219
220 perlmain$(OBJ_EXT): perlmain.c
221         $(CCCMD) $(PLDLFLAGS) $*.c
222
223 # The file ext.libs is a list of libraries that must be linked in
224 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
225 # static extension Makefile's add to it.
226 ext.libs: $(static_ext)
227         -@test -f ext.libs || touch ext.libs
228
229 !NO!SUBS!
230
231 # How to build libperl.  This is still rather convoluted.
232 # Load up custom Makefile.SH fragment for shared loading and executables:
233 if test -r $osname/Makefile.SHs ; then
234         . $osname/Makefile.SHs
235         $spitshell >>Makefile <<!GROK!THIS!
236
237 Makefile: $osname/Makefile.SHs
238 !GROK!THIS!
239 else
240         $spitshell >>Makefile <<'!NO!SUBS!'
241 $(LIBPERL): $& perl$(OBJ_EXT) $(obj)
242 !NO!SUBS!
243         case "$useshrplib" in
244         true)
245                 $spitshell >>Makefile <<'!NO!SUBS!'
246         $(LD) $(LDDLFLAGS) -o $@ perl$(OBJ_EXT) $(obj)
247 !NO!SUBS!
248                 ;;
249         *)
250                 $spitshell >>Makefile <<'!NO!SUBS!'
251         rm -f $(LIBPERL)
252         $(AR) rcu $(LIBPERL) perl$(OBJ_EXT) $(obj)
253         @$(ranlib) $(LIBPERL)
254 !NO!SUBS!
255                 ;;
256         esac
257         $spitshell >>Makefile <<'!NO!SUBS!'
258
259 # How to build executables.
260
261 # The $& notation tells Sequent machines that it can do a parallel make,
262 # and is harmless otherwise.
263 # The miniperl -w -MExporter line is a basic cheap test to catch errors
264 # before make goes on to run preplibrary and then MakeMaker on extensions.
265 # This is very handy because later errors are often caused by miniperl
266 # build problems but that's not obvious to the novice.
267 # The Module used here must not depend on Config or any extensions.
268
269 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)
270         $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LIBPERL) $(libs)
271         @./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
272
273 perl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
274         $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
275
276 pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
277         purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
278
279 quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
280         quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
281
282 # This version, if specified in Configure, does ONLY those scripts which need
283 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
284 # checks as well as the special code to validate that the script in question
285 # has been invoked correctly.
286
287 suidperl: $& sperl$(OBJ_EXT) perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
288         $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
289
290 !NO!SUBS!
291
292 fi
293
294 $spitshell >>Makefile <<'!NO!SUBS!'
295
296 sperl$(OBJ_EXT): perl.c perly.h patchlevel.h $(h)
297         $(RMS) sperl.c
298         $(LNS) perl.c sperl.c
299         $(CCCMD) -DIAMSUID sperl.c
300         $(RMS) sperl.c
301
302 # We have to call our ./makedir because Ultrix 4.3 make can't handle the line
303 #       test -d lib/auto || mkdir lib/auto
304 #
305 preplibrary: miniperl lib/Config.pm $(plextract)
306         @sh ./makedir lib/auto
307         @echo " AutoSplitting perl library"
308         @./miniperl -Ilib -e 'use AutoSplit; \
309                 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
310
311 # Take care to avoid modifying lib/Config.pm without reason
312 lib/Config.pm: config.sh miniperl configpm
313         ./miniperl configpm tmp
314         sh mv-if-diff tmp lib/Config.pm
315
316 lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.pl lib/Config.pm
317         ./miniperl minimod.pl > tmp && mv tmp $@
318
319 $(plextract):   miniperl lib/Config.pm
320         ./miniperl -Ilib $@.PL
321
322 install: all install.perl install.man
323
324 install.perl:   all installperl
325         ./perl installperl
326
327 install.man:    all installman
328         ./perl installman
329
330 # Not implemented yet.
331 #install.html:  all installhtml
332 #       ./perl installhtml
333
334 # I now supply perly.c with the kits, so the following section is
335 # used only if you force byacc to run by saying
336 #       make run_byacc
337 # Since we patch up the byacc output, the perly.fixer script needs
338 # to run with precisely the same version of byacc as I use.  You
339 # normally shouldn't remake perly.[ch].
340
341 run_byacc:      FORCE
342         @ echo 'Expect' 130 shift/reduce and 1 reduce/reduce conflict
343         $(BYACC) -d perly.y
344         sh $(shellflags) ./perly.fixer y.tab.c perly.c
345         sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' perly.c >perly.tmp && mv perly.tmp perly.c
346         mv y.tab.h perly.h
347         echo 'extern YYSTYPE yylval;' >>perly.h
348         - perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
349
350 # We don't want to regenerate perly.c and perly.h, but they might
351 # appear out-of-date after a patch is applied or a new distribution is
352 # made.
353 perly.c: perly.y
354         -@sh -c true
355
356 perly.h: perly.y
357         -@sh -c true
358
359 # The following three header files are generated automatically
360 #       keywords.h:     keywords.pl
361 #       opcode.h:       opcode.pl
362 #       embed.h:        embed.pl global.sym interp.sym
363 # The correct versions should be already supplied with the perl kit,
364 # in case you don't have perl available.
365 # To force them to run, type
366 #       make regen_headers
367 regen_headers:  FORCE
368         perl keywords.pl
369         perl opcode.pl
370         perl embed.pl
371
372 # Extensions:
373 # Names added to $(dynamic_ext) or $(static_ext) will automatically
374 # get built.  There should ordinarily be no need to change any of
375 # this part of makefile.
376 #
377 # The dummy dependency is a place holder in case $(dynamic_ext) or
378 # $(static_ext) is empty.
379 #
380 # DynaLoader may be needed for extensions that use Makefile.PL.
381
382 $(DYNALOADER):  miniperl preplibrary FORCE
383         @sh ext/util/make_ext static $@ LIBPERL_A=$(LIBPERL)
384
385 d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
386         @sh ext/util/make_ext dynamic $@ LIBPERL_A=$(LIBPERL)
387
388 s_dummy $(static_ext):  miniperl preplibrary $(DYNALOADER) FORCE
389         @sh ext/util/make_ext static $@ LIBPERL_A=$(LIBPERL)
390
391 clean:
392         rm -f *$(OBJ_EXT) *$(LIB_EXT) all perlmain.c
393         rm -f perl.exp ext.libs
394         -rm -f perl.export perl.dll perl.libexp perl.map perl.def
395         -cd pod; $(MAKE) clean
396         -cd utils; $(MAKE) clean
397         -cd x2p; $(MAKE) clean
398         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
399         sh ext/util/make_ext clean $$x ; \
400         done
401         rm -f perl suidperl miniperl $(LIBPERL)
402
403 realclean: clean
404         -cd os2; rm -f Makefile
405         -cd pod; $(MAKE) realclean
406         -cd utils; $(MAKE) realclean
407         -cd x2p; $(MAKE) realclean
408         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
409         sh ext/util/make_ext realclean $$x ; \
410         done
411         rm -f *.orig */*.orig *~ */*~ core t/core t/c t/perl
412         rm -rf $(addedbyconf)
413         rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old
414         rm -f $(private)
415         rm -rf lib/auto
416         rm -f lib/.exists
417         rm -f h2ph.man pstruct
418         rm -rf .config
419         @echo "Note that make realclean does not delete config.sh"
420
421 clobber:        realclean
422         rm -f config.sh cppstdin
423
424 distclean:      clobber
425
426 # The following lint has practically everything turned on.  Unfortunately,
427 # you have to wade through a lot of mumbo jumbo that can't be suppressed.
428 # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
429 # for that spot.
430
431 lint: perly.c $(c)
432         lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
433
434 # Need to unset during recursion to go out of loop
435
436 MAKEDEPEND = makedepend
437
438 $(FIRSTMAKEFILE):       Makefile $(MAKEDEPEND)
439         $(MAKE) depend MAKEDEPEND=
440
441 config.h: config_h.SH config.sh
442         $(SHELL) config_h.SH
443
444 perl.exp: perl_exp.SH config.sh
445         $(SHELL) perl_exp.SH
446
447 # When done, touch perlmain.c so that it doesn't get remade each time.
448 depend: makedepend
449         sh ./makedepend
450         - test -s perlmain.c && touch perlmain.c
451         cd x2p; $(MAKE) depend
452
453 # Cannot postpone this until $firstmakefile is ready ;-)
454 makedepend: makedepend.SH config.sh
455         sh ./makedepend.SH
456
457 check test: miniperl perl preplibrary $(dynamic_ext)
458         - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../perl$(EXE_EXT) perl$(EXE_EXT)) && ./perl TEST </dev/tty
459
460 # Can't depend on lib/Config.pm because that might be where miniperl
461 # is crashing.
462 minitest: miniperl
463         @echo "You may see some irrelevant test failures if you have been unable"
464         @echo "to build lib/Config.pm."
465         - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../miniperl$(EXE_EXT) perl$(EXE_EXT)) \
466                 && ./perl TEST base/*.t comp/*.t cmd/*.t io/*.t op/*.t </dev/tty
467
468 clist:  $(c)
469         echo $(c) | tr ' ' '\012' >.clist
470
471 hlist:  $(h)
472         echo $(h) | tr ' ' '\012' >.hlist
473
474 shlist: $(sh)
475         echo $(sh) | tr ' ' '\012' >.shlist
476
477 pllist: $(pl)
478         echo $(pl) | tr ' ' '\012' >.pllist
479
480 Makefile: Makefile.SH ./config.sh
481         $(SHELL) Makefile.SH
482
483 distcheck: FORCE
484         perl '-MExtUtils::Manifest=&fullcheck' -e 'fullcheck()'
485
486 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
487 # If this runs make out of memory, delete /usr/include lines.
488 !NO!SUBS!
489
490 $eunicefix Makefile
491 case `pwd` in
492 *SH)
493     $rm -f ../Makefile
494     $ln Makefile ../Makefile
495     ;;
496 esac
497 $rm -f $firstmakefile