summaryrefslogtreecommitdiff
path: root/Mk/Uses/tcl.mk
blob: bf0078b95acb6cbff80af7d9d6fed42d0ec54e50 (plain) (blame)
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
# $FreeBSD$
#
# vim: ts=8 noexpandtab
#
# Provide support to use Tcl/Tk
#
# Variables set by this file:
#
# TCL_VER		- Major.Minor version of Tcl
#
# TCLSH			- Set to full path of the Tcl interpreter
#
# TCL_LIBDIR		- Path where the Tcl libraries can be found
#
# TCL_INCLUDEDIR	- Path where the Tcl C headers can be found
#
#
# TK_VER		- Major.Minor version of Tk
#
# WISH			- Set to full path of the Tk interpreter
#
# TK_LIBDIR		- Path where the Tk libraries can be found
#
# TK_INCLUDEDIR		- Path where the Tk C headers can be found
#
#
#
# Usage:
#
# USES+=	PORT[:(VERSION|wrapper),build,run,tea]
#
# where PORT is one of:
#
# - tcl			- Depend on Tcl
# - tk			- Depend on both Tk and Tcl (Tk itself depends on Tcl)
#
# and VERSION is in one of the following formats:
#
# - (empty)		- Depend on any installed version of PORT. If none
#   			  is installed, bring in the default version. See
#   			  ${_TCLTK_DEFAULT_VERSION} below.
#
# - 85, 86, 87		- Depend on a specific version series of PORT. Multiple
#   			  values are OK. The highest version available is
#   			  picked.
#
# - 85+, 86+, 87+	- Depend on any installed version greater or equal to
#   			  the specified version.
#
# If wrapper is specified, an additional dependency on tcl-wrapper or
# tk-wrapper is added. It is NOT possible to select a specific version of
# Tcl/Tk when using the wrapper.
#
# Build-time / Run-time only dependencies can be specified with build or run.
#
# Tea can be used for Tcl/Tk extensions that use the Tcl Extension Architecture
# [http://www.tcl.tk/doc/tea] and allows to set common autoconf parameters.
#
# MAINTAINER: tcltk@FreeBSD.org

.if ${USES:Mtk} || ${USES:Mtk\:*}
.if !defined(_TCLTK_PORT)
_TCLTK_IGNORE=	yes
.endif
.endif

.if !defined(_INCLUDE_USES_TCL_MK) && !defined(_TCLTK_IGNORE)
_INCLUDE_USES_TCL_MK=	yes

#
# List the currently available versions.
#
# When adding a version, please keep the comment in
# Mk/bsd.default-versions.mk in sync.
_TCLTK_VALID_VERSIONS=	85 86 87

