source: trunk/essentials/dev-lang/perl/Makefile.SH@ 3212

Last change on this file since 3212 was 3192, checked in by bird, 19 years ago

for later.

File size: 43.7 KB
Line 
1#! /bin/sh
2case $PERL_CONFIG_SH in
3'')
4 if test -f config.sh
5 then TOP=.
6 else
7 echo "Can't find config.sh."; exit 1
8 fi
9 . $TOP/config.sh
10 ;;
11esac
12
13# H.Merijn Brand [17 Feb 2004]
14# This comment is just to ensure that Configure will find variables that
15# are removed/replaced in patches on blead, but are still needed in the
16# 5.8.x, 5.6.x and 5.005.x maintainance tracks.
17# metaconfig -m will scan all .SH files on this level (not deeper), and
18# not in x2p and other subfolders. This file is as good as any .SH
19# patch references
20# #22227 $baserev
21# #22302 $yacc $byacc
22
23# H.Merijn Brand [30 Oct 2004]
24# Mentioned for the same reason for future reference
25# #23434 $d_strlcat $d_strlcpy
26
27: This forces SH files to create target in same directory as SH file.
28: This is so that make depend always knows where to find SH derivatives.
29case "$0" in
30*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
31esac
32
33case "$d_dosuid" in
34*define*) suidperl='suidperl' ;;
35*) suidperl='';;
36esac
37
38linklibperl='$(LIBPERL)'
39shrpldflags='$(LDDLFLAGS)'
40ldlibpth=''
41DPERL_EXTERNAL_GLOB='-DPERL_EXTERNAL_GLOB'
42case "$useshrplib" in
43true)
44 # Prefix all runs of 'miniperl' and 'perl' with
45 # $ldlibpth so that ./perl finds *this* shared libperl.
46 case "$LD_LIBRARY_PATH" in
47 '')
48 ldlibpth="LD_LIBRARY_PATH=`pwd`";;
49 *)
50 ldlibpth="LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}";;
51 esac
52
53 pldlflags="$cccdlflags"
54 static_target='static_pic'
55 case "${osname}${osvers}" in
56 next4*)
57 ld=libtool
58 lddlflags="-dynamic -undefined warning -framework System \
59 -compatibility_version 1 -current_version $patchlevel \
60 -prebind -seg1addr 0x27000000 -install_name \$(shrpdir)/\$@"
61 ;;
62 rhapsody*|darwin*)
63 shrpldflags="${ldflags} -dynamiclib \
64 -compatibility_version \
65 ${api_revision}.${api_version}.${api_subversion} \
66 -current_version \
67 ${revision}.${patchlevel}.${subversion} \
68 -install_name \$(shrpdir)/\$@"
69 ;;
70 cygwin*)
71 linklibperl="-lperl"
72 ;;
73 sunos*)
74 linklibperl="-lperl"
75 ;;
76 netbsd*|freebsd[234]*|openbsd*)
77 linklibperl="-L. -lperl"
78 ;;
79 interix*)
80 linklibperl="-L. -lperl"
81 shrpldflags="$shrpldflags -Wl,--image-base,0x57000000"
82 ;;
83 aix*)
84 shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
85 case "$osvers" in
86 3*) shrpldflags="$shrpldflags -e _nostart"
87 ;;
88 *) shrpldflags="$shrpldflags -b noentry"
89 ;;
90 esac
91 shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
92 linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
93 ;;
94 hpux*)
95 linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+s -Wl,+b$archlibexp/CORE -lperl"
96 ;;
97 os390*)
98 shrpldflags='-W l,dll'
99 linklibperl='libperl.x'
100 DPERL_EXTERNAL_GLOB=''
101 ;;
102 esac
103 case "$ldlibpthname" in
104 '') ;;
105 *)
106 case "$osname" in
107 os2)
108 ldlibpth=''
109 ;;
110 *)
111 eval "ldlibpth=\"$ldlibpthname=`pwd`:\$$ldlibpthname\""
112 ;;
113 esac
114 # Strip off any trailing :'s
115 ldlibpth=`echo $ldlibpth | sed 's/:*$//'`
116 ;;
117 esac
118
119 case "$ldlibpth" in
120 # Protect any spaces
121 *" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
122 esac
123
124 case "$osname" in
125 linux)
126 # If there is a pre-existing $libperl from a previous
127 # installation, Linux needs to use LD_PRELOAD to
128 # override the LD_LIBRARY_PATH setting. See the
129 # INSTALL file, under "Building a shared perl library".
130 # If there is no pre-existing $libperl, we don't need
131 # to do anything further.
132 if test -f $archlib/CORE/$libperl; then
133 rm -f preload
134 cat <<'EOT' > preload
135#! /bin/sh
136lib=$1
137shift
138test -r $lib && export LD_PRELOAD="$lib $LD_PRELOAD"
139exec "$@"
140EOT
141 chmod 755 preload
142 ldlibpth="$ldlibpth `pwd`/preload `pwd`/$libperl"
143 fi
144 ;;
145 os390) test -f /bin/env && ldlibpth="/bin/env $ldlibpth"
146 ;;
147 esac
148
149 ;;
150
151*) pldlflags=''
152 static_target='static'
153 ;;
154esac
155
156: Prepare dependency lists for Makefile.
157dynamic_list=' '
158for f in $dynamic_ext; do
159 : the dependency named here will never exist
160 base=`echo "$f" | sed 's/.*\///'`
161 dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
162done
163
164static_list=' '
165for f in $static_ext; do
166 base=`echo "$f" | sed 's/.*\///'`
167 static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
168done
169
170nonxs_list=' '
171for f in $nonxs_ext; do
172 base=`echo "$f" | sed 's/.*\///'`
173 nonxs_list="$nonxs_list ext/$f/pm_to_blib"
174done
175
176# Handle the usage of different yaccs in posix-bc (During Configure we
177# us yacc for perly.y and byacc for a2p.y. The makefiles must use the
178# same configuration for run_byacc!):
179case "$osname" in
180 posix-bc)
181 byacc=$yacc
182 ;;
183esac
184
185echo "Extracting Makefile (with variable substitutions)"
186$spitshell >Makefile <<!GROK!THIS!
187# Makefile.SH
188# This file is derived from Makefile.SH. Any changes made here will
189# be lost the next time you run Configure.
190# Makefile is used to generate $firstmakefile. The only difference
191# is that $firstmakefile has the dependencies filled in at the end.
192#
193#
194# I now supply perly.c with the kits, so don't remake perly.c without byacc
195BYACC = $byacc
196CC = $cc
197LD = $ld
198
199LDFLAGS = $ldflags
200CLDFLAGS = $ldflags
201
202mallocsrc = $mallocsrc
203mallocobj = $mallocobj
204LNS = $lns
205# NOTE: some systems don't grok "cp -f". XXX Configure test needed?
206CPS = $cp
207RMS = rm -f
208ranlib = $ranlib
209
210# The following are mentioned only to make metaconfig include the
211# appropriate questions in Configure. If you want to change these,
212# edit config.sh instead, or specify --man1dir=/wherever on
213# installman commandline.
214bin = $installbin
215scriptdir = $scriptdir
216shrpdir = $archlibexp/CORE
217privlib = $installprivlib
218man1dir = $man1dir
219man1ext = $man1ext
220man3dir = $man3dir
221man3ext = $man3ext
222
223# The following are used to build and install shared libraries for
224# dynamic loading.
225LDDLFLAGS = $lddlflags
226SHRPLDFLAGS = $shrpldflags
227CCDLFLAGS = $ccdlflags
228DLSUFFIX = .$dlext
229PLDLFLAGS = $pldlflags
230LIBPERL = $libperl
231LLIBPERL= $linklibperl
232SHRPENV = $shrpenv
233
234# Static targets are ordinarily built without CCCDLFLAGS. However,
235# if building a shared libperl.so that might later be linked into
236# another application, then it might be appropriate to also build static
237# extensions (usually just DynaLoader) with relocatable code (e.g. -fPIC
238# for GNU cc). This is handled by ext/util/make_ext.
239STATIC = $static_target
240
241# The following is used to include the current directory in
242# the dynamic loader path you are building a shared libperl.
243LDLIBPTH = $ldlibpth
244
245dynamic_ext = $dynamic_list
246static_ext = $static_list
247nonxs_ext = $nonxs_list
248ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
249DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
250
251libs = $perllibs $cryptlib
252
253public = perl\$(EXE_EXT) $suidperl utilities translators
254
255shellflags = $shellflags
256
257# This is set to MAKE=$make if your $make command doesn't
258# do it for you.
259$make_set_make
260
261# Mention $gmake here so it gets probed for by Configure.
262
263# These variables may need to be manually set for non-Unix systems.
264AR = $full_ar
265EXE_EXT = $_exe
266LIB_EXT = $_a
267OBJ_EXT = $_o
268PATH_SEP = $p_
269
270FIRSTMAKEFILE = $firstmakefile
271
272# Any special object files needed by this architecture, e.g. os2/os2.obj
273ARCHOBJS = $archobjs
274
275.SUFFIXES: .c \$(OBJ_EXT) .i .s
276
277# grrr
278SHELL = $sh
279
280# how to tr(anslate) newlines
281TRNL = '$trnl'
282
283OPTIMIZE = $optimize
284
285EXTRAS = $extras
286
287INSTALLPREFIXEXP = $prefix
288
289!GROK!THIS!
290# not used by Makefile but by installperl;
291# mentioned here so that metaconfig picks these up
292# $installusrbinperl
293# $versiononly
294
295case "${osname}:${osvers}" in
296darwin:*)
297$spitshell >>Makefile <<EOF
298
299# Your locales are broken (osname $osname, osvers $osvers)
300# and to avoid the numerous
301# perl: warning: Setting locale failed.
302# warnings during the build process we reset the locale variables.
303
304LC_ALL=C
305LANG=C
306LANGUAGE=C
307EOF
308 ;;
309esac
310
311## In the following dollars and backticks do not need the extra backslash.
312$spitshell >>Makefile <<'!NO!SUBS!'
313
314CCCMD = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
315
316CCCMDSRC = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<`
317
318CONFIGPM = lib/Config.pm lib/Config_heavy.pl
319private = preplibrary $(CONFIGPM) lib/Config.pod lib/ExtUtils/Miniperl.pm
320
321# Files to be built with variable substitution before miniperl
322# is available.
323sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
324 makedir.SH myconfig.SH writemain.SH pod/Makefile.SH
325
326shextract = Makefile cflags config.h makeaperl makedepend \
327 makedir myconfig writemain pod/Makefile
328
329# Files to be built with variable substitution after miniperl is
330# available. Dependencies handled manually below (for now).
331
332pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL \
333 pod/pod2usage.PL pod/podchecker.PL pod/podselect.PL
334
335# lib/lib.pm is not listed here because it has a rule of its own.
336plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text \
337 pod/pod2usage pod/podchecker pod/podselect
338
339addedbyconf = UU $(shextract) $(plextract) lib/lib.pm pstruct
340
341# Unicode data files generated by mktables
342unidatafiles = lib/unicore/Canonical.pl lib/unicore/Exact.pl \
343 lib/unicore/Properties lib/unicore/Decomposition.pl \
344 lib/unicore/CombiningClass.pl lib/unicore/Name.pl lib/unicore/PVA.pl
345
346# Directories of Unicode data files generated by mktables
347unidatadirs = lib/unicore/To lib/unicore/lib
348
349h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
350h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h opcode.h
351h3 = pad.h patchlevel.h perl.h perlapi.h perly.h pp.h proto.h regcomp.h
352h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
353h5 = utf8.h warnings.h
354h = $(h1) $(h2) $(h3) $(h4) $(h5)
355
356c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c reentr.c
357c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c
358c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c universal.c xsutils.c pad.c
359c4 = globals.c perlio.c perlapi.c numeric.c locale.c pp_pack.c pp_sort.c
360
361c = $(c1) $(c2) $(c3) $(c4) miniperlmain.c perlmain.c opmini.c
362
363obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) op$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT)
364obj2 = 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)
365obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) xsutils$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) perlapi$(OBJ_EXT) numeric$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT)
366
367obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
368
369lintflags = \
370 -bhn \
371 -p \
372 -s \
373 -Ncheck=%all \
374 -Nlevel=4 \
375 -errfmt=src \
376 -errtags \
377 -erroff=E_BAD_PTR_CAST \
378 -erroff=E_BLOCK_DECL_UNUSED \
379 -erroff=E_CONSTANT_CONDITION \
380 -erroff=E_BAD_PTR_CAST_ALIGN \
381 -erroff=E_PTRDIFF_OVERFLOW \
382 -erroff=E_EXPR_NULL_EFFECT \
383 -erroff=E_BAD_PTR_INT_COMBINATION \
384 -erroff=E_LOOP_EMPTY \
385 -erroff=E_TRUE_LOGICAL_EXPR \
386 -erroff=E_FALSE_LOGICAL_EXPR \
387 -erroff=E_INDISTING_FROM_TRUNC \
388 -erroff=E_POINTER_TO_OBJECT \
389 -erroff=E_ASSIGN_NARROW_CONV \
390 -erroff=E_BAD_SIGN_EXTEND \
391 -erroff=E_INCL_NUSD \
392 -erroff=E_MAIN_PARAM \
393 -Wfoo.flow
394
395.c$(OBJ_EXT):
396 $(CCCMD) $(PLDLFLAGS) $*.c
397
398.c.i:
399 $(CCCMDSRC) -E $*.c > $*.i
400
401.c.s:
402 $(CCCMDSRC) -S $*.c
403
404all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
405 @echo " ";
406 @echo " Everything is up to date. Type '$(MAKE) test' to run test suite."
407
408.PHONY: all compile translators utilities
409
410compile: all
411 echo "testing compilation" > testcompile;
412 cd utils; $(MAKE) compile;
413 cd x2p; $(MAKE) compile;
414 cd pod; $(MAKE) compile;
415
416translators: miniperl$(EXE_EXT) $(CONFIGPM) FORCE
417 @echo " "; echo " Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
418
419utilities: miniperl$(EXE_EXT) $(CONFIGPM) $(plextract) lib/lib.pm FORCE
420 @echo " "; echo " Making utilities"; cd utils; $(LDLIBPTH) $(MAKE) all
421
422
423# This is now done by installman only if you actually want the man pages.
424# @echo " "; echo " Making docs"; cd pod; $(MAKE) all;
425
426# Phony target to force checking subdirectories.
427# Apparently some makes require an action for the FORCE target.
428.PHONY: FORCE
429FORCE:
430 @sh -c true
431!NO!SUBS!
432$spitshell >>Makefile <<!GROK!THIS!
433
434# We do a copy of the op.c instead of a symlink because gcc gets huffy
435# if we have a symlink forest to another disk (it complains about too many
436# levels of symbolic links, even if we have only two)
437
438opmini.c: op.c
439 \$(RMS) opmini.c
440 \$(CPS) op.c opmini.c
441
442opmini\$(OBJ_EXT): opmini.c
443 \$(CCCMD) \$(PLDLFLAGS) $DPERL_EXTERNAL_GLOB opmini.c
444
445!GROK!THIS!
446$spitshell >>Makefile <<'!NO!SUBS!'
447miniperlmain$(OBJ_EXT): miniperlmain.c patchlevel.h
448 $(CCCMD) $(PLDLFLAGS) $*.c
449
450perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
451 sh writemain $(DYNALOADER) $(static_ext) > perlmain.c
452
453!NO!SUBS!
454case "$osname" in
455cygwin)
456 ;; # Let cygwin/Makefile.SHs do its work.
457*)
458 $spitshell >>Makefile <<'!NO!SUBS!'
459perlmain$(OBJ_EXT): perlmain.c
460 $(CCCMD) $(PLDLFLAGS) $*.c
461
462!NO!SUBS!
463 ;;
464esac
465$spitshell >>Makefile <<'!NO!SUBS!'
466# The file ext.libs is a list of libraries that must be linked in
467# for static extensions, e.g. -lm -lgdbm, etc. The individual
468# static extension Makefile's add to it.
469ext.libs: $(static_ext)
470 -@test -f ext.libs || touch ext.libs
471
472!NO!SUBS!
473
474# How to build libperl. This is still rather convoluted.
475# Load up custom Makefile.SH fragment for shared loading and executables:
476case "$osname" in
477*)
478 Makefile_s="$osname/Makefile.SHs"
479 ;;
480esac
481
482case "$osname" in
483aix)
484 $spitshell >>Makefile <<!GROK!THIS!
485LIBS = $perllibs
486# In AIX we need to change this for building Perl itself from
487# its earlier definition (which is for building external
488# extensions *after* Perl has been built and installed)
489CCDLFLAGS = `echo $ccdlflags|sed -e 's@-bE:.*/perl\.exp@-bE:perl.exp@'`
490
491!GROK!THIS!
492 case "$useshrplib" in