]> err.no Git - sope/blob - gnustep-make/GNUstep.sh.in
corrected a wrong (intermediary) committed version, updated ChangeLog this time ;-)
[sope] / gnustep-make / GNUstep.sh.in
1 #! /bin/echo This file must be sourced inside (ba)sh using: .
2 #
3 #   @configure_input@
4 #
5 #   Shell initialization for the GNUstep environment.
6 #
7 #   Copyright (C) 1997-2002 Free Software Foundation, Inc.
8 #
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>
13 #
14 #   This file is part of the GNUstep Makefile Package.
15 #
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.
20 #   
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.
25 #
26
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
30 # environment.
31 #
32 # Sourcing makes the shell script more delicate for the following reasons:
33 #
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;
37 #
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.
56 #
57
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
61
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
65     set -y
66     GS_ZSH_NEED_TO_RESTORE_SET=yes
67   fi
68
69 fi
70
71 #
72 # Set the GNUstep system root and local root
73 #
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@
79 fi
80 export GNUSTEP_ROOT GNUSTEP_SYSTEM_ROOT GNUSTEP_FLATTENED LIBRARY_COMBO
81
82 GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@
83 export GNUSTEP_MAKEFILES
84
85 GNUSTEP_LOCAL_ROOT=@GNUSTEP_LOCAL_ROOT@
86 GNUSTEP_NETWORK_ROOT=@GNUSTEP_NETWORK_ROOT@
87 export GNUSTEP_LOCAL_ROOT GNUSTEP_NETWORK_ROOT
88
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@
104 fi
105
106 #
107 # Determine the host information
108 #
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`
114   cd "$tmpdir"
115   unset tmpdir
116 fi
117
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`
121 fi
122
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`
126 fi
127
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`
131 fi
132
133 export GNUSTEP_HOST GNUSTEP_HOST_CPU GNUSTEP_HOST_VENDOR GNUSTEP_HOST_OS
134
135 #
136 # Ask the user_home tool for the root path.
137 #
138 if [ -z "$GNUSTEP_FLATTENED" ]; then
139   GNUSTEP_USER_ROOT=`$GNUSTEP_MAKEFILES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/user_home user`
140 else
141   GNUSTEP_USER_ROOT=`$GNUSTEP_MAKEFILES/user_home user`
142 fi
143
144 export GNUSTEP_USER_ROOT
145
146 #
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
150 #
151 if [ -z "$GNUSTEP_PATHLIST" ]; then
152
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"`
159   else
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"
164   fi
165
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.
169
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"
173   else
174     GNUSTEP_PATHLIST="$G_U_R"
175   fi
176
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"
181     fi
182   fi
183
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"
189       fi
190     fi
191   fi
192
193   unset G_U_R
194   unset G_L_R
195   unset G_N_R
196   unset G_S_R
197
198   export GNUSTEP_PATHLIST
199 fi
200
201 #
202 # Add path to Tools to PATH
203 #
204 tmp_IFS="$IFS"
205 IFS=:
206 temp_path=
207 for dir in $GNUSTEP_PATHLIST; do
208
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}"
212   else
213     path_fragment="$dir/Tools"
214   fi
215
216   # Add it to temp_path
217   if [ -z "$temp_path" ]; then
218     temp_path="$path_fragment"
219   else
220     temp_path="$temp_path:$path_fragment"
221   fi
222
223   unset path_fragment
224
225 done
226 IFS="$tmp_IFS"
227 unset tmp_IFS
228 unset dir
229 if [ -z "$PATH" ]; then
230   PATH="$temp_path"
231 else
232   if ( echo ${PATH}| grep -v "${temp_path}" >/dev/null ); then
233     PATH="${temp_path}:${PATH}"
234   fi
235 fi
236 unset temp_path
237 export PATH
238
239 . $GNUSTEP_MAKEFILES/ld_lib_path.sh
240
241 tmp_IFS="$IFS"
242 IFS=:
243 gnustep_class_path=
244 for dir in $GNUSTEP_PATHLIST; do
245
246   if [ -z "$gnustep_class_path" ]; then
247     gnustep_class_path="$dir/Library/Libraries/Java"
248   else
249     gnustep_class_path="$gnustep_class_path:$dir/Library/Libraries/Java"
250   fi
251
252 done
253 IFS="$tmp_IFS"
254 unset tmp_IFS
255 unset dir
256
257 if [ -z "$CLASSPATH" ]; then
258   CLASSPATH="$gnustep_class_path"
259 else
260   if ( echo ${CLASSPATH}| grep -v "${gnustep_class_path}" >/dev/null ); then
261     CLASSPATH="$CLASSPATH:$gnustep_class_path"
262   fi
263 fi
264
265 unset gnustep_class_path
266 export CLASSPATH
267
268 #
269 # Setup path for loading guile modules too.
270 #
271 old_IFS="$IFS"
272 IFS=:
273 guile_paths=
274 for dir in $GNUSTEP_PATHLIST; do
275
276   if [ -z "$guile_paths" ]; then
277     guile_paths="$dir/Library/Libraries/Guile"
278   else
279     guile_paths="$guile_paths:$dir/Library/Libraries/Guile"
280   fi
281
282 done
283 IFS="$old_IFS"
284 unset old_IFS
285 unset dir
286
287 if [ -z "$GUILE_LOAD_PATH" ]; then
288   GUILE_LOAD_PATH="$guile_paths"
289 else
290   if ( echo ${GUILE_LOAD_PATH}| grep -v "${guile_paths}" >/dev/null ); then
291     GUILE_LOAD_PATH="$guile_paths:$GUILE_LOAD_PATH"
292   fi
293 fi
294 export GUILE_LOAD_PATH
295 unset guile_paths
296
297
298 #
299 # Perform any user initialization
300 #
301 if [ -f "$GNUSTEP_USER_ROOT/GNUstep.sh" ]; then
302   . "$GNUSTEP_USER_ROOT/GNUstep.sh"
303 fi
304
305 if [ -n "$GS_ZSH_NEED_TO_RESTORE_SET" ]; then
306   set +y
307 fi
308 # EOF