xref: /openbsd/gnu/usr.bin/perl/Policy_sh.SH (revision 91f110e0)
1*91f110e0Safresh1#!/bin/sh
2*91f110e0Safresh1
355745691Smillertcase $PERL_CONFIG_SH in
40a5f61bbSmillert'') . ./config.sh ;;
50a5f61bbSmillertesac
60a5f61bbSmillertecho "Extracting Policy.sh (with variable substitutions)"
70a5f61bbSmillert$spitshell <<!GROK!THIS! >Policy.sh
80a5f61bbSmillert$startsh
90a5f61bbSmillert#
100a5f61bbSmillert#  This file was produced by running the Policy_sh.SH script, which
110a5f61bbSmillert#  gets its values from config.sh, which is generally produced by
12c48bdce4Smillert#  running Configure.
130a5f61bbSmillert#
140a5f61bbSmillert#  The idea here is to distill in one place the common site-wide
150a5f61bbSmillert#  "policy" answers (such as installation directories) that are
160a5f61bbSmillert#  to be "sticky".  If you keep the file Policy.sh around in
170a5f61bbSmillert#  the same directory as you are building Perl, then Configure will
180a5f61bbSmillert#  (by default) load up the Policy.sh file just before the
19c48bdce4Smillert#  platform-specific hints file and rewrite it at the end.
200a5f61bbSmillert#
21c48bdce4Smillert#   The sequence of events is as follows:
22c48bdce4Smillert#   A:  If you are NOT re-using an old config.sh:
23c48bdce4Smillert#   1.  At start-up, Configure loads up the defaults from the
24c48bdce4Smillert#	os-specific  hints/osname_osvers.sh file and any previous
25c48bdce4Smillert#	Policy.sh file.
26c48bdce4Smillert#   2.  At the end, Configure runs Policy_sh.SH, which creates
27c48bdce4Smillert#	Policy.sh, overwriting a previous Policy.sh if necessary.
28c48bdce4Smillert#
29c48bdce4Smillert#   B: If you are re-using an old config.sh:
30c48bdce4Smillert#   1.  At start-up, Configure loads up the defaults from config.sh,
31c48bdce4Smillert#	ignoring any previous Policy.sh file.
32c48bdce4Smillert#   2.  At the end, Configure runs Policy_sh.SH, which creates
33c48bdce4Smillert#	Policy.sh, overwriting a previous Policy.sh if necessary.
34c48bdce4Smillert#
35c48bdce4Smillert#  Thus the Policy.sh file gets overwritten each time
36c48bdce4Smillert#  Configure is run.  Any variables you add to Policy.sh will be lost
37c48bdce4Smillert#  unless you copy Policy.sh somewhere else before running Configure.
38c48bdce4Smillert#
390a5f61bbSmillert#  Allow Configure command-line overrides; usually these won't be
400a5f61bbSmillert#  needed, but something like -Dprefix=/test/location can be quite
410a5f61bbSmillert#  useful for testing out new versions.
420a5f61bbSmillert
430a5f61bbSmillert#Site-specific values:
440a5f61bbSmillert
450a5f61bbSmillertcase "\$perladmin" in
460a5f61bbSmillert'') perladmin='$perladmin' ;;
470a5f61bbSmillertesac
480a5f61bbSmillert
49c8ca9003Smillert# Installation prefixes.  Allow a Configure -D override.  You
500a5f61bbSmillert# may wish to reinstall perl under a different prefix, perhaps
510a5f61bbSmillert# in order to test a different configuration.
52c8ca9003Smillert# For an explanation of the installation directories, see the
53c8ca9003Smillert# INSTALL file section on "Installation Directories".
540a5f61bbSmillertcase "\$prefix" in
550a5f61bbSmillert'') prefix='$prefix' ;;
560a5f61bbSmillertesac
57c48bdce4Smillert
58c48bdce4Smillert# By default, the next three are the same as \$prefix.
59c48bdce4Smillert# If the user changes \$prefix, and previously \$siteprefix was the
60c48bdce4Smillert# same as \$prefix, then change \$siteprefix as well.
61c48bdce4Smillert# Use similar logic for \$vendorprefix and \$installprefix.
62c48bdce4Smillert
63c8ca9003Smillertcase "\$siteprefix" in
64c48bdce4Smillert'') if test "$siteprefix" = "$prefix"; then
65c48bdce4Smillert	siteprefix="\$prefix"
66c48bdce4Smillert    else
67c48bdce4Smillert	siteprefix='$siteprefix'
68c48bdce4Smillert    fi
69c48bdce4Smillert    ;;
70c8ca9003Smillertesac
71c8ca9003Smillertcase "\$vendorprefix" in
72c48bdce4Smillert'') if test "$vendorprefix" = "$prefix"; then
73c48bdce4Smillert	vendorprefix="\$prefix"
74c48bdce4Smillert    else
75c48bdce4Smillert	vendorprefix='$vendorprefix'
76c48bdce4Smillert    fi
77c48bdce4Smillert    ;;
78c8ca9003Smillertesac
79c8ca9003Smillert
80c8ca9003Smillert# Where installperl puts things.
81c8ca9003Smillertcase "\$installprefix" in
82c48bdce4Smillert'') if test "$installprefix" = "$prefix"; then
83c48bdce4Smillert	installprefix="\$prefix"
84c48bdce4Smillert    else
85c48bdce4Smillert	installprefix='$installprefix'
86c48bdce4Smillert    fi
87c48bdce4Smillert    ;;
88c8ca9003Smillertesac
890a5f61bbSmillert
900a5f61bbSmillert# Installation directives.  Note that each one comes in three flavors.
910a5f61bbSmillert# For example, we have privlib, privlibexp, and installprivlib.
920a5f61bbSmillert# privlib is for private (to perl) library files.
930a5f61bbSmillert# privlibexp is the same, except any '~' the user gave to Configure
940a5f61bbSmillert#     is expanded to the user's home directory.  This is figured
950a5f61bbSmillert#     out automatically by Configure, so you don't have to include it here.
960a5f61bbSmillert# installprivlib is for systems (such as those running AFS) that
970a5f61bbSmillert#     need to distinguish between the place where things
98c8ca9003Smillert#     get installed and where they finally will reside.  As of 5.005_6x,
99c8ca9003Smillert#     this too is handled automatically by Configure based on
100c8ca9003Smillert#     $installprefix, so it isn't included here either.
101c8ca9003Smillert#
102c8ca9003Smillert# Note also that there are three broad hierarchies of installation
103c8ca9003Smillert# directories, as discussed in the INSTALL file under
104c8ca9003Smillert# "Installation Directories":
105c8ca9003Smillert#
106c8ca9003Smillert#  =item Directories for the perl distribution
107c8ca9003Smillert#
108c8ca9003Smillert#  =item Directories for site-specific add-on files
109c8ca9003Smillert#
110c8ca9003Smillert#  =item Directories for vendor-supplied add-on files
111c8ca9003Smillert#
112c8ca9003Smillert#  See Porting/Glossary for the definitions of these names, and see the
113c8ca9003Smillert#  INSTALL file for further explanation and some examples.
1140a5f61bbSmillert#
1150a5f61bbSmillert# In each case, if your previous value was the default, leave it commented
1160a5f61bbSmillert# out.  That way, if you override prefix, all of these will be
1170a5f61bbSmillert# automatically adjusted.
1180a5f61bbSmillert#
1190a5f61bbSmillert# WARNING:  Be especially careful about architecture-dependent and
1200a5f61bbSmillert# version-dependent names, particularly if you reuse this file for
1210a5f61bbSmillert# different versions of perl.
1220a5f61bbSmillert
1230a5f61bbSmillert!GROK!THIS!
1240a5f61bbSmillert
12585009909Smillert# Set the following variables.  Mention them here so metaconfig
12685009909Smillert# includes the appropriate code in Configure
12785009909Smillert#   $bin $scriptdir $privlib $archlib
12885009909Smillert#	$man1dir $man3dir $html1dir $html3dir
12985009909Smillert#   $sitebin $sitescript $sitelib $sitearch
13085009909Smillert#	$siteman1dir $siteman3dir $sitehtml1dir $sitehtml3dir
13185009909Smillert#   $vendorbin $vendorscript $vendorlib $vendorarch
13285009909Smillert#	$vendorman1dir $vendorman3dir $vendorhtml1dir $vendorhtml3dir
13385009909Smillert
134c8ca9003Smillertfor var in \
135898184e3Ssthen	bin scriptdir privlib archlib man1dir man3dir man1ext man3ext \
136898184e3Ssthen	html1dir html3dir \
137c8ca9003Smillert	sitebin sitescript sitelib sitearch \
13885009909Smillert		siteman1dir siteman3dir sitehtml1dir sitehtml3dir \
139c8ca9003Smillert	vendorbin vendorscript vendorlib vendorarch \
14085009909Smillert		vendorman1dir vendorman3dir vendorhtml1dir vendorhtml3dir
141c8ca9003Smillertdo
1420a5f61bbSmillert
1430a5f61bbSmillert    case "$var" in
144c8ca9003Smillert
145c8ca9003Smillert    # Directories for the core perl components
1460a5f61bbSmillert    bin)	dflt=$prefix/bin ;;
1470a5f61bbSmillert    # The scriptdir test is more complex, but this is probably usually ok.
1480a5f61bbSmillert    scriptdir)
1490a5f61bbSmillert	if $test -d $prefix/script; then
1500a5f61bbSmillert	    dflt=$prefix/script
1510a5f61bbSmillert	else
1520a5f61bbSmillert	    dflt=$bin
1530a5f61bbSmillert	fi
1540a5f61bbSmillert	;;
1550a5f61bbSmillert    privlib)
1560a5f61bbSmillert	case "$prefix" in
1570a5f61bbSmillert	*perl*)	dflt=$prefix/lib/$version ;;
1580a5f61bbSmillert	*)	dflt=$prefix/lib/$package/$version ;;
1590a5f61bbSmillert	esac
1600a5f61bbSmillert	;;
161c8ca9003Smillert    archlib)	dflt="$privlib/$archname" ;;
1620a5f61bbSmillert
163c8ca9003Smillert    man1dir)	dflt="$prefix/man/man1" ;;
164c8ca9003Smillert    man3dir)	dflt="$prefix/man/man3" ;;
1650a5f61bbSmillert    # Can we assume all sed's have greedy matching?
1660a5f61bbSmillert    man1ext)	dflt=`echo $man1dir | sed -e 's!.*man!!' -e 's!^\.!!'` ;;
1670a5f61bbSmillert    man3ext)	dflt=`echo $man3dir | sed -e 's!.*man!!' -e 's!^\.!!'` ;;
1680a5f61bbSmillert
169c8ca9003Smillert    # We don't know what to do with these yet.
170c8ca9003Smillert    html1dir)	dflt='' ;;
171898184e3Ssthen    html3dir)	dflt='' ;;
172c8ca9003Smillert
173c8ca9003Smillert    # Directories for site-specific add-on files
174c8ca9003Smillert    sitebin)	dflt=$siteprefix/bin ;;
175c8ca9003Smillert    sitescript)
176c8ca9003Smillert	if $test -d $siteprefix/script; then
177c8ca9003Smillert	    dflt=$siteprefix/script
178c8ca9003Smillert	else
179c8ca9003Smillert	    dflt=$sitebin
180c8ca9003Smillert	fi
181c8ca9003Smillert	;;
182c8ca9003Smillert    sitelib)
183c8ca9003Smillert	case "$siteprefix" in
184c8ca9003Smillert	*perl*)	dflt=$prefix/lib/site_perl/$version ;;
185c8ca9003Smillert	*)	dflt=$prefix/lib/$package/site_perl/$version ;;
186c8ca9003Smillert	esac
187c8ca9003Smillert	;;
188c8ca9003Smillert    sitearch)	dflt="$sitelib/$archname" ;;
189c8ca9003Smillert
190898184e3Ssthen    siteman1dir) dflt="$siteprefix/man/man1" ;;
191898184e3Ssthen    siteman3dir) dflt="$siteprefix/man/man3" ;;
192c8ca9003Smillert    # We don't know what to do with these yet.
193898184e3Ssthen    sitehtml1dir)	dflt='' ;;
194898184e3Ssthen    sitehtml3dir)	dflt='' ;;
195c8ca9003Smillert
196c8ca9003Smillert    # Directories for vendor-supplied add-on files
197c8ca9003Smillert    # These are all usually empty.
198c8ca9003Smillert    vendor*)
199c8ca9003Smillert	if test X"$vendorprefix" = X""; then
200c8ca9003Smillert	    dflt=''
201c8ca9003Smillert	else
202c8ca9003Smillert	    case "$var" in
203c8ca9003Smillert	    vendorbin)	dflt=$vendorprefix/bin ;;
204c8ca9003Smillert	    vendorscript)
205c8ca9003Smillert		if $test -d $vendorprefix/script; then
206c8ca9003Smillert		    dflt=$vendorprefix/script
207c8ca9003Smillert		else
208c8ca9003Smillert		    dflt=$vendorbin
209c8ca9003Smillert		fi
210c8ca9003Smillert		;;
211c8ca9003Smillert	    vendorlib)
212c8ca9003Smillert		case "$vendorprefix" in
213c8ca9003Smillert		*perl*)	dflt=$prefix/lib/vendor_perl/$version ;;
214c8ca9003Smillert		*)	dflt=$prefix/lib/$package/vendor_perl/$version ;;
215c8ca9003Smillert		esac
216c8ca9003Smillert		;;
217c8ca9003Smillert	    vendorarch)	dflt="$vendorlib/$archname" ;;
218c8ca9003Smillert
219898184e3Ssthen	    vendorman1dir)	dflt="$vendorprefix/man/man1" ;;
220898184e3Ssthen	    vendorman3dir)	dflt="$vendorprefix/man/man3" ;;
221c8ca9003Smillert	    # We don't know what to do with these yet.
222898184e3Ssthen	    vendorhtml1dir)	dflt='' ;;
223898184e3Ssthen	    vendorhtml3dir)	dflt='' ;;
224c8ca9003Smillert
225c8ca9003Smillert	    esac  # End of vendorprefix != ''
226c8ca9003Smillert	fi
227c8ca9003Smillert	;;
2280a5f61bbSmillert    esac
2290a5f61bbSmillert
2300a5f61bbSmillert    eval val="\$$var"
2310a5f61bbSmillert    if test X"$val" = X"$dflt"; then
2320a5f61bbSmillert	echo "# $var='$dflt'"
2330a5f61bbSmillert    else
2340a5f61bbSmillert	echo "# Preserving custom $var"
2350a5f61bbSmillert	echo "$var='$val'"
2360a5f61bbSmillert    fi
2370a5f61bbSmillert
2380a5f61bbSmillertdone >> Policy.sh
2390a5f61bbSmillert
2400a5f61bbSmillert$spitshell <<!GROK!THIS! >>Policy.sh
2410a5f61bbSmillert
2420a5f61bbSmillert#  Lastly, you may add additional items here.  For example, to set the
2430a5f61bbSmillert#  pager to your local favorite value, uncomment the following line in
2440a5f61bbSmillert#  the original Policy_sh.SH file and re-run   sh Policy_sh.SH.
2450a5f61bbSmillert#
2460a5f61bbSmillert#  pager='$pager'
2470a5f61bbSmillert#
2480a5f61bbSmillert#  A full Glossary of all the config.sh variables is in the file
2490a5f61bbSmillert#  Porting/Glossary.
2500a5f61bbSmillert
2510a5f61bbSmillert!GROK!THIS!
2520a5f61bbSmillert
2530a5f61bbSmillert#Credits:
2540a5f61bbSmillert#   The original design for this Policy.sh file came from Wayne Davison,
2550a5f61bbSmillert#   maintainer of trn.
2560a5f61bbSmillert#   This version for Perl5.004_61 originally written by
257c8ca9003Smillert#   Andy Dougherty <doughera@lafayette.edu>.
2580a5f61bbSmillert#   This file may be distributed under the same terms as Perl itself.
259