1 #! /bin/echo This file must be sourced inside (ba)sh using: .
5 # Shell initialization for the GNUstep environment.
7 # Copyright (C) 1997-2005 Free Software Foundation, Inc.
9 # Author: Scott Christley <scottc@net-community.com>
10 # Author: Adam Fedor <fedor@gnu.org>
11 # Author: Richard Frith-Macdonald <rfm@gnu.org>
12 # Author: Nicola Pero <n.pero@mi.flashnet.it>
14 # This file is part of the GNUstep Makefile Package.
16 # This library is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
21 # You should have received a copy of the GNU General Public
22 # License along with this library; see the file COPYING.LIB.
23 # If not, write to the Free Software Foundation,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 # Warning - this shell script is delicate, because it is sourced by
28 # using . rather than simply executed. It is sourced because that is
29 # the only way to change the shell variables in the calling
32 # Sourcing makes the shell script more delicate for the following reasons:
34 # * temporary variables are automatically set in the calling
35 # environment! WORKAROUND: we need to unset all them after using
36 # them to avoid polluting the calling environment;
38 # * not only the exit value of the script, but the exit value of each
39 # command we execute, might be interpreted by the calling
40 # environment. Typically, the calling environment might be using the
41 # shell errexit option ('set -e') in bash parlance, which causes the
42 # shell to exit if any command returns an error value. If this were
43 # a normal script, this option would mean that the shell would exit
44 # if the return value of the whole script were an error value; but
45 # because we are sourced, it is as all the commands in this script
46 # were executed directly in the calling environment, so *all* values
47 # returned by *all* commands must be non-error. [this all typically
48 # happens in rpm builds, where scripts are run with the errexit
49 # option so that errors in scripts abort the build, and now if a
50 # script sources GNUstep.sh, then we are exactly in this situation -
51 # if any command inside GNUstep.sh returns an error value (even if
52 # GNUstep.sh as a whole would be happy and return succes), the whole
53 # rpm build process aborts!]. WORKAROUND: we must make sure all
54 # commands return success - last resorts hacks like 'command || :'
55 # which always returns success whatever command returns.
58 # If we're running in zsh (auch!) make sure we're using -y
59 # (SH_WORD_SPLIT) else our path manipulations won't work.
60 if [ -n "$ZSH_VERSION" ]; then
62 # If -y is not already set, set it and remember that we
63 # need to set it back to what it was at the end.
64 if ( setopt | grep shwordsplit > /dev/null ); then :; else
66 GS_ZSH_NEED_TO_RESTORE_SET=yes
72 # Set the GNUstep system root and local root
76 # Read our configuration files
79 # Determine the location of the system configuration file
80 if [ -z "$GNUSTEP_CONFIG_FILE" ]; then
81 GNUSTEP_CONFIG_FILE=@GNUSTEP_CONFIG_FILE@
84 # Determine the location of the user configuration file
85 if [ -z "$GNUSTEP_USER_CONFIG_FILE" ]; then
86 GNUSTEP_USER_CONFIG_FILE=@GNUSTEP_USER_CONFIG_FILE@
89 # Read the system configuration file
90 if [ -f "$GNUSTEP_CONFIG_FILE" ]; then
91 . "$GNUSTEP_CONFIG_FILE"
94 # FIXME: determining GNUSTEP_HOME
97 # Read the user configuration file ... unless it is disabled (ie, set
99 if [ -n "$GNUSTEP_USER_CONFIG_FILE" ]; then
100 case "$GNUSTEP_USER_CONFIG_FILE" in
101 /*) # An absolute path
102 if [ -f "$GNUSTEP_USER_CONFIG_FILE" ]; then
103 . "$GNUSTEP_USER_CONFIG_FILE"
106 if [ -f "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE" ]; then
107 . "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE"
112 # Now, set any essential variable (that is not already set) to the
114 if [ -z "$GNUSTEP_SYSTEM_ROOT" ]; then
115 GNUSTEP_SYSTEM_ROOT=@GNUSTEP_SYSTEM_ROOT@
118 if [ -z "$GNUSTEP_LOCAL_ROOT" ]; then
119 GNUSTEP_LOCAL_ROOT=@GNUSTEP_LOCAL_ROOT@
122 if [ -z "$GNUSTEP_NETWORK_ROOT" ]; then
123 GNUSTEP_NETWORK_ROOT=@GNUSTEP_NETWORK_ROOT@
126 export GNUSTEP_SYSTEM_ROOT GNUSTEP_LOCAL_ROOT GNUSTEP_NETWORK_ROOT
128 GNUSTEP_FLATTENED=@GNUSTEP_FLATTENED@
129 if [ -z "$LIBRARY_COMBO" ]; then
130 LIBRARY_COMBO=@ac_cv_library_combo@
132 export GNUSTEP_FLATTENED LIBRARY_COMBO
134 if [ -z "$GNUSTEP_MAKEFILES" ]; then
135 GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/Library/Makefiles
137 export GNUSTEP_MAKEFILES
139 if [ -z "$GNUSTEP_USER_DIR" ]; then
140 GNUSTEP_USER_DIR=@GNUSTEP_USER_DIR@
144 # Set GNUSTEP_USER_ROOT which is the variable used in practice
146 case "$GNUSTEP_USER_DIR" in
147 /*) # An absolute path
148 GNUSTEP_USER_ROOT="$GNUSTEP_USER_DIR";;
150 GNUSTEP_USER_ROOT="$GNUSTEP_HOME/$GNUSTEP_USER_DIR";;
153 export GNUSTEP_USER_ROOT
158 # If multi-platform support is disabled, just use the hardcoded cpu,
159 # vendor and os determined when gnustep-make was configured. The
160 # reason using the hardcoded ones might be better is that config.guess
161 # and similar scripts might even require compiling test files to
162 # determine the platform - but then you can't source GNUstep.sh
163 # without having gcc, binutils, libc6-dev installed. Which can be a
164 # problem for end-users who are not developers and have no development
165 # tools installed. To prevent this problem, unless we were configured
166 # to determine the platform at run time, by default we use the
167 # hardcoded values of GNUSTEP_HOST*.
168 if [ -z "@GNUSTEP_MULTI_PLATFORM@" ]; then
169 GNUSTEP_HOST=@target@
170 GNUSTEP_HOST_CPU=@clean_target_cpu@
171 GNUSTEP_HOST_VENDOR=@clean_target_vendor@
172 GNUSTEP_HOST_OS=@clean_target_os@
176 # Determine the host information
178 if [ -z "$GNUSTEP_HOST" ]; then
179 # Not all shells (e.g. /bin/sh on FreeBSD < 4.0 or ash) have pushd/popd
180 tmpdir=`pwd`; cd /tmp
181 GNUSTEP_HOST=`$GNUSTEP_MAKEFILES/config.guess`
182 GNUSTEP_HOST=`$GNUSTEP_MAKEFILES/config.sub $GNUSTEP_HOST`
187 if [ -z "$GNUSTEP_HOST_CPU" ]; then
188 GNUSTEP_HOST_CPU=`$GNUSTEP_MAKEFILES/cpu.sh $GNUSTEP_HOST`
189 GNUSTEP_HOST_CPU=`$GNUSTEP_MAKEFILES/clean_cpu.sh $GNUSTEP_HOST_CPU`
192 if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
193 GNUSTEP_HOST_VENDOR=`$GNUSTEP_MAKEFILES/vendor.sh $GNUSTEP_HOST`
194 GNUSTEP_HOST_VENDOR=`$GNUSTEP_MAKEFILES/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
197 if [ -z "$GNUSTEP_HOST_OS" ]; then
198 GNUSTEP_HOST_OS=`$GNUSTEP_MAKEFILES/os.sh $GNUSTEP_HOST`
199 GNUSTEP_HOST_OS=`$GNUSTEP_MAKEFILES/clean_os.sh $GNUSTEP_HOST_OS`
202 export GNUSTEP_HOST GNUSTEP_HOST_CPU GNUSTEP_HOST_VENDOR GNUSTEP_HOST_OS
205 # GNUSTEP_PATHLIST is like an abstract path-like shell
206 # variable, which can be used to search the gnustep directories - and
207 # in these scripts, it is also used to set up other shell variables
209 if [ -z "$GNUSTEP_PATHLIST" ]; then
211 # If we need to convert win32 paths, this is the time!
212 if [ -z "`echo $GNUSTEP_SYSTEM_ROOT | sed 's|^[a-zA-Z]:/.*$||'`" ]; then
213 G_U_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_USER_ROOT"`
214 G_L_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_LOCAL_ROOT"`
215 G_N_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_NETWORK_ROOT"`
216 G_S_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_SYSTEM_ROOT"`
218 G_U_R="$GNUSTEP_USER_ROOT"
219 G_L_R="$GNUSTEP_LOCAL_ROOT"
220 G_N_R="$GNUSTEP_NETWORK_ROOT"
221 G_S_R="$GNUSTEP_SYSTEM_ROOT"
224 # Now we basically want to build
225 # GNUSTEP_PATHLIST="$G_U_R:$G_L_R:$G_N_R:$G_S_R"
226 # but we want to remove duplicates.
228 # Start with $G_U_R:$G_L_R - or $G_U_R if they are the same
229 if [ "$G_L_R" != "$G_U_R" ]; then
230 GNUSTEP_PATHLIST="$G_U_R:$G_L_R"
232 GNUSTEP_PATHLIST="$G_U_R"
235 # Now append $G_N_R but only if different from what already there
236 if [ "$G_N_R" != "$G_U_R" ]; then
237 if [ "$G_N_R" != "$G_L_R" ]; then
238 GNUSTEP_PATHLIST="$GNUSTEP_PATHLIST:$G_N_R"
242 # Now append $G_S_R but only if different from what already there
243 if [ "$G_S_R" != "$G_U_R" ]; then
244 if [ "$G_S_R" != "$G_L_R" ]; then
245 if [ "$G_S_R" != "$G_N_R" ]; then
246 GNUSTEP_PATHLIST="$GNUSTEP_PATHLIST:$G_S_R"
256 export GNUSTEP_PATHLIST
260 # Add path to Tools to PATH
265 for dir in $GNUSTEP_PATHLIST; do
267 # Prepare the path_fragment
268 if [ -z "$GNUSTEP_FLATTENED" ]; then
269 path_fragment="$dir/Tools:$dir/Tools/${GNUSTEP_HOST_CPU}/${GNUSTEP_HOST_OS}/${LIBRARY_COMBO}:$dir/Tools/${GNUSTEP_HOST_CPU}/${GNUSTEP_HOST_OS}"
271 path_fragment="$dir/Tools"
274 # Add it to temp_path
275 if [ -z "$temp_path" ]; then
276 temp_path="$path_fragment"
278 temp_path="$temp_path:$path_fragment"
287 if [ -z "$PATH" ]; then
290 if ( echo ${PATH}| grep -v "${temp_path}" >/dev/null ); then
291 PATH="${temp_path}:${PATH}"
297 . $GNUSTEP_MAKEFILES/ld_lib_path.sh
302 for dir in $GNUSTEP_PATHLIST; do
304 if [ -z "$gnustep_class_path" ]; then
305 gnustep_class_path="$dir/Library/Libraries/Java"
307 gnustep_class_path="$gnustep_class_path:$dir/Library/Libraries/Java"
315 if [ -z "$CLASSPATH" ]; then
316 CLASSPATH="$gnustep_class_path"
318 if ( echo ${CLASSPATH}| grep -v "${gnustep_class_path}" >/dev/null ); then
319 CLASSPATH="$CLASSPATH:$gnustep_class_path"
323 unset gnustep_class_path
327 # Setup path for loading guile modules too.
332 for dir in $GNUSTEP_PATHLIST; do
334 if [ -z "$guile_paths" ]; then
335 guile_paths="$dir/Library/Libraries/Guile"
337 guile_paths="$guile_paths:$dir/Library/Libraries/Guile"
345 if [ -z "$GUILE_LOAD_PATH" ]; then
346 GUILE_LOAD_PATH="$guile_paths"
348 if ( echo ${GUILE_LOAD_PATH}| grep -v "${guile_paths}" >/dev/null ); then
349 GUILE_LOAD_PATH="$guile_paths:$GUILE_LOAD_PATH"
352 export GUILE_LOAD_PATH
357 # Perform any user initialization
359 if [ -f "$GNUSTEP_USER_ROOT/GNUstep.sh" ]; then
360 . "$GNUSTEP_USER_ROOT/GNUstep.sh"
363 if [ -n "$GS_ZSH_NEED_TO_RESTORE_SET" ]; then