summaryrefslogtreecommitdiff
path: root/tcl/cygtcl.m4
blob: b74c2be7aca8741996a8dd32b894a56a42bedb39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# CYGNUS LOCAL
#
# This entire file is Cygnus local, it contains a set of cross
# platform autoconf macros to be used by Tcl extensions.

# FIXME: There seems to be a problem with variable
# names that still need an expansion (like $foo_FILE)
# since another eval might be needed in these macros.

#--------------------------------------------------------------------
# TCL_TOOL_PATH
#
#	Return a file path that the build system tool will understand.
#	This path might be different than the path used in the
#	Makefiles.
#
# Arguments:
#	
#	VAR
#	PATH
#	
# Results:
#
#
# Example:
#
# TCL_TOOL_PATH(TCL_CC_PATH, /usr/local/compiler)
#
#--------------------------------------------------------------------

AC_DEFUN(TCL_TOOL_PATH, [
  val=$2

  if test "$val" = "" ; then
    AC_MSG_ERROR([Empty value for variable $1])
  fi

  case "${host}" in
    *windows32* | *mingw32*)
      if test "${CYGPATH}" = ""; then
        AC_MSG_ERROR([CYGPATH variable is not defined.])
      elif test "${CYGPATH}" = "echo"; then
        # No cygpath when cross compiling
        $1=$val
      else
        # store literal argument text in a variable
        val=$val
        # Convert Cygwin to Windows path (/tmp/foo -> C:\Tmp\foo)
        val="`${CYGPATH} $val`"
        # Convert path like C:\Tmp\foo to C:/Tmp/foo
        $1="`echo $val | sed -e s#\\\\\\\\#/#g`"
      fi
    ;;
    *)
      # Default to a no-op under Unix or Cygwin gcc
      $1=$val
    ;;
  esac
])

# FIXME: It would simplify things if no SUFFIX had to be passed
# into these LONGNAME macros. Using the TCL_SHARED_LIB_SUFFIX
# and TCL_UNSHARED_LIB_SUFFIX from tclConfig.sh might do the trick!

#--------------------------------------------------------------------
# TCL_TOOL_STATIC_LIB_LONGNAME
#
#	Return static library name in the "long format" understood by
#	the build tools. This might involve prepending a suffix
#	and appending version information to the library name.
#
# Arguments:
#	
#	VAR
#	LIBNAME
#	SUFFIX
#	
# Depends on:
#	TCL_DBGX
#	TCL_VENDOR_PREFIX
#
# Example:
#
# TCL_TOOL_STATIC_LIB_LONGNAME(TCL_LIB, tcl, $TCL_UNSHARED_LIB_SUFFIX)
#
# Results:
#
#	TCL_LIB=libtcl83.a
#
#	or
#
#	TCL_LIB=tcl83.lib
#
#--------------------------------------------------------------------

AC_DEFUN(TCL_TOOL_STATIC_LIB_LONGNAME, [
  libname=$2
  suffix=$3

  case "${host}" in
    *windows32* | *mingw32*)
      if test "$GCC" != yes; then
        eval "long_libname=\"${TCL_VENDOR_PREFIX}${libname}${suffix}\""
      else
        eval "long_libname=\"lib${TCL_VENDOR_PREFIX}${libname}${suffix}\""
      fi
    ;;
    *)
      eval "long_libname=\"lib${TCL_VENDOR_PREFIX}${libname}${suffix}\""
    ;;
  esac

  eval "long_libname=${long_libname}"

  # Trick to replace DBGX with TCL_DBGX
  DBGX='${TCL_DBGX}'
  eval "long_libname=${long_libname}"

  $1=$long_libname
])

#--------------------------------------------------------------------
# TCL_TOOL_SHARED_LIB_LONGNAME
#
#	Return the shared library name in the "long format" understood by
#	the build tools. This might involve prepending a suffix
#	and appending version information to the shared library name.
#
# Arguments:
#	
#	VAR
#	LIBNAME
#	SUFFIX
#	
# Depends on:
#	TCL_DBGX
#	TCL_VENDOR_PREFIX
#
# Example:
#
# TCL_TOOL_SHARED_LIB_LONGNAME(TCL_SHLIB, tcl, $TCL_SHARED_LIB_SUFFIX)
#
# Results:
#	The above example could result in the following.
#
#	TCL_SHLIB=libtcl83.so
#
#	or
#
#	TCL_SHLIB=tcl83.dll
#
#--------------------------------------------------------------------

