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