]> err.no Git - sope/blob - ld_lib_path.csh
21870752d25dd351bf9878d90f77cda643c47873
[sope] / ld_lib_path.csh
1 #!/bin/csh
2 #
3 #   ld_lib_path.csh
4 #
5 #   Set up the LD_LIBRARY_PATH (or similar env variable for your system)
6 #
7 #   Copyright (C) 1998 Free Software Foundation, Inc.
8 #
9 #   Author:  Scott Christley <scottc@net-community.com>
10 #   Author:  Ovidiu Predescu <ovidiu@net-community.com>
11 #
12 #   This file is part of the GNUstep Makefile Package.
13 #
14 #   This library is free software; you can redistribute it and/or
15 #   modify it under the terms of the GNU General Public License
16 #   as published by the Free Software Foundation; either version 2
17 #   of the License, or (at your option) any later version.
18 #   
19 #   You should have received a copy of the GNU General Public
20 #   License along with this library; see the file COPYING.LIB.
21 #   If not, write to the Free Software Foundation,
22 #   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #
24
25 # The first (and only) parameter to this script is the canonical
26 # operating system name.
27
28 if ( "$GNUSTEP_FLATTENED" == "" ) then
29   set last_path_part="Library/Libraries/${GNUSTEP_HOST_CPU}/${GNUSTEP_HOST_OS}/${LIBRARY_COMBO}"
30   set tool_path_part="Library/Libraries/${GNUSTEP_HOST_CPU}/${GNUSTEP_HOST_OS}"
31 else
32   set last_path_part="Library/Libraries"
33   set tool_path_part="Library/Libraries"
34 endif
35
36 set host_os=${GNUSTEP_HOST_OS}
37
38 if ( "${host_os}" == "" ) then
39   set host_os=${1}
40 endif
41
42 set lib_paths="${GNUSTEP_USER_ROOT}/${last_path_part}:${GNUSTEP_USER_ROOT}/${tool_path_part}:${GNUSTEP_LOCAL_ROOT}/${last_path_part}:${GNUSTEP_LOCAL_ROOT}/${tool_path_part}:${GNUSTEP_NETWORK_ROOT}/${last_path_part}:${GNUSTEP_NETWORK_ROOT}/${tool_path_part}:${GNUSTEP_SYSTEM_ROOT}/${last_path_part}:${GNUSTEP_SYSTEM_ROOT}/${tool_path_part}"
43
44 set last_path_part="Library/Frameworks"
45
46 set fw_paths="${GNUSTEP_USER_ROOT}/${last_path_part}:${GNUSTEP_LOCAL_ROOT}/${last_path_part}:${GNUSTEP_NETWORK_ROOT}/${last_path_part}:${GNUSTEP_SYSTEM_ROOT}/${last_path_part}"
47
48 switch ( "${host_os}" )
49
50   case *nextstep4* :
51     if ( $?DYLD_LIBRARY_PATH == 0 ) then
52         setenv DYLD_LIBRARY_PATH "${lib_paths}"
53     else if ( { (echo "${DYLD_LIBRARY_PATH}" | fgrep -v "${lib_paths}" >/dev/null) } ) then
54         setenv DYLD_LIBRARY_PATH "${lib_paths}:${DYLD_LIBRARY_PATH}"
55     endif
56     if ( $?additional_lib_paths == 1) then
57       foreach dir (${additional_lib_paths})
58         set additional="${additional}${dir}:"
59       end
60     endif
61
62     if ( "${?additional}" == "1" ) then
63       if ( { (echo "${DYLD_LIBRARY_PATH}" | fgrep -v "${additional}" >/dev/null) } ) then
64        setenv DYLD_LIBRARY_PATH="${additional}${DYLD_LIBRARY_PATH}"
65       endif
66     endif
67     breaksw
68
69   case *darwin* :
70     if ( $?DYLD_LIBRARY_PATH == 0 ) then
71         setenv DYLD_LIBRARY_PATH "${lib_paths}"
72     else if ( { (echo "${DYLD_LIBRARY_PATH}" | fgrep -v "${lib_paths}" >/dev/null) } ) then
73         setenv DYLD_LIBRARY_PATH "${lib_paths}:${DYLD_LIBRARY_PATH}"
74     endif
75     if ( $?additional_lib_paths == 1) then
76       foreach dir (${additional_lib_paths})
77         set additional="${additional}${dir}:"
78       end
79     endif
80
81     if ( "${?additional}" == "1" ) then
82       if ( { (echo "${DYLD_LIBRARY_PATH}" | fgrep -v "${additional}" >/dev/null) } ) then
83        setenv DYLD_LIBRARY_PATH="${additional}${DYLD_LIBRARY_PATH}"
84       endif
85     endif
86     
87 # The code below has been temporarily removed, because...
88 # With GNUstep -make on any platform, when you compile a
89 # framework, it is supported by creating a link like
90 # Librairies/libMyFramework.dylib ->
91 # Frameworks/MyFramework.framework/Versions/Current/libMyFramework.dylib, to
92 # mitigate the fact that FSF GCC supports to link frameworks with the -frameworks
93 # flag only on Darwin . 
94 # Well concerning library GNUstep -make on Darwin, the problem lies in the fact
95 # the Darwin linker seems to be unable to link the library when you pass the
96 # flag -lMyFramework to compile an application which depends on it, strangely it
97 # links the framework directly.  You can see that with otool -L
98 # Whatever/MyApplication.app/MyApplication which will output 
99 # MyFramework.framework/MyFramework and not libMyFramework.dylib .
100 # So because a framework is linked when it is present even when you want to
101 # link the equivalent library, the application will not find the framework when
102 # you launch it with DYLD_FRAMEWORK_PATH empty. To correct that, we must
103 # set DYLD_FRAMEWORK_PATH in any cases until the Darwin linker behaves correctly.
104 #
105 #    if ( ( "${LIBRARY_COMBO}" == "apple-apple-apple" ) \ 
106 #         || ( "${LIBRARY_COMBO}" == "apple") ) then
107
108     unset additional
109
110     if ( $?DYLD_FRAMEWORK_PATH == 0 ) then
111       setenv DYLD_FRAMEWORK_PATH "${fw_paths}"
112     else if ( { (echo "${DYLD_FRAMEWORK_PATH}" | fgrep -v "${fw_paths}" >/dev/null) } ) then
113       setenv DYLD_FRAMEWORK_PATH "${fw_paths}:${DYLD_FRAMEWORK_PATH}"
114     endif
115     if ( $?additional_framework_paths == 1) then
116       foreach dir (${additional_framework_paths})
117         set additional="${additional}${dir}:"
118       end
119     endif
120
121     if ( "${?additional}" == "1" ) then
122       if ( { (echo "${DYLD_FRAMEWORK_PATH}" | fgrep -v "${additional}" >/dev/null) } ) then
123         setenv DYLD_FRAMEWORK_PATH="${additional}${DYLD_FRAMEWORK_PATH}"
124       endif
125     endif
126     breaksw
127
128   case *hpux* :
129     if ( $?SHLIB_PATH == 0 ) then
130         setenv SHLIB_PATH "${lib_paths}"
131     else if ( { (echo "${SHLIB_PATH}" | fgrep -v "${lib_paths}" >/dev/null) } ) then
132         setenv SHLIB_PATH "${lib_paths}:${SHLIB_PATH}"
133     endif
134     if ( $?additional_lib_paths == 1) then
135       foreach dir (${additional_lib_paths})
136         set additional="${additional}${dir}:"
137       end
138     endif
139
140     if ( "${?additional}" == "1" ) then
141       if ( { (echo "${SHLIB_PATH}" | fgrep -v "${additional}" >/dev/null) } ) then
142        setenv SHLIB_PATH="${additional}${SHLIB_PATH}"
143       endif
144     endif
145
146     if ( $?LD_LIBRARY_PATH == 0 ) then
147         setenv LD_LIBRARY_PATH "${lib_paths}"
148     else if ( { (echo "${LD_LIBRARY_PATH}" | fgrep -v "${lib_paths}" >/dev/null) } ) then
149         setenv LD_LIBRARY_PATH "${lib_paths}:${LD_LIBRARY_PATH}"
150     endif
151
152     if ( $?additional_lib_paths == 1) then
153       foreach dir (${additional_lib_paths})
154         set additional="${additional}${dir}:"
155       end
156     endif
157
158     if ( "${?additional}" == "1" ) then
159       if ( { (echo "${LD_LIBRARY_PATH}" | fgrep -v "${additional}" >/dev/null) } ) then
160        setenv LD_LIBRARY_PATH="${additional}${LD_LIBRARY_PATH}"
161       endif
162     endif
163     breaksw
164
165   case * :
166     if ( $?LD_LIBRARY_PATH == 0 ) then
167         setenv LD_LIBRARY_PATH "${lib_paths}"
168     else if ( { (echo "${LD_LIBRARY_PATH}" | fgrep -v "${lib_paths}" >/dev/null) } ) then
169         setenv LD_LIBRARY_PATH "${lib_paths}:${LD_LIBRARY_PATH}"
170     endif
171     if ( $?additional_lib_paths == 1) then
172       foreach dir (${additional_lib_paths})
173         set additional="${additional}${dir}:"
174       end
175     endif
176
177     if ( "${?additional}" == "1" ) then
178       if ( { (echo "${LD_LIBRARY_PATH}" | fgrep -v "${additional}" >/dev/null) } ) then
179        setenv LD_LIBRARY_PATH="${additional}${LD_LIBRARY_PATH}"
180       endif
181     endif
182     breaksw
183
184 endsw
185
186 unset tool_path_part last_path_part host_os additional dir lib_paths fw_paths
187