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