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