extract_config.sh revision 8511:c9d1f9fefe39
1#!/bin/ksh -p
2
3#
4# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
5# Use is subject to license terms.
6#
7
8#
9# This script extracts values from the passed config.sh file and prints them to
10# stdout in a form that is suitable for including in a Makefile.  This removes
11# the requirement to manually keep the various Makefile macros in step with the
12# contents of config.sh.
13#
14
15if  [ -z "$1" -o ! -r "$1" ]; then
16	printf 'No config.sh file specified\n' >&2
17	exit 1
18fi
19typeset -r config=$1
20typeset -r perlsrc=cmd/perl/5.8.4
21
22# Pull in config.sh.
23set -e
24. $config
25set +e
26
27printf '# This file was automatically generated from %s by %s\n\n' \
28    $config $(basename $0)
29
30#
31# ON Makefile flag macro adjustments.  Perl needs to build/ship with a
32# consistent set of flags, and needs to build with the selected compilers.
33#
34printf 'C99MODE = $(C99_ENABLE)\n'
35printf 'COPTFLAG = %s\n' "$optimize"
36printf 'SPACEFLAG =\n'
37printf 'ILDOFF =\n'
38printf 'CERRWARN =\n'
39printf 'G_SHARED = %s\n' "$lddlflags"
40printf 'sparc_C_PICFLAGS = %s\n' "$cccdlflags"
41printf 'i386_C_PICFLAGS = %s\n' "$cccdlflags"
42printf 'C_PICFLAGS = %s\n' "$cccdlflags"
43printf 'DYNFLAGS += $(ZIGNORE)\n'
44printf 'CFLAGS += -_gcc=-w\n'
45
46# Global stuff.
47printf 'PERL_VERSION = %s\n' $version
48printf 'PERL_DISTRIB = $(SRC)/%s/distrib\n' $perlsrc
49printf 'PERL_CONTRIB = $(SRC)/%s/contrib\n' $perlsrc
50printf 'PERL_UTILS = $(SRC)/%s/utils\n' $perlsrc
51printf 'MINIPERL = $(PERL_DISTRIB)/miniperl\n'
52printf 'PERL_CONFIG_PM = $(PERL_DISTRIB)/lib/Config.pm\n'
53printf 'PERL_CONFIG_H = $(PERL_DISTRIB)/config.h\n'
54printf 'PERL_CONFIGDEP = $(PERL_CONFIG_H) $(PERL_CONFIG_PM)\n'
55
56# Directory locations.
57printf 'PERL_REAL_ROOT_STEM = %s\n' ${prefix%/$version}
58printf 'PERL_REAL_ROOT_DIR = %s\n' $prefix
59printf 'PERL_REAL_BIN_DIR = %s\n' $binexp
60printf 'PERL_REAL_ARCHLIB_DIR = %s\n' $archlibexp
61printf 'PERL_REAL_CORE_DIR = %s/CORE\n' $archlibexp
62printf 'PERL_REAL_SITE_DIR = %s\n' $sitearchexp
63printf 'PERL_REAL_VENDOR_DIR = %s\n' $vendorarchexp
64printf 'PERL_REAL_POD_DIR = %s/pod\n' $privlibexp
65
66# Directory locations relative to the current build $ROOT.
67printf 'PERL_ROOT_STEM = $(ROOT)%s\n' ${prefix%/$version}
68printf 'PERL_ROOT_DIR = $(ROOT)%s\n' $prefix
69printf 'PERL_BIN_DIR = $(ROOT)%s\n' $binexp
70printf 'PERL_ARCHLIB_DIR = $(ROOT)%s\n' $archlibexp
71printf 'PERL_CORE_DIR = $(ROOT)%s/CORE\n' $archlibexp
72printf 'PERL_SITE_DIR = $(ROOT)%s\n' $sitearchexp
73printf 'PERL_VENDOR_DIR = $(ROOT)%s\n' $vendorarchexp
74printf 'PERL_POD_DIR = $(ROOT)%s/pod\n' $privlibexp
75
76# Compilation environment flags.
77printf 'KEEP_STATE_OFF = unset KEEP_STATE SUNPRO_DEPENDENCIES || true\n'
78printf 'PERL_COREFLAGS = -DPERL_CORE\n'
79printf 'PERL_LFFLAGS = %s\n' "$ccflags_uselargefiles"
80printf 'PERL_LDLIBS = %s\n' "$perllibs"
81printf 'PERL_LD_ENV = LD_LIBRARY_PATH=$(PERL_DISTRIB); export LD_LIBRARY_PATH\n'
82printf 'PERL_LIB_ENV = PERL5LIB=$(PERL_UTILS)/lib:$(PERL_DISTRIB)/lib; '
83printf 'export PERL5LIB\n'
84printf 'PERL_MM_ENV = $(KEEP_STATE_OFF); unset VERSION || true; '
85printf '$(PERL_LIB_ENV)\n'
86printf "PERL_MM_ARGS = PERL_CORE=1 DEFINE='\$(DTEXTDOM)'\n"
87
88# Make sure we always run miniperl with the correct environment.
89printf 'RUN_MINIPERL = $(PERL_LD_ENV); $(PERL_LIB_ENV); $(MINIPERL)\n'
90