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