merge from master to elisp
[bpt/guile.git] / meta / uninstalled-env.in
1 #!/bin/sh
2
3 # Copyright (C) 2003, 2006, 2008, 2009 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="srfi 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 if test "${top_srcdir}" != "${top_builddir}"; then
52 GUILE_LOAD_PATH="${top_builddir}/guile-readline:${top_srcdir}/guile-readline:${top_builddir}:${top_srcdir}:${top_builddir}/module:${top_srcdir}/module"
53 else
54 GUILE_LOAD_PATH="${top_srcdir}/guile-readline:${top_srcdir}:${top_srcdir}/module:${top_srcdir}/module"
55 fi
56 else
57 for d in "${top_srcdir}" "${top_srcdir}/guile-readline" \
58 "${top_srcdir}/module" "${top_builddir}/module"
59 do
60 # This hair prevents double inclusion.
61 # The ":" prevents prefix aliasing.
62 case x"$GUILE_LOAD_PATH" in
63 x*${d}:*) ;;
64 *) GUILE_LOAD_PATH="${d}:$GUILE_LOAD_PATH" ;;
65 esac
66 done
67 fi
68 export GUILE_LOAD_PATH
69
70 if [ x"$GUILE_LOAD_COMPILED_PATH" = x ]
71 then
72 GUILE_LOAD_COMPILED_PATH="${top_builddir}/guile-readline:${top_builddir}:${top_builddir}/module"
73 else
74 for d in "${top_builddir}" "${top_builddir}/guile-readline" \
75 "${top_builddir}/module"
76 do
77 # This hair prevents double inclusion.
78 # The ":" prevents prefix aliasing.
79 case x"$GUILE_LOAD_COMPILED_PATH" in
80 x*${d}:*) ;;
81 *) GUILE_LOAD_COMPILED_PATH="${d}:$GUILE_LOAD_COMPILED_PATH" ;;
82 esac
83 done
84 fi
85 export GUILE_LOAD_COMPILED_PATH
86
87 # Don't look in installed dirs for guile modules
88 if ( env | grep -v -q -E '^GUILE_SYSTEM_COMPILED_PATH=' ); then
89 export GUILE_SYSTEM_COMPILED_PATH=
90 fi
91 # Don't look in installed dirs for dlopen-able modules
92 if ( env | grep -v -q -E '^GUILE_SYSTEM_EXTENSIONS_PATH=' ); then
93 export GUILE_SYSTEM_EXTENSIONS_PATH=
94 fi
95
96 # handle LTDL_LIBRARY_PATH (no clobber)
97 ltdl_prefix=""
98 dyld_prefix=""
99 for dir in $subdirs_with_ltlibs ; do
100 ltdl_prefix="${top_builddir}/${dir}:${ltdl_prefix}"
101 dyld_prefix="${top_builddir}/${dir}/.libs:${dyld_prefix}"
102 done
103 LTDL_LIBRARY_PATH="${ltdl_prefix}$LTDL_LIBRARY_PATH"
104 export LTDL_LIBRARY_PATH
105 DYLD_LIBRARY_PATH="${dyld_prefix}$DYLD_LIBRARY_PATH"
106 export DYLD_LIBRARY_PATH
107
108 if [ x"$PKG_CONFIG_PATH" = x ]
109 then
110 PKG_CONFIG_PATH="${top_builddir}/meta"
111 else
112 PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
113 fi
114 export PKG_CONFIG_PATH
115
116 # handle PATH (no clobber)
117 PATH="${top_builddir}/libguile:${PATH}"
118 PATH="${top_srcdir}/meta:${PATH}"
119 PATH="${top_builddir}/meta:${PATH}"
120 export PATH
121
122 exec "$@"