OSDN Git Service

gdb/
[pf3gnuchains/pf3gnuchains3x.git] / tk / cygtcl.m4
1 # CYGNUS LOCAL
2 #
3 # This entire file is Cygnus local, it contains a set of cross
4 # platform autoconf macros to be used by Tcl extensions.
5
6 # FIXME: There seems to be a problem with variable
7 # names that still need an expansion (like $foo_FILE)
8 # since another eval might be needed in these macros.
9
10 #--------------------------------------------------------------------
11 # TCL_TOOL_PATH
12 #
13 #       Return a file path that the build system tool will understand.
14 #       This path might be different than the path used in the
15 #       Makefiles.
16 #
17 # Arguments:
18 #       
19 #       VAR
20 #       PATH
21 #       
22 # Results:
23 #
24 #
25 # Example:
26 #
27 # TCL_TOOL_PATH(TCL_CC_PATH, /usr/local/compiler)
28 #
29 #--------------------------------------------------------------------
30
31 AC_DEFUN(TCL_TOOL_PATH, [
32   val=$2
33
34   if test "$val" = "" ; then
35     AC_MSG_ERROR([Empty value for variable $1])
36   fi
37
38   case "${host}" in
39     *windows32* | *mingw32*)
40       if test "${CYGPATH}" = ""; then
41         AC_MSG_ERROR([CYGPATH variable is not defined.])
42       elif test "${CYGPATH}" = "echo"; then
43         # No cygpath when cross compiling
44         $1=$val
45       else
46         # store literal argument text in a variable
47         val=$val
48         # Convert Cygwin to Windows path (/tmp/foo -> C:\Tmp\foo)
49         val="`${CYGPATH} $val`"
50         # Convert path like C:\Tmp\foo to C:/Tmp/foo
51         $1="`echo $val | sed -e s#\\\\\\\\#/#g`"
52       fi
53     ;;
54     *)
55       # Default to a no-op under Unix or Cygwin gcc
56       $1=$val
57     ;;
58   esac
59 ])
60
61 # FIXME: It would simplify things if no SUFFIX had to be passed
62 # into these LONGNAME macros. Using the TCL_SHARED_LIB_SUFFIX
63 # and TCL_UNSHARED_LIB_SUFFIX from tclConfig.sh might do the trick!
64
65 #--------------------------------------------------------------------
66 # TCL_TOOL_STATIC_LIB_LONGNAME
67 #
68 #       Return static library name in the "long format" understood by
69 #       the build tools. This might involve prepending a suffix
70 #       and appending version information to the library name.
71 #
72 # Arguments:
73 #       
74 #       VAR
75 #       LIBNAME
76 #       SUFFIX
77 #       
78 # Depends on:
79 #       TCL_DBGX
80 #       TCL_VENDOR_PREFIX
81 #
82 # Example:
83 #
84 # TCL_TOOL_STATIC_LIB_LONGNAME(TCL_LIB, tcl, $TCL_UNSHARED_LIB_SUFFIX)
85 #
86 # Results:
87 #
88 #       TCL_LIB=libtcl83.a
89 #
90 #       or
91 #
92 #       TCL_LIB=tcl83.lib
93 #
94 #--------------------------------------------------------------------
95
96 AC_DEFUN(TCL_TOOL_STATIC_LIB_LONGNAME, [
97   libname=$2
98   suffix=$3
99
100   case "${host}" in
101     *windows32* | *mingw32*)
102       if test "$GCC" != yes; then
103         eval "long_libname=\"${TCL_VENDOR_PREFIX}${libname}${suffix}\""
104       else
105         eval "long_libname=\"lib${TCL_VENDOR_PREFIX}${libname}${suffix}\""
106       fi
107     ;;
108     *)
109       eval "long_libname=\"lib${TCL_VENDOR_PREFIX}${libname}${suffix}\""
110     ;;
111   esac
112
113   eval "long_libname=${long_libname}"
114
115   # Trick to replace DBGX with TCL_DBGX
116   DBGX='${TCL_DBGX}'
117   eval "long_libname=${long_libname}"
118
119   $1=$long_libname
120 ])
121
122 #--------------------------------------------------------------------
123 # TCL_TOOL_SHARED_LIB_LONGNAME
124 #
125 #       Return the shared library name in the "long format" understood by
126 #       the build tools. This might involve prepending a suffix
127 #       and appending version information to the shared library name.
128 #
129 # Arguments:
130 #       
131 #       VAR
132 #       LIBNAME
133 #       SUFFIX
134 #       
135 # Depends on:
136 #       TCL_DBGX
137 #       TCL_VENDOR_PREFIX
138 #
139 # Example:
140 #
141 # TCL_TOOL_SHARED_LIB_LONGNAME(TCL_SHLIB, tcl, $TCL_SHARED_LIB_SUFFIX)
142 #
143 # Results:
144 #       The above example could result in the following.
145 #
146 #       TCL_SHLIB=libtcl83.so
147 #
148 #       or
149 #
150 #       TCL_SHLIB=tcl83.dll
151 #
152 #--------------------------------------------------------------------
153
154 AC_DEFUN(TCL_TOOL_SHARED_LIB_LONGNAME, [
155   libname=$2
156   suffix=$3
157
158   case "${host}" in
159     *windows32* | *mingw32* | *cygwin*)
160       eval "long_libname=\"${TCL_VENDOR_PREFIX}${libname}${suffix}\""
161     ;;
162     *)
163       eval "long_libname=\"lib${TCL_VENDOR_PREFIX}${libname}${suffix}\""
164     ;;
165   esac
166
167   eval "long_libname=${long_libname}"
168
169   # Trick to replace DBGX with TCL_DBGX
170   DBGX='${TCL_DBGX}'
171   eval "long_libname=${long_libname}"
172
173   $1=$long_libname
174 ])
175
176 #--------------------------------------------------------------------
177 # TCL_TOOL_LIB_SHORTNAME
178 #
179 #       Return the library name in the "short format" understood by
180 #       the build tools. This might involve prepending a suffix
181 #       and appending version information to the library name.
182 #       The VC++ compiler does not support short library names
183 #       so we just use the static import lib name in that case.
184 #
185 # Arguments:
186 #       
187 #       VAR
188 #       LIBNAME
189 #       VERSION
190 #       
191 # Depends on:
192 #       TCL_LIB_VERSIONS_OK
193 #       TCL_DBGX
194 #       SHARED_BUILD
195 #       
196 #
197 # Example:
198 #
199 # TCL_TOOL_LIB_SHORTNAME(TCL_LIB, tcl, 8.3)
200 #
201 # Results:
202 #       The above example could result in the following.
203 #
204 #       TCL_LIB=-ltcl83
205 #
206 #       or
207 #
208 #       TCL_LIB=tcl83.lib
209 #
210 #--------------------------------------------------------------------
211
212 AC_DEFUN(TCL_TOOL_LIB_SHORTNAME, [
213   libname=$2
214   version=$3
215
216   if test "$TCL_LIB_SUFFIX" = "" ; then
217     AC_MSG_ERROR([The TCL_LIB_SUFFIX variable is not defined])
218   fi
219
220   # If the . character is not allowed in lib name, remove it from version
221   if test "${TCL_LIB_VERSIONS_OK}" != "ok"; then
222         version=`echo $version | tr -d .`
223   fi
224
225   case "${host}" in
226     *windows32* | *mingw32*)
227       if test "$GCC" != yes; then
228         eval "short_libname=\"${TCL_VENDOR_PREFIX}${libname}${version}${TCL_LIB_SUFFIX}\""
229       else
230         short_libname="-l${TCL_VENDOR_PREFIX}${libname}${version}${TCL_DBGX}"
231       fi
232     ;;
233     *)
234       short_libname="-l${TCL_VENDOR_PREFIX}${libname}${version}\${TCL_DBGX}"
235     ;;
236   esac
237
238   $1=$short_libname
239 ])
240
241 #--------------------------------------------------------------------
242 # TCL_TOOL_LIB_SPEC
243 #
244 #       Return the "lib spec format" understood by the build tools.
245 #
246 # Arguments:
247 #       
248 #       VAR
249 #       DIR
250 #       LIBARG
251 #       
252 # Depends on:
253 #       
254 #
255 # Example:
256 #
257 # TCL_TOOL_LIB_SPEC(SPEC, /usr/lib, -ltcl)
258 #
259 # Results:
260 #       The above example could result in the following.
261 #
262 #       SPEC="-L/usr/lib -ltcl83"
263 #
264 #--------------------------------------------------------------------
265
266 AC_DEFUN(TCL_TOOL_LIB_SPEC, [
267   case "${host}" in
268     *windows32* | *mingw32*)
269       if test "$GCC" != yes; then
270         TCL_TOOL_PATH($1, "$2/$3")
271       else
272         TCL_TOOL_PATH(dirname, $2)
273         $1="-L${dirname} $3"
274       fi
275     ;;
276     *)
277       $1="-L$2 $3"
278     ;;
279   esac
280 ])
281
282 #--------------------------------------------------------------------
283 # TCL_TOOL_LIB_PATH
284 #
285 #       Return the "lib path format" understood by the build tools.
286 #       Typically, this is the fully qualified path name of the library.
287 #
288 # Arguments:
289 #       
290 #       VAR
291 #       DIR
292 #       LIBARG
293 #       
294 # Depends on:
295 #       
296 #
297 # Example:
298 #
299 # TCL_TOOL_LIB_PATH(TMP_PATH, /usr/lib, libtcl83.a)
300 #
301 # Results:
302 #       The above example could result in the following.
303 #
304 #       TMP_PATH="/usr/lib/libtcl83.a"
305 #
306 #--------------------------------------------------------------------
307
308 AC_DEFUN(TCL_TOOL_LIB_PATH, [
309   TCL_TOOL_PATH($1, "$2/$3")
310 ])