1 # -*- tab-width: 4; -*-
4 # $FreeBSD: Mk/bsd.tcl.mk 318663 2013-05-21 08:59:02Z gahr $
7 .if !defined(_POSTMKINCLUDED) && !defined(Tcl_Pre_Include)
9 Tcl_Pre_Include= bsd.tcl.mk
10 Tcl_Include_MAINTAINER= mm@FreeBSD.org
12 # USE_TCL - Add library dependency on Tcl. If no version is given by the maintainer
13 # via the port or by the user via defined variable try to find the highest
14 # stable installed version.
15 # Available values: yes 86+ 85+ 84+ 85 84
16 # NOTE: - default value 86 is used in case of USE_TCL=yes
18 # USE_TCL_BUILD - Add buildtime dependency on Tcl (tclsh).
19 # Available values: see USE_TCL
20 # NOTE: - has no effect if USE_TCL is defined
22 # USE_TCL_RUN - Add runtime dependency on Tcl (tclsh).
23 # Available values: see USE_TCL
24 # NOTE: - has no effect if USE_TCL is defined
25 # - value is implied by USE_TCL_BUILD (if defined)
27 # USE_TCL_WRAPPER - Depend on the tclsh wrapper to run. Ports that do not explicitly require
28 # a specific tclsh version may use this.
29 # The tclsh wrapper script installs into ${LOCALBASE}/bin/tclsh
30 # NOTE: - USE_TCL_WRAPPER and USE_TCL can be used together
31 # - ports using the wrapper should support default Tcl (8.6)
33 # INVALID_TCL_VER - This variable contains a list of Tcl versions not supported by the port.
34 # This setting is effective only when USE_TCL is set to a range (e.g. 85+)
35 # WITH_TCL_VER - User defined global variable to set Tcl version
36 # This variable is effective only if USE_TCL is set to a range (e.g. 85+)
37 # and WITH_TCL_VER points inside that range.
38 # NOTE: INVALID_TCL_VER takes precedence
39 # <UNIQUENAME>_WITH_TCL_VER - User defined port specific variable to set Tcl version
41 # TCL_VER - Detected by bsd.tcl.mk. Contains the version number of Tcl to be used.
44 # USE_TK - Add library dependency on Tk. If no version is given by the maintainer
45 # via the port or by the user via defined variable try to find the highest
46 # stable installed version.
47 # Avaliable values: yes 86+ 85+ 84+ 85 84
48 # NOTE: - overrides USE_TCL
49 # - default value 86 is used in case of USE_TK=yes
51 # USE_TK_BUILD - Add buildtime dependency on Tk (wish).
52 # Available values: see USE_TK
53 # NOTE: - has no effect if USE_TK is defined
55 # USE_TK_RUN - Add runtime dependency on Tk (wish).
56 # Available values: see USE_TK
57 # NOTE: - has no effect if USE_TK is defined
58 # - value is implied by USE_TK_BUILD (if defined)
60 # USE_TK_WRAPPER - Depend on the wish wrapper to run. Ports that do not explicitly require
61 # a specific wish version may use this.
62 # The wish wrapper script installs into ${LOCALBASE}/bin/wish
63 # NOTE: - USE_TK_WRAPPER and USE_TK can be used together.
64 # - ports using the wrapper should support default Tk (8.6)
66 # INVALID_TK_VER - This variable contains a list of Tk versions not supported by the port
67 # This setting is effective only when USE_TK is set to a range (e.g. 85+)
68 # WITH_TK_VER - User defined global variable to set Tk version.
69 # This variable is effective only if USE_TK is set to a range (e.g. 85+)
70 # and WITH_TK_VER points inside that range.
71 # NOTE: overrides WITH_TCL_VER.
72 # <UNIQUENAME>_WITH_TK_VER - User defined port specific variable to set Tk version
73 # NOTE: overrides <UNIQUENAME>_WITH_TCL_VER.
75 # TCL_LIBDIR - Path where tcl libraries can be found
77 # TCL_INCLUDEDIR - Path where tcl C headers can be found
79 # TK_LIBDIR - Path where tk libraries can be found
81 # TK_INCLUDEDIR - Path where tk C headers can be found
83 # TCLSH - Path to tclsh executable respecting Tcl version
84 # or to the tclsh wrapper if USE_TCL_WRAPPER is set
86 # WISH - Path to wish executable respecting Tk version
87 # or to the wish wrapper if USE_TK_WRAPPER is set
90 # PATCH_TCL_SCRIPTS - List of tcl scripts that need to be patched to replace
91 # tclsh calls with tclsh${TK_VER} calls. Also note that
92 # post-patch target is used.
94 # PATCH_TK_SCRIPTS - List of tcl scripts that need to be patched to replace
95 # wish calls with wish${TK_VER} calls. Also note that
96 # post-patch target is used.
98 # Set RUN_DEPENDS for wrappers
99 . if defined(USE_TCL_WRAPPER)
100 RUN_DEPENDS+= tclsh:${PORTSDIR}/lang/tcl-wrapper
102 . if defined(USE_TK_WRAPPER)
103 RUN_DEPENDS+= wish:${PORTSDIR}/x11-toolkits/tk-wrapper
106 # Process USE_TCL_BUILD and USE_TCL_RUN
107 .if !defined(USE_TCL)
108 . if defined(USE_TCL_RUN)
109 USE_TCL:= ${USE_TCL_RUN}
110 _TCL_RUN_DEPENDS= yes
112 . if defined(USE_TCL_BUILD)
113 USE_TCL:= ${USE_TCL_BUILD}
114 _TCL_BUILD_DEPENDS= yes
118 # Process USE_TK_BUILD and USE_TK_RUN
120 . if defined(USE_TK_RUN)
121 USE_TK:= ${USE_TK_RUN}
124 . if defined(USE_TK_BUILD)
125 USE_TK:= ${USE_TK_BUILD}
126 _TK_BUILD_DEPENDS= yes
130 # Override the global WITH_TCL_VER or WITH_TK_VER with the
131 # port specific <UNIQUENAME>_WITH_TCL_VER or <UNIQUENAME>_WITH_TK_VER
132 . if defined(${UNIQUENAME:tu:S,-,_,}_WITH_TCL_VER)
133 WITH_TCL_VER:= ${${UNIQUENAME:tu:S,-,_,}_WITH_TCL_VER}
135 . if defined(${UNIQUENAME:tu:S,-,_,}_WITH_TK_VER)
136 WITH_TK_VER:= ${${UNIQUENAME:tu:S,-,_,}_WITH_TK_VER}
139 # If USE_TK, WITH_TK_VER, INVALID_TK_VER is defined,
140 # set USE_TCL, WITH_TCL_VER, INVALID_TCL_VER to identical values
141 # we require the same version of Tcl for Tk
143 . if !defined(USE_TCL)
148 . if defined(WITH_TK_VER)
149 WITH_TCL_VER:= ${WITH_TK_VER}
151 . if defined(INVALID_TK_VER)
152 INVALID_TCL_VER:= ${INVALID_TK_VER}
158 . if defined(USE_TCL)
160 _TCL_DEFAULT_VERSION= 86
161 _TCL_VERSIONS= 86 85 84
162 _TCL_RANGE_VERSIONS= 86+ 85+ 84+
164 # For specifying [85, 84, ..]+
169 # Set the default Tcl version and check if USE_TCL=yes was given
170 . if ${USE_TCL} == "yes"
171 USE_TCL= ${_TCL_DEFAULT_VERSION}
176 # Check if we have user-defined WITH_TCL_VER and if it matches
177 # the range specified in port's USE_TCL or USE_TK
178 . if defined(WITH_TCL_VER)
179 . for ver in ${_TCL_RANGE_VERSIONS}
180 . if ${USE_TCL} == "${ver}" && ${_TCL_VER} == "no"
181 _MATCHED_TCL_VER:= ${USE_TCL:S/+//}
182 . for tcl in ${_TCL_${_MATCHED_TCL_VER}P}
183 . if ${WITH_TCL_VER} == ${tcl}
184 # Check if user supplied WITH_TCL is in the INVALID_TCL_VER list
186 . for iver in ${INVALID_TCL_VER}
187 . if ${WITH_TCL_VER} == ${iver}
191 # If WITH_TCL is not in the INVALID_TCL_VER list, use it
192 # otherwise take default from port
193 . if ${_BRKTCL} == "no"
194 _TCL_VER= ${WITH_TCL_VER}
203 # Check for highest installed Tcl (if e.g. 84+ is specified)
204 # The default version of Tcl counts as the highest
205 . if ${_TCL_VER} == "no"
206 . for ver in ${_TCL_RANGE_VERSIONS}
207 . if ${USE_TCL} == "${ver}" && ${_TCL_VER} == "no"
208 _MATCHED_TCL_VER:= ${USE_TCL:S/+//}
209 . for tcl in ${_TCL_${_MATCHED_TCL_VER}P}
210 # Skip versions we are incompatible with
212 . for iver in ${INVALID_TCL_VER}
213 _INVALID_VER= ${iver}
214 . if ${_INVALID_VER} == ${tcl}
218 . if ${_BRKTCL} == "no"
219 # We have matched a supported version
220 _TCL_VER_MATCH=${tcl}
221 # Check if the default version is supported
222 . if ${_TCL_VER_MATCH} == ${_TCL_DEFAULT_VERSION}
223 _TCL_SUPPORT_DEFAULT= yes
225 # Look for installed versions
226 . if exists(${LOCALBASE}/include/tcl${tcl:S/8/8./}/tcl.h)
228 # Check if the default version is installed
229 . if ${_TCL_INST_VER} == ${_TCL_DEFAULT_VERSION}
230 _TCL_HAVE_DEFAULT= yes
237 . if defined(_MATCHED_TCL_VER)
238 . if defined(_TCL_INST_VER)
239 # Default version is installed
240 . if defined(_TCL_HAVE_DEFAULT)
241 USE_TCL= ${_TCL_DEFAULT_VERSION}
243 # Default version is not installed, but another supported version is installed
244 USE_TCL= ${_TCL_INST_VER}
246 # No supported version is installed, we want to install the default version
247 . elif defined(_TCL_SUPPORT_DEFAULT)
248 USE_TCL= ${_TCL_DEFAULT_VERSION}
249 . elif defined(_TCL_VER_MATCH)
250 # Default version is not wanted, select next best match
251 USE_TCL= ${_TCL_VER_MATCH}
253 # INVALID_[TCL|TK]_VER removes all choices from the USE_[TCL|TK] range
254 IGNORE= selection of a Tcl/Tk version is not possible. Please check USE_[TCL|TK] and INVALID_[TCL|TK]_VER
259 TCL_VER:= ${USE_TCL:S/8/8./}
261 # Check if a correct Tcl/Tk version was specified
263 . for ver in ${_TCL_VERSIONS}
264 . if ${USE_TCL} == "${ver}" && ${_FOUND} == "no"
269 . if ${_FOUND} == "yes"
271 TCL_INCLUDEDIR= ${LOCALBASE}/include/tcl${TCL_VER}
272 TCL_LIBDIR= ${LOCALBASE}/lib/tcl${TCL_VER}
273 TCLSH= ${LOCALBASE}/bin/tclsh${TCL_VER}
276 . if !defined(_TK_ONLY)
277 . if !defined(_TCL_RUN_DEPENDS) && !defined(_TCL_BUILD_DEPENDS)
278 LIB_DEPENDS+= tcl${USE_TCL}:${PORTSDIR}/lang/tcl${USE_TCL}
280 . if defined(_TCL_BUILD_DEPENDS)
281 BUILD_DEPENDS+= tclsh${TCL_VER}:${PORTSDIR}/lang/tcl${USE_TCL}
283 . if defined(_TCL_RUN_DEPENDS)
284 RUN_DEPENDS+= tclsh${TCL_VER}:${PORTSDIR}/lang/tcl${USE_TCL}
289 . elif !defined(IGNORE)
290 IGNORE= unknown Tcl/Tk version specified: ${USE_TCL}
298 # We now read the version numbers from the Tcl part
300 TK_VER:= ${USE_TCL:S/8/8./}
302 . if !defined(_TK_RUN_DEPENDS) && !defined(_TK_BUILD_DEPENDS)
303 LIB_DEPENDS+= tk${USE_TK}:${PORTSDIR}/x11-toolkits/tk${USE_TK}
305 . if defined(_TK_BUILD_DEPENDS)
306 BUILD_DEPENDS+= wish${TK_VER}:${PORTSDIR}/x11-toolkits/tk${USE_TK}
308 . if defined(_TK_RUN_DEPENDS)
309 RUN_DEPENDS+= wish${TK_VER}:${PORTSDIR}/x11-toolkits/tk${USE_TK}
313 TK_INCLUDEDIR= ${LOCALBASE}/include/tk${TK_VER}
314 TK_LIBDIR= ${LOCALBASE}/lib/tk${TK_VER}
315 WISH= ${LOCALBASE}/bin/wish${TK_VER}
317 . endif # defined(USE_TK)
318 . endif # defined(USE_TCL)
320 # (Re)set WISH and TCLSH to the wrapper, if defined
321 . if defined(USE_TCL_WRAPPER)
322 TCLSH= ${LOCALBASE}/bin/tclsh
324 . if defined(USE_TK_WRAPPER)
325 WISH= ${LOCALBASE}/bin/wish
328 .endif # !defined(_POSTMKINCLUDED) && !defined(Tcl_Pre_Include)
330 .if defined(_POSTMKINCLUDED) && !defined(Tcl_Post_Include)
332 Tcl_Post_Include= bsd.tcl.mk
334 . if defined(PATCH_TCL_SCRIPTS) || defined (PATCH_TK_SCRIPTS)
335 . if !target(post-patch)
337 . if defined(PATCH_TCL_SCRIPTS) && defined(TCLSH)
338 . for tcl_script in ${PATCH_TCL_SCRIPTS}
339 @${REINPLACE_CMD} -e 's,tclsh,${TCLSH},' ${WRKSRC}/${tcl_script}
342 . if defined(PATCH_TK_SCRIPTS) && defined(WISH)
343 . for tk_script in ${PATCH_TK_SCRIPTS}
344 @${REINPLACE_CMD} -e 's,wish,${WISH},' ${WRKSRC}/${tk_script}
347 . endif # !target(post-patch)
348 . endif # defined(PATCH_TCL_SCRIPTS) || defined (PATCH_TK_SCRIPTS)
349 .endif # defined(_POSTMKINCLUDED) && !defined(Tcl_Post_Include)