]> err.no Git - sope/blob - gnustep-make/ld_lib_path.sh
use %p for pointer formats
[sope] / gnustep-make / ld_lib_path.sh
1 #! /bin/sh
2 #
3 #   ld_lib_path.sh
4 #
5 #   Set up the LD_LIBRARY_PATH (or similar env variable for your system)
6 #
7 #   Copyright (C) 1997-2002 Free Software Foundation, Inc.
8 #
9 #   Author:  Scott Christley <scottc@net-community.com>
10 #   Author:  Ovidiu Predescu <ovidiu@net-community.com>
11 #   Rewrite: Richard Frith-Macdonald <richard@brainstorm.co.uk>
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 # This file is sourced.  This means extra care is needed when changing
28 # it.  Please read the comments on GNUstep.sh.in before touching it.
29
30 # The first (and only) parameter to this script is the canonical
31 # operating system name.
32
33 host_os=$GNUSTEP_HOST_OS
34
35 if [ -z "$host_os" ]; then
36   host_os=$1
37 fi
38
39
40 old_IFS="$IFS"
41 IFS=:
42 lib_paths=
43 fw_paths=
44 for dir in $GNUSTEP_PATHLIST; do
45
46   # prepare the path_fragment for libraries and this dir
47   if [ -z "$GNUSTEP_FLATTENED" ]; then
48     path_fragment="$dir/Library/Libraries/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO:$dir/Library/Libraries/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS"
49   else
50     path_fragment="$dir/Library/Libraries"
51   fi
52
53   # Append the path_fragment to lib_paths
54   if [ -z "$lib_paths" ]; then
55     lib_paths="$path_fragment"
56   else
57     lib_paths="$lib_paths:$path_fragment"
58   fi
59
60   # prepare the path_fragment for frameworks and this dir
61   path_fragment="$dir/Library/Frameworks"
62
63   # Append the path_fragment to fw_paths
64   if [ -z "$fw_paths" ]; then
65     fw_paths="$path_fragment"
66   else
67     fw_paths="$fw_paths:$path_fragment"
68   fi
69
70   unset path_fragment
71
72 done
73 IFS="$old_IFS"
74 unset old_IFS
75 unset dir
76
77
78 if [ -n "$additional_library_paths" ]; then
79   old_IFS="$IFS"
80   IFS=" 
81 "
82   additional=""
83   for dir in $additional_library_paths; do
84     additional="${additional}${dir}:"
85   done
86   unset dir
87
88   lib_paths="${additional}${lib_paths}"
89
90   unset additional
91   IFS="$old_IFS"
92   unset old_IFS
93 fi
94
95 if [ -n "$additional_framework_paths" ]; then
96   old_IFS="$IFS"
97   IFS="
98 "
99   additional=""
100   for dir in $additional_framework_paths; do
101     additional="${additional}${dir}:"
102   done
103   unset dir
104
105   fw_paths="${additional}${fw_paths}"
106
107   unset additional
108   IFS="$old_IFS"
109   unset old_IFS
110 fi
111
112 case "$host_os" in
113
114   *nextstep4*)
115     if [ -z "$DYLD_LIBRARY_PATH" ]; then
116       DYLD_LIBRARY_PATH="$lib_paths"
117     else
118       if ( echo ${DYLD_LIBRARY_PATH}|fgrep -v "${lib_paths}" >/dev/null ); then
119         DYLD_LIBRARY_PATH="$lib_paths:$DYLD_LIBRARY_PATH"
120       fi
121     fi
122     export DYLD_LIBRARY_PATH
123     ;;
124
125   *darwin*)
126     if [ -z "$DYLD_LIBRARY_PATH" ]; then
127       DYLD_LIBRARY_PATH="$lib_paths"
128     else
129       if ( echo ${DYLD_LIBRARY_PATH}|fgrep -v "${lib_paths}" >/dev/null ); then
130         DYLD_LIBRARY_PATH="$lib_paths:$DYLD_LIBRARY_PATH"
131       fi
132     fi
133     export DYLD_LIBRARY_PATH
134     
135 # The code below has been temporarily removed, because...
136 # Frameworks in GNUstep-make are supported by creating a link like
137
138 #   Libraries/libMyFramework.dylib ->
139 #      Frameworks/MyFramework.framework/Versions/Current/libMyFramework.dylib,
140 #
141 # to mitigate the fact that FSF GCC does not support a -framework flag.
142 #
143 # On Darwin, however, we partially emulate -framework by setting the
144 # "install_name" to the framework name during linking. The dynamic
145 # linker (dyld) is smart enough to find the framework under this name,
146 # but only if DYLD_FRAMEWORK_PATH is set (unless we set the
147 # "install_name" to an absolute path, which we don't). We'd really like
148 # to fully support -framework, though.
149 #
150 # Use otool -L MyApplication.app/MyApplication, for instance, to see
151 # how the shared libraries/frameworks are linked.
152 #
153 #    if [ "$LIBRARY_COMBO" = "apple-apple-apple" -o \
154 #         "$LIBRARY_COMBO" = "apple" ]; then
155     
156     if [ -z "$DYLD_FRAMEWORK_PATH" ]; then
157       DYLD_FRAMEWORK_PATH="$fw_paths"
158     else
159       if ( echo ${DYLD_FRAMEWORK_PATH}|
160            fgrep -v "${fw_paths}" >/dev/null ); then
161         DYLD_FRAMEWORK_PATH="$fw_paths:$DYLD_FRAMEWORK_PATH"
162       fi
163     fi
164     export DYLD_FRAMEWORK_PATH;;
165
166   *hpux*)
167     if [ -z "$SHLIB_PATH" ]; then
168       SHLIB_PATH="$lib_paths"
169     else
170       if ( echo ${SHLIB_PATH}|fgrep -v "${lib_paths}" >/dev/null ); then
171         SHLIB_PATH="$lib_paths:$SHLIB_PATH"
172       fi
173     fi
174     export SHLIB_PATH;
175     if [ -z "$LD_LIBRARY_PATH" ]; then
176       LD_LIBRARY_PATH="$lib_paths"
177     else
178       if ( echo ${LD_LIBRARY_PATH}| grep -v "${lib_paths}" >/dev/null ); then
179         LD_LIBRARY_PATH="$lib_paths:$LD_LIBRARY_PATH"
180       fi
181     fi
182     export LD_LIBRARY_PATH;;
183
184   *)
185     if [ -z "$LD_LIBRARY_PATH" ]; then
186       LD_LIBRARY_PATH="$lib_paths"
187     else
188       if ( echo ${LD_LIBRARY_PATH}| grep -v "${lib_paths}" >/dev/null ); then
189         LD_LIBRARY_PATH="$lib_paths:$LD_LIBRARY_PATH"
190       fi
191     fi
192     export LD_LIBRARY_PATH;;
193
194 esac
195
196 unset host_os
197 unset lib_paths
198 unset fw_paths
199