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