1 #! /bin/echo This file must be sourced inside (ba)sh using: .
5 # Shell initialization for the GNUstep environment.
7 # Copyright (C) 1997-2002 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 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
74 GNUSTEP_ROOT=@GNUSTEP_ROOT@
75 GNUSTEP_SYSTEM_ROOT=@prefix@
76 GNUSTEP_FLATTENED=@GNUSTEP_FLATTENED@
77 if [ -z "$LIBRARY_COMBO" ]; then
78 LIBRARY_COMBO=@ac_cv_library_combo@
80 export GNUSTEP_ROOT GNUSTEP_SYSTEM_ROOT GNUSTEP_FLATTENED LIBRARY_COMBO
82 GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@
83 export GNUSTEP_MAKEFILES
85 GNUSTEP_LOCAL_ROOT=@GNUSTEP_LOCAL_ROOT@
86 GNUSTEP_NETWORK_ROOT=@GNUSTEP_NETWORK_ROOT@
87 export GNUSTEP_LOCAL_ROOT GNUSTEP_NETWORK_ROOT
89 # If multi-platform support is disabled, just use the hardcoded cpu,
90 # vendor and os determined when gnustep-make was configured. The
91 # reason using the hardcoded ones might be better is that config.guess
92 # and similar scripts might even require compiling test files to
93 # determine the platform - but then you can't source GNUstep.sh
94 # without having gcc, binutils, libc6-dev installed. Which can be a
95 # problem for end-users who are not developers and have no development
96 # tools installed. To prevent this problem, unless we were configured
97 # to determine the platform at run time, by default we use the
98 # hardcoded values of GNUSTEP_HOST*.
99 if [ -z "@GNUSTEP_MULTI_PLATFORM@" ]; then
100 GNUSTEP_HOST=@target@
101 GNUSTEP_HOST_CPU=@clean_target_cpu@
102 GNUSTEP_HOST_VENDOR=@clean_target_vendor@
103 GNUSTEP_HOST_OS=@clean_target_os@
107 # Determine the host information
109 if [ -z "$GNUSTEP_HOST" ]; then
110 # Not all shells (e.g. /bin/sh on FreeBSD < 4.0 or ash) have pushd/popd
111 tmpdir=`pwd`; cd /tmp
112 GNUSTEP_HOST=`$GNUSTEP_MAKEFILES/config.guess`
113 GNUSTEP_HOST=`$GNUSTEP_MAKEFILES/config.sub $GNUSTEP_HOST`
118 if [ -z "$GNUSTEP_HOST_CPU" ]; then
119 GNUSTEP_HOST_CPU=`$GNUSTEP_MAKEFILES/cpu.sh $GNUSTEP_HOST`
120 GNUSTEP_HOST_CPU=`$GNUSTEP_MAKEFILES/clean_cpu.sh $GNUSTEP_HOST_CPU`
123 if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
124 GNUSTEP_HOST_VENDOR=`$GNUSTEP_MAKEFILES/vendor.sh $GNUSTEP_HOST`
125 GNUSTEP_HOST_VENDOR=`$GNUSTEP_MAKEFILES/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
128 if [ -z "$GNUSTEP_HOST_OS" ]; then
129 GNUSTEP_HOST_OS=`$GNUSTEP_MAKEFILES/os.sh $GNUSTEP_HOST`
130 GNUSTEP_HOST_OS=`$GNUSTEP_MAKEFILES/clean_os.sh $GNUSTEP_HOST_OS`
133 export GNUSTEP_HOST GNUSTEP_HOST_CPU GNUSTEP_HOST_VENDOR GNUSTEP_HOST_OS
136 # Ask the user_home tool for the root path.
138 if [ -z "$GNUSTEP_FLATTENED" ]; then
139 GNUSTEP_USER_ROOT=`$GNUSTEP_MAKEFILES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/user_home user`
141 GNUSTEP_USER_ROOT=`$GNUSTEP_MAKEFILES/user_home user`
144 export GNUSTEP_USER_ROOT
147 # GNUSTEP_PATHLIST is like an abstract path-like shell
148 # variable, which can be used to search the gnustep directories - and
149 # in these scripts, it is also used to set up other shell variables
151 if [ -z "$GNUSTEP_PATHLIST" ]; then
153 # If we need to convert win32 paths, this is the time!
154 if [ -z "`echo $GNUSTEP_SYSTEM_ROOT | sed 's|^[a-zA-Z]:/.*$||'`" ]; then
155 G_U_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_USER_ROOT"`
156 G_L_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_LOCAL_ROOT"`
157 G_N_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_NETWORK_ROOT"`
158 G_S_R=`$GNUSTEP_MAKEFILES/fixpath.sh -u "$GNUSTEP_SYSTEM_ROOT"`
160 G_U_R="$GNUSTEP_USER_ROOT"
161 G_L_R="$GNUSTEP_LOCAL_ROOT"
162 G_N_R="$GNUSTEP_NETWORK_ROOT"
163 G_S_R="$GNUSTEP_SYSTEM_ROOT"
166 # Now we basically want to build
167 # GNUSTEP_PATHLIST="$G_U_R:$G_L_R:$G_N_R:$G_S_R"
168 # but we want to remove duplicates.
170 # Start with $G_U_R:$G_L_R - or $G_U_R if they are the same
171 if [ "$G_L_R" != "$G_U_R" ]; then
172 GNUSTEP_PATHLIST="$G_U_R:$G_L_R"
174 GNUSTEP_PATHLIST="$G_U_R"
177 # Now append $G_N_R but only if different from what already there
178 if [ "$G_N_R" != "$G_U_R" ]; then
179 if [ "$G_N_R" != "$G_L_R" ]; then
180 GNUSTEP_PATHLIST="$GNUSTEP_PATHLIST:$G_N_R"
184 # Now append $G_S_R but only if different from what already there
185 if [ "$G_S_R" != "$G_U_R" ]; then
186 if [ "$G_S_R" != "$G_L_R" ]; then
187 if [ "$G_S_R" != "$G_N_R" ]; then
188 GNUSTEP_PATHLIST="$GNUSTEP_PATHLIST:$G_S_R"
198 export GNUSTEP_PATHLIST
202 # Add path to Tools to PATH
207 for dir in $GNUSTEP_PATHLIST; do
209 # Prepare the path_fragment
210 if [ -z "$GNUSTEP_FLATTENED" ]; then
211 path_fragment="$dir/Tools:$dir/Tools/${GNUSTEP_HOST_CPU}/${GNUSTEP_HOST_OS}/${LIBRARY_COMBO}:$dir/Tools/${GNUSTEP_HOST_CPU}/${GNUSTEP_HOST_OS}"
213 path_fragment="$dir/Tools"
216 # Add it to temp_path
217 if [ -z "$temp_path" ]; then
218 temp_path="$path_fragment"
220 temp_path="$temp_path:$path_fragment"
229 if [ -z "$PATH" ]; then
232 if ( echo ${PATH}| grep -v "${temp_path}" >/dev/null ); then
233 PATH="${temp_path}:${PATH}"
239 . $GNUSTEP_MAKEFILES/ld_lib_path.sh
244 for dir in $GNUSTEP_PATHLIST; do
246 if [ -z "$gnustep_class_path" ]; then
247 gnustep_class_path="$dir/Library/Libraries/Java"
249 gnustep_class_path="$gnustep_class_path:$dir/Library/Libraries/Java"
257 if [ -z "$CLASSPATH" ]; then
258 CLASSPATH="$gnustep_class_path"
260 if ( echo ${CLASSPATH}| grep -v "${gnustep_class_path}" >/dev/null ); then
261 CLASSPATH="$CLASSPATH:$gnustep_class_path"
265 unset gnustep_class_path
269 # Setup path for loading guile modules too.
274 for dir in $GNUSTEP_PATHLIST; do
276 if [ -z "$guile_paths" ]; then
277 guile_paths="$dir/Library/Libraries/Guile"
279 guile_paths="$guile_paths:$dir/Library/Libraries/Guile"
287 if [ -z "$GUILE_LOAD_PATH" ]; then
288 GUILE_LOAD_PATH="$guile_paths"
290 if ( echo ${GUILE_LOAD_PATH}| grep -v "${guile_paths}" >/dev/null ); then
291 GUILE_LOAD_PATH="$guile_paths:$GUILE_LOAD_PATH"
294 export GUILE_LOAD_PATH
299 # Perform any user initialization
301 if [ -f "$GNUSTEP_USER_ROOT/GNUstep.sh" ]; then
302 . "$GNUSTEP_USER_ROOT/GNUstep.sh"
305 if [ -n "$GS_ZSH_NEED_TO_RESTORE_SET" ]; then