#
# Bring in the default and check that the specified version is in the list of
# valid versions.
#
_TCLTK_DEFAULT_VERSION=	${TCLTK_DEFAULT:S/.//}
.if ! ${_TCLTK_VALID_VERSIONS:M${_TCLTK_DEFAULT_VERSION}}
IGNORE=	Invalid tcltk version ${TCLTK_DEFAULT}
.endif

#
# _TCLTK_PORT tells us whether we're depending on Tcl or Tk. When using
# USES+=tk, the included file tk.mk sets this before including this file.
#
_TCLTK_PORT?=	tcl

#
# Parse a ver+ argument.
#
.if ${tcl_ARGS:M*+}
_TCLTK_MIN_VERSION:=	${tcl_ARGS:M*+:S/+//}
_TCLTK_WANTED_VERSIONS:=${_TCLTK_DEFAULT_VERSION}
.if ${_TCLTK_MIN_VERSION} == "85"
IGNORE=	Minimum tcltk version 85+ is meaningless
.endif
.endif

#
# Parse one or more ver arguments.
#
.if ${tcl_ARGS:M8[5-7]}
_TCLTK_WANTED_VERSIONS:=${tcl_ARGS:M8[5-7]}
.endif

#
# It makes little sense to specify both the wrapper and a specific version.
#
.if ${tcl_ARGS:Mwrapper} && defined(_TCLTK_WANTED_VERSIONS)
IGNORE=	USES=${_TCLTK_PORT}: it is not possible to specify both a version and the wrapper: ${tcl_ARGS}
.endif

#
# If no version was specified with any of the ver or ver+ arguments, set the
# default version.
#
.if !defined(_TCLTK_WANTED_VERSIONS)
_TCLTK_WANTED_VERSIONS=	${_TCLTK_DEFAULT_VERSION}
.endif

# 
# Resolve minimum versions (ver+). Append anything greater or equal than the
# specified minimum version to the list of wanted versions.
#
.if defined(_TCLTK_MIN_VERSION)
.  for _v in ${_TCLTK_VALID_VERSIONS}
.    if ${_TCLTK_MIN_VERSION} <= ${_v}
_TCLTK_WANTED_VERSIONS+=${_v}
.    endif
.  endfor
.endif

#
# Right now we have built a list of potential versions that we may depend on.
# Let's sort them and remove any duplicates. We then locate the highest one
# already installed, if any.
#
.for _v in ${_TCLTK_WANTED_VERSIONS:O:u}
_TCLTK_HIGHEST_VERSION:=${_v}
.  if exists(${LOCALBASE}/lib/lib${_TCLTK_PORT}${_v}.so)
_TCLTK_WANTED_VERSION:=	${_v}
.  endif
.endfor

#
# If we couldn't find any wanted version installed, depend on the default or the highest one.
.if !defined(_TCLTK_WANTED_VERSION)
.  if ${_TCLTK_WANTED_VERSIONS:M${_TCLTK_DEFAULT_VERSION}}
_TCLTK_WANTED_VERSION:=	${_TCLTK_DEFAULT_VERSION}
.  else
_TCLTK_WANTED_VERSION:= ${_TCLTK_HIGHEST_VERSION}
.  endif
.endif

#
# Deprecate by default all ports depending on 8.5
.if ${_TCLTK_WANTED_VERSION} == "85"
DEPRECATED=	Tcl/Tk 8.5 is nearing EOL, please consider porting to Tcl/Tk 8.6
.endif

#
# Exported variables
#
TCL_VER:=	${_TCLTK_WANTED_VERSION:S/8/8./}
TCL_SHLIB_VER:=	${_TCLTK_WANTED_VERSION}
TCLSH:=		${LOCALBASE}/bin/tclsh${TCL_VER}
TCL_LIBDIR:=	${LOCALBASE}/lib/tcl${TCL_VER}
TCL_INCLUDEDIR:=${LOCALBASE}/include/tcl${TCL_VER}

.if ${_TCLTK_PORT} == "tk"
TK_VER:=	${_TCLTK_WANTED_VERSION:S/8/8./}
TK_SHLIB_VER:=	${_TCLTK_WANTED_VERSION}
WISH:=		${LOCALBASE}/bin/wish${TCL_VER}
TK_LIBDIR:=	${LOCALBASE}/lib/tk${TK_VER}
TK_INCLUDEDIR:=	${LOCALBASE}/include/tk${TK_VER}
.endif

#
# Dependencies
#
_TCLTK_BUILD_DEPENDS=
_TCLTK_RUN_DEPENDS=
_TCLTK_LIB_DEPENDS=

# Construct the correct dependency lines (wrapper)
.if ${tcl_ARGS:Mwrapper}
.  if ${_TCLTK_PORT} == "tcl"
_TCLTK_WRAPPER_PORT=	tclsh:lang/tcl-wrapper
.  elif ${_TCLTK_PORT} == "tk"
_TCLTK_WRAPPER_PORT=	wish:x11-toolkits/tk-wrapper
.  endif
.endif

# Construct the correct dependency lines (Tcl/Tk)
.if ${_TCLTK_PORT} == "tcl"
_TCLTK_EXE_LINE=	tclsh${TCL_VER}:lang/tcl${_TCLTK_WANTED_VERSION}
_TCLTK_LIB_LINE=	libtcl${TCL_SHLIB_VER}.so:lang/tcl${_TCLTK_WANTED_VERSION}
.elif ${_TCLTK_PORT} == "tk"
_TCLTK_EXE_LINE=	wish${TK_VER}:x11-toolkits/tk${_TCLTK_WANTED_VERSION}
_TCLTK_LIB_LINE=	libtk${TK_SHLIB_VER}.so:x11-toolkits/tk${_TCLTK_WANTED_VERSION} \
			libtcl${TCL_SHLIB_VER}.so:lang/tcl${_TCLTK_WANTED_VERSION}
.endif

.if ${tcl_ARGS:Mbuild}
BUILD_DEPENDS+=	${_TCLTK_WRAPPER_PORT} \
		${_TCLTK_EXE_LINE}
.elif ${tcl_ARGS:Mrun}
RUN_DEPENDS+=	${_TCLTK_WRAPPER_PORT} \
		${_TCLTK_EXE_LINE}
.else
RUN_DEPENDS+=	${_TCLTK_WRAPPER_PORT}
LIB_DEPENDS+=	${_TCLTK_LIB_LINE}
.endif

# Setup TEA stuff
.if ${tcl_ARGS:Mtea}
GNU_CONFIGURE=	yes
TCL_PKG?=	${PORTNAME:C/^tcl(-?)//:C/(-?)tcl\$//}${PORTVERSION}
PLIST_SUB+=	TCL_PKG=${TCL_PKG}
CONFIGURE_ARGS+=--exec-prefix=${PREFIX} \
		--with-tcl=${TCL_LIBDIR} \
		--with-tclinclude=${TCL_INCLUDEDIR}
.  if ${_TCLTK_PORT} == "tk"
CONFIGURE_ARGS+=--with-tk=${TK_LIBDIR} --with-tkinclude=${TK_INCLUDEDIR}
.  endif
.endif

.endif # defined(_INCLUDE_USES_TCL_MK)

.undef _TCLTK_IGNORE