Merge commit 'd364a8971828e38e8f9112b711066f4962bb400e'
[bpt/guile.git] / meta / uninstalled-env.in
CommitLineData
c8eb6d1f
RB
1#!/bin/sh
2
d10f7b57 3# Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation
c8eb6d1f
RB
4#
5# This file is part of GUILE.
6#
53befeb7
NJ
7# This script is free software; you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as
9# published by the Free Software Foundation; either version 3 of the
10# License, or (at your option) any later version.
c8eb6d1f
RB
11#
12# This library is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public
18# License along with this library; if not, write to the Free Software
53befeb7
NJ
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20# 02110-1301 USA
c8eb6d1f 21
0b6d8fdc 22# NOTE: If you update this file, please update uninstalled.in as
c8eb6d1f
RB
23# well, if appropriate.
24
0b6d8fdc 25# Usage: uninstalled-env [ARGS]
c8eb6d1f
RB
26
27# This script arranges for the environment to support running Guile
28# from the build tree. The following env vars are modified (but not
29# clobbered): GUILE_LOAD_PATH, LTDL_LIBRARY_PATH, and PATH.
30
0b6d8fdc
AW
31# Example: uninstalled-env guile -c '(display "hello\n")'
32# Example: ../../uninstalled-env ./guile-test-foo
c8eb6d1f
RB
33
34# config
60904831 35subdirs_with_ltlibs="guile-readline libguile" # maintain me
c8eb6d1f
RB
36
37# env (set by configure)
38top_srcdir="@top_srcdir_absolute@"
39top_builddir="@top_builddir_absolute@"
40
41[ x"$top_srcdir" = x -o ! -d "$top_srcdir" -o \
42 x"$top_builddir" = x -o ! -d "$top_builddir" ] && {
43 echo $0: bad environment
44 echo top_srcdir=$top_srcdir
45 echo top_builddir=$top_builddir
46 exit 1
47}
48
adf8616f 49# When cross-compiling, let $GUILE_FOR_BUILD use its own .go files since
f7012874
LC
50# the ones that are being built may be incompatible ($GUILE_FOR_BUILD is
51# typically used to run `guild compile --target=$host'.) Likewise,
52# $GUILE_FOR_BUILD must use its own source files when booting; for
53# instance, $srcdir/module/ice-9/boot-9.scm must not be in its search
54# path, because it would then end up using its C evaluator to run the
55# compiler.
adf8616f 56if test "@cross_compiling@" = "no"
d1e47c6e 57then
f7012874
LC
58 if [ x"$GUILE_LOAD_PATH" = x ]
59 then
d10f7b57 60 GUILE_LOAD_PATH="${top_srcdir}/module:${top_srcdir}/guile-readline"
f7012874 61 if test "${top_srcdir}" != "${top_builddir}"; then
d10f7b57 62 GUILE_LOAD_PATH="$GUILE_LOAD_PATH:${top_builddir}/module:${top_builddir}/guile-readline"
f7012874
LC
63 fi
64 else
d10f7b57 65 for d in "/module" "/guile-readline"
f7012874
LC
66 do
67 # This hair prevents double inclusion.
68 # The ":" prevents prefix aliasing.
69 case x"$GUILE_LOAD_PATH" in
70 x*${top_srcdir}${d}:*) ;;
71 x*${top_srcdir}${d}) ;;
72 *) GUILE_LOAD_PATH="${top_srcdir}${d}:$GUILE_LOAD_PATH" ;;
73 esac
74 case x"$GUILE_LOAD_PATH" in
75 x*${top_builddir}${d}:*) ;;
76 x*${top_builddir}${d}) ;;
77 *) GUILE_LOAD_PATH="${top_builddir}${d}:$GUILE_LOAD_PATH" ;;
78 esac
79 done
80 fi
81 export GUILE_LOAD_PATH
82
adf8616f
LC
83 if test "x$GUILE_LOAD_COMPILED_PATH" = "x"
84 then
d10f7b57 85 GUILE_LOAD_COMPILED_PATH="${top_builddir}/module:${top_builddir}/guile-readline"
adf8616f 86 else
d10f7b57 87 for d in "/module" "/guile-readline"
adf8616f
LC
88 do
89 # This hair prevents double inclusion.
90 # The ":" prevents prefix aliasing.
91 case x"$GUILE_LOAD_COMPILED_PATH" in
92 x*${top_builddir}${d}:*) ;;
93 x*${top_builddir}${d}) ;;
94 *) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}:$GUILE_LOAD_COMPILED_PATH" ;;
95 esac
96 done
97 fi
98 export GUILE_LOAD_COMPILED_PATH
d1e47c6e 99
f7012874
LC
100 # Don't look in installed dirs for guile modules
101 if ( env | grep -v '^GUILE_SYSTEM_PATH=' > /dev/null ); then
102 GUILE_SYSTEM_PATH=
103 export GUILE_SYSTEM_PATH
104 fi
105 # Don't look in installed dirs for compiled guile modules
106 if ( env | grep -v '^GUILE_SYSTEM_COMPILED_PATH=' > /dev/null ); then
107 GUILE_SYSTEM_COMPILED_PATH=
108 export GUILE_SYSTEM_COMPILED_PATH
109 fi
110 # Don't look in installed dirs for dlopen-able modules
111 if ( env | grep -v '^GUILE_SYSTEM_EXTENSIONS_PATH=' > /dev/null ); then
112 GUILE_SYSTEM_EXTENSIONS_PATH=
113 export GUILE_SYSTEM_EXTENSIONS_PATH
114 fi
eb350124 115fi
02b84691 116
c8eb6d1f 117# handle LTDL_LIBRARY_PATH (no clobber)
c8eb6d1f 118for dir in $subdirs_with_ltlibs ; do
070d8db0
AW
119 if test -z "$LTDL_LIBRARY_PATH"; then
120 LTDL_LIBRARY_PATH="${top_builddir}/${dir}"
121 else
122 LTDL_LIBRARY_PATH="${top_builddir}/${dir}:${LTDL_LIBRARY_PATH}"
123 fi
124 if test -z "$DYLD_LIBRARY_PATH"; then
125 DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs"
126 else
127 DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs:${DYLD_LIBRARY_PATH}"
128 fi
c8eb6d1f 129done
c8eb6d1f 130export LTDL_LIBRARY_PATH
027e0e2c 131export DYLD_LIBRARY_PATH
c8eb6d1f 132
0b6d8fdc
AW
133if [ x"$PKG_CONFIG_PATH" = x ]
134then
275baf01 135 PKG_CONFIG_PATH="${top_builddir}/meta"
0b6d8fdc 136else
275baf01 137 PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
0b6d8fdc
AW
138fi
139export PKG_CONFIG_PATH
140
c8eb6d1f 141# handle PATH (no clobber)
c8eb6d1f 142PATH="${top_builddir}/libguile:${PATH}"
d4876cb4 143PATH="${top_srcdir}/meta:${PATH}"
d8e1bce4 144if test "x${top_srcdir}" != "x${top_builddir}"; then
070d8db0
AW
145 PATH="${top_builddir}/meta:${PATH}"
146fi
c8eb6d1f
RB
147export PATH
148
f4b7d918
LC
149# Define $GUILE, used by `guild'.
150GUILE="${top_builddir}/meta/guile"
151export GUILE
152
c8eb6d1f 153exec "$@"