AC_DEFUN(TCL_TOOL_SHARED_LIB_LONGNAME, [
  libname=$2
  suffix=$3

  case "${host}" in
    *windows32* | *mingw32* | *cygwin*)
      eval "long_libname=\"${TCL_VENDOR_PREFIX}${libname}${suffix}\""
    ;;
    *)
      eval "long_libname=\"lib${TCL_VENDOR_PREFIX}${libname}${suffix}\""
    ;;
  esac

  eval "long_libname=${long_libname}"

  # Trick to replace DBGX with TCL_DBGX
  DBGX='${TCL_DBGX}'
  eval "long_libname=${long_libname}"

  $1=$long_libname
])

#--------------------------------------------------------------------
# TCL_TOOL_LIB_SHORTNAME
#
#	Return the library name in the "short format" understood by
#	the build tools. This might involve prepending a suffix
#	and appending version information to the library name.
#	The VC++ compiler does not support short library names
#	so we just use the static import lib name in that case.
#
# Arguments:
#	
#	VAR
#	LIBNAME
#	VERSION
#	
# Depends on:
#	TCL_LIB_VERSIONS_OK
#	TCL_DBGX
#	SHARED_BUILD
#	
#
# Example:
#
# TCL_TOOL_LIB_SHORTNAME(TCL_LIB, tcl, 8.3)
#
# Results:
#	The above example could result in the following.
#
#	TCL_LIB=-ltcl83
#
#	or
#
#	TCL_LIB=tcl83.lib
#
#--------------------------------------------------------------------

AC_DEFUN(TCL_TOOL_LIB_SHORTNAME, [
  libname=$2
  version=$3

  if test "$TCL_LIB_SUFFIX" = "" ; then
    AC_MSG_ERROR([The TCL_LIB_SUFFIX variable is not defined])
  fi

  # If the . character is not allowed in lib name, remove it from version
  if test "${TCL_LIB_VERSIONS_OK}" != "ok"; then
        version=`echo $version | tr -d .`
  fi

  case "${host}" in
    *windows32* | *mingw32*)
      if test "$GCC" != yes; then
        eval "short_libname=\"${TCL_VENDOR_PREFIX}${libname}${version}${TCL_LIB_SUFFIX}\""
      else
        short_libname="-l${TCL_VENDOR_PREFIX}${libname}${version}${TCL_DBGX}"
      fi
    ;;
    *)
      short_libname="-l${TCL_VENDOR_PREFIX}${libname}${version}\${TCL_DBGX}"
    ;;
  esac

  $1=$short_libname
])

#--------------------------------------------------------------------
# TCL_TOOL_LIB_SPEC
#
#	Return the "lib spec format" understood by the build tools.
#
# Arguments:
#	
#	VAR
#	DIR
#	LIBARG
#	
# Depends on:
#	
#
# Example:
#
# TCL_TOOL_LIB_SPEC(SPEC, /usr/lib, -ltcl)
#
# Results:
#	The above example could result in the following.
#
#	SPEC="-L/usr/lib -ltcl83"
#
#--------------------------------------------------------------------

AC_DEFUN(TCL_TOOL_LIB_SPEC, [
  case "${host}" in
    *windows32* | *mingw32*)
      if test "$GCC" != yes; then
        TCL_TOOL_PATH($1, "$2/$3")
      else
        TCL_TOOL_PATH(dirname, $2)
        $1="-L${dirname} $3"
      fi
    ;;
    *)
      $1="-L$2 $3"
    ;;
  esac
])

#--------------------------------------------------------------------
# TCL_TOOL_LIB_PATH
#
#	Return the "lib path format" understood by the build tools.
#	Typically, this is the fully qualified path name of the library.
#
# Arguments:
#	
#	VAR
#	DIR
#	LIBARG
#	
# Depends on:
#	
#
# Example:
#
# TCL_TOOL_LIB_PATH(TMP_PATH, /usr/lib, libtcl83.a)
#
# Results:
#	The above example could result in the following.
#
#	TMP_PATH="/usr/lib/libtcl83.a"
#
#--------------------------------------------------------------------

AC_DEFUN(TCL_TOOL_LIB_PATH, [
  TCL_TOOL_PATH($1, "$2/$3")
])