Leave $GUILE_LOAD_COMPILED_PATH unchanged when cross-compiling.
[bpt/guile.git] / meta / uninstalled-env.in
1 #!/bin/sh
2
3 # Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Free Software Foundation
4 #
5 # This file is part of GUILE.
6 #
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.
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
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301 USA
21
22 # NOTE: If you update this file, please update uninstalled.in as
23 # well, if appropriate.
24
25 # Usage: uninstalled-env [ARGS]
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
31 # Example: uninstalled-env guile -c '(display "hello\n")'
32 # Example: ../../uninstalled-env ./guile-test-foo
33
34 # config
35 subdirs_with_ltlibs="guile-readline libguile" # maintain me
36
37 # env (set by configure)
38 top_srcdir="@top_srcdir_absolute@"
39 top_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
49 if [ x"$GUILE_LOAD_PATH" = x ]
50 then
51 GUILE_LOAD_PATH="${top_srcdir}/module:${top_srcdir}/guile-readline:${top_srcdir}"
52 if test "${top_srcdir}" != "${top_builddir}"; then
53 GUILE_LOAD_PATH="$GUILE_LOAD_PATH:${top_builddir}/module:${top_builddir}/guile-readline:${top_builddir}"
54 fi
55 else
56 for d in "/module" "/guile-readline" ""
57 do
58 # This hair prevents double inclusion.
59 # The ":" prevents prefix aliasing.
60 case x"$GUILE_LOAD_PATH" in
61 x*${top_srcdir}${d}:*) ;;
62 x*${top_srcdir}${d}) ;;
63 *) GUILE_LOAD_PATH="${top_srcdir}${d}:$GUILE_LOAD_PATH" ;;
64 esac
65 case x"$GUILE_LOAD_PATH" in
66 x*${top_builddir}${d}:*) ;;
67 x*${top_builddir}${d}) ;;
68 *) GUILE_LOAD_PATH="${top_builddir}${d}:$GUILE_LOAD_PATH" ;;
69 esac
70 done
71 fi
72 export GUILE_LOAD_PATH
73
74 # When cross-compiling, let $GUILE_FOR_BUILD use its own .go files since
75 # the ones that are being built may be incompatible.
76 if test "@cross_compiling@" = "no"
77 then
78 if test "x$GUILE_LOAD_COMPILED_PATH" = "x"
79 then
80 GUILE_LOAD_COMPILED_PATH="${top_builddir}/module:${top_builddir}/guile-readline:${top_builddir}"
81 else
82 for d in "/module" "/guile-readline" ""
83 do
84 # This hair prevents double inclusion.
85 # The ":" prevents prefix aliasing.
86 case x"$GUILE_LOAD_COMPILED_PATH" in
87 x*${top_builddir}${d}:*) ;;
88 x*${top_builddir}${d}) ;;
89 *) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}:$GUILE_LOAD_COMPILED_PATH" ;;
90 esac
91 done
92 fi
93 export GUILE_LOAD_COMPILED_PATH
94 fi
95
96 # Don't look in installed dirs for guile modules
97 if ( env | grep -v '^GUILE_SYSTEM_PATH=' > /dev/null ); then
98 GUILE_SYSTEM_PATH=
99 export GUILE_SYSTEM_PATH
100 fi
101 # Don't look in installed dirs for compiled guile modules
102 if ( env | grep -v '^GUILE_SYSTEM_COMPILED_PATH=' > /dev/null ); then
103 GUILE_SYSTEM_COMPILED_PATH=
104 export GUILE_SYSTEM_COMPILED_PATH
105 fi
106 # Don't look in installed dirs for dlopen-able modules
107 if ( env | grep -v '^GUILE_SYSTEM_EXTENSIONS_PATH=' > /dev/null ); then
108 GUILE_SYSTEM_EXTENSIONS_PATH=
109 export GUILE_SYSTEM_EXTENSIONS_PATH
110 fi
111
112 # handle LTDL_LIBRARY_PATH (no clobber)
113 for dir in $subdirs_with_ltlibs ; do
114 if test -z "$LTDL_LIBRARY_PATH"; then
115 LTDL_LIBRARY_PATH="${top_builddir}/${dir}"
116 else
117 LTDL_LIBRARY_PATH="${top_builddir}/${dir}:${LTDL_LIBRARY_PATH}"
118 fi
119 if test -z "$DYLD_LIBRARY_PATH"; then
120 DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs"
121 else
122 DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs:${DYLD_LIBRARY_PATH}"
123 fi
124 done
125 export LTDL_LIBRARY_PATH
126 export DYLD_LIBRARY_PATH
127
128 if [ x"$PKG_CONFIG_PATH" = x ]
129 then
130 PKG_CONFIG_PATH="${top_builddir}/meta"
131 else
132 PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
133 fi
134 export PKG_CONFIG_PATH
135
136 # handle PATH (no clobber)
137 PATH="${top_builddir}/libguile:${PATH}"
138 PATH="${top_srcdir}/meta:${PATH}"
139 if test "x${top_srcdir}" != "x${top_builddir}"; then
140 PATH="${top_builddir}/meta:${PATH}"
141 fi
142 export PATH
143
144 # Define $GUILE, used by `guild'.
145 GUILE="${top_builddir}/meta/guile"
146 export GUILE
147
148 exec "$@"