]> err.no Git - sope/blob - gnustep-make/GNUstep.sh.in
Drop apache 1 build-dependency
[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-2005 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 #   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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
75 #
76 # Read our configuration files
77 #
78
79 # Determine the location of the system configuration file
80 if [ -z "$GNUSTEP_CONFIG_FILE" ]; then
81   GNUSTEP_CONFIG_FILE=@GNUSTEP_CONFIG_FILE@
82 fi
83
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@
87 fi
88
89 # Read the system configuration file
90 if [ -f "$GNUSTEP_CONFIG_FILE" ]; then
91   . "$GNUSTEP_CONFIG_FILE"
92 fi
93
94 # FIXME: determining GNUSTEP_HOME
95 GNUSTEP_HOME=~
96
97 # Read the user configuration file ... unless it is disabled (ie, set
98 # to an empty string)
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"
104         fi;;
105      *) # Something else
106         if [ -f "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE" ]; then
107           . "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE"
108         fi;;
109   esac
110 fi
111
112 # Now, set any essential variable (that is not already set) to the
113 # built-in values.
114 if [ -z "$GNUSTEP_SYSTEM_ROOT" ]; then
115   GNUSTEP_SYSTEM_ROOT=@GNUSTEP_SYSTEM_ROOT@
116 fi
117
118 if [ -z "$GNUSTEP_LOCAL_ROOT" ]; then
119   GNUSTEP_LOCAL_ROOT=@GNUSTEP_LOCAL_ROOT@
120 fi
121
122 if [ -z "$GNUSTEP_NETWORK_ROOT" ]; then
123   GNUSTEP_NETWORK_ROOT=@GNUSTEP_NETWORK_ROOT@
124 fi
125
126 export GNUSTEP_SYSTEM_ROOT GNUSTEP_LOCAL_ROOT GNUSTEP_NETWORK_ROOT
127
128 GNUSTEP_FLATTENED=@GNUSTEP_FLATTENED@
129 if [ -z "$LIBRARY_COMBO" ]; then
130   LIBRARY_COMBO=@ac_cv_library_combo@
131 fi
132 export GNUSTEP_FLATTENED LIBRARY_COMBO
133
134 if [ -z "$GNUSTEP_MAKEFILES" ]; then
135   GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/Library/Makefiles
136 fi
137 export GNUSTEP_MAKEFILES
138
139 if [ -z "$GNUSTEP_USER_DIR" ]; then
140   GNUSTEP_USER_DIR=@GNUSTEP_USER_DIR@
141 fi
142
143 #
144 # Set GNUSTEP_USER_ROOT which is the variable used in practice
145 #
146 case "$GNUSTEP_USER_DIR" in 
147   /*) # An absolute path
148       GNUSTEP_USER_ROOT="$GNUSTEP_USER_DIR";;
149    *) # Something else
150       GNUSTEP_USER_ROOT="$GNUSTEP_HOME/$GNUSTEP_USER_DIR";;
151 esac
152
153 export GNUSTEP_USER_ROOT
154
155 # No longer needed
156 unset GNUSTEP_HOME
157
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@
173 fi
174
175 #
176 # Determine the host information
177 #
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`
183   cd "$tmpdir"
184   unset tmpdir
185 fi
186
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`
190 fi
191
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`
195 fi
196
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`
200 fi
201
202 export GNUSTEP_HOST GNUSTEP_HOST_CPU GNUSTEP_HOST_VENDOR GNUSTEP_HOST_OS
203
204 #
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
208 #
209 if [ -z "$GNUSTEP_PATHLIST" ]; then
210
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"`
217   else
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"
222   fi
223
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.
227
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"
231   else
232     GNUSTEP_PATHLIST="$G_U_R"
233   fi
234
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"
239     fi
240   fi
241
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"
247       fi
248     fi
249   fi
250
251   unset G_U_R
252   unset G_L_R
253   unset G_N_R
254   unset G_S_R
255
256   export GNUSTEP_PATHLIST
257 fi
258
259 #
260 # Add path to Tools to PATH
261 #
262 tmp_IFS="$IFS"
263 IFS=:
264 temp_path=
265 for dir in $GNUSTEP_PATHLIST; do
266
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}"
270   else
271     path_fragment="$dir/Tools"
272   fi
273
274   # Add it to temp_path
275   if [ -z "$temp_path" ]; then
276     temp_path="$path_fragment"
277   else
278     temp_path="$temp_path:$path_fragment"
279   fi
280
281   unset path_fragment
282
283 done
284 IFS="$tmp_IFS"
285 unset tmp_IFS
286 unset dir
287 if [ -z "$PATH" ]; then
288   PATH="$temp_path"
289 else
290   if ( echo ${PATH}| grep -v "${temp_path}" >/dev/null ); then
291     PATH="${temp_path}:${PATH}"
292   fi
293 fi
294 unset temp_path
295 export PATH
296
297 . $GNUSTEP_MAKEFILES/ld_lib_path.sh
298
299 tmp_IFS="$IFS"
300 IFS=:
301 gnustep_class_path=
302 for dir in $GNUSTEP_PATHLIST; do
303
304   if [ -z "$gnustep_class_path" ]; then
305     gnustep_class_path="$dir/Library/Libraries/Java"
306   else
307     gnustep_class_path="$gnustep_class_path:$dir/Library/Libraries/Java"
308   fi
309
310 done
311 IFS="$tmp_IFS"
312 unset tmp_IFS
313 unset dir
314
315 if [ -z "$CLASSPATH" ]; then
316   CLASSPATH="$gnustep_class_path"
317 else
318   if ( echo ${CLASSPATH}| grep -v "${gnustep_class_path}" >/dev/null ); then
319     CLASSPATH="$CLASSPATH:$gnustep_class_path"
320   fi
321 fi
322
323 unset gnustep_class_path
324 export CLASSPATH
325
326 #
327 # Setup path for loading guile modules too.
328 #
329 old_IFS="$IFS"
330 IFS=:
331 guile_paths=
332 for dir in $GNUSTEP_PATHLIST; do
333
334   if [ -z "$guile_paths" ]; then
335     guile_paths="$dir/Library/Libraries/Guile"
336   else
337     guile_paths="$guile_paths:$dir/Library/Libraries/Guile"
338   fi
339
340 done
341 IFS="$old_IFS"
342 unset old_IFS
343 unset dir
344
345 if [ -z "$GUILE_LOAD_PATH" ]; then
346   GUILE_LOAD_PATH="$guile_paths"
347 else
348   if ( echo ${GUILE_LOAD_PATH}| grep -v "${guile_paths}" >/dev/null ); then
349     GUILE_LOAD_PATH="$guile_paths:$GUILE_LOAD_PATH"
350   fi
351 fi
352 export GUILE_LOAD_PATH
353 unset guile_paths
354
355
356 #
357 # Perform any user initialization
358 #
359 if [ -f "$GNUSTEP_USER_ROOT/GNUstep.sh" ]; then
360   . "$GNUSTEP_USER_ROOT/GNUstep.sh"
361 fi
362
363 if [ -n "$GS_ZSH_NEED_TO_RESTORE_SET" ]; then
364   set +y
365 fi
366 # EOF