3 # bsd.wx.mk - Support for wxWidgets based ports.
5 # Created by: Alejandro Pulver <alepulver@FreeBSD.org>
7 # The following variables can be defined in a port that uses the wxWidgets
8 # library, contributed libraries, WxPython and/or more wxWidgets related
9 # components (with run and/or build dependencies). It can be used after and/or
10 # before bsd.port.pre.mk, but Python components will only work if Python
11 # variables (e.g. USE_PYTHON) are defined before it (this is a bsd.python.mk
12 # limitation), at least it is manually included.
13 # USE_WX - Set to the list of wxWidgets versions that can be used by
14 # the port. The syntax allows the following elements:
15 # - Single version (e.g. "3.0").
16 # - Range of versions (e.g. "2.8-3.0"). Must be ascending.
17 # - Partial range: single version and upper (e.g. "2.8+").
18 # - Partial range: single version and lower (e.g. "-2.8").
19 # Multiple elements can be specified separated by spaces.
20 # USE_WX_NOT - Set to the list of wxWidgets versions that can't be used by
21 # the port. In other words, it removes some versions from
22 # USE_WX. If the latter is not defined, it will have the value
23 # of all the possible versions. The syntax is like USE_WX.
24 # WX_COMPS - Set to the list of wxWidgets components the port uses.
25 # Several components can be specified separated by spaces. By
26 # default it will have the value of "wx". Suffixes in the form
27 # ":xxx" may be added to the components to determine the
29 # The available components are:
30 # wx - The wxWidgets library.
31 # contrib - The wxWidgets contributed libraries.
32 # python - The wxWidgets API for Python.
33 # The available dependency types are:
34 # build - Requires component for building.
35 # lib - Requires component for building and running.
36 # run - Requires component for running.
37 # If no suffix is present then "run" will be used for "python"
38 # and "lib" for others.
39 # WX_CONF_ARGS - Set to "absolute" or "relative" if the port needs configure
40 # arguments in addition to the WX_CONFIG environment variable.
41 # It determines the type of parameters that have to be passed
42 # to the configure script. In the first case it adds
43 # "--with-wx-config=${WX_CONFIG}" (absolute path of
44 # WX_CONFIG), and in second one "--with-wx=${LOCALBASE}" plus
45 # "--with-wx-config=${WX_CONFIG:T} (prefix and name).
46 # WX_PREMK - Define to determine version and define WX_CONFIG/WX_VERSION
47 # after <bsd.port.pre.mk> (in case the port needs to manually run
49 # WX_UNICODE - Define if the port needs the Unicode version of the
50 # wxWidgets library and/or contributed libraries.
51 # NOTE: this should NOT be used for ports that can be compiled
52 # with Unicode or not, but for the ones that require it.
53 # WANT_UNICODE - Define if the port prefers Unicode, but doesn't require it.
54 # WANT_WX - Set to "yes" or a valid single version (no ranges, etc).
55 # In both cases it will detect the installed wxWidgets
56 # components and add them to the variable HAVE_WX. If a
57 # version is selected, HAVE_WX will contain a list of
58 # components in the other case it will contain a list of
59 # "component-version" pairs (e.g. wx-2.8, contrib-2.8, etc).
60 # It has to be used before bsd.port.pre.mk.
61 # WANT_WX_VER - Set to the prefered wxWidgets version for the port. It must
62 # be present in USE_WX or missing in USE_WX_NOT. This is
63 # overriden by the user variable WITH_WX_VER if set. It can
64 # contain multiple versions in order of preference (last ones
67 # The following variables are intended for the user and can be defined in
69 # WITH_UNICODE - Define if you prefer the Unicode version when available.
71 # - Define if you prefer the non Unicode version (this
72 # variable disables WITH_UNICODE and WANT_UNICODE).
73 # WITH_WX_VER - Define to the list of prefered versions in reverse order.
75 # The following variables are defined by this file, to be read from the port.
76 # WX_CONFIG - The path to the wx-config program (with different name).
77 # WXRC_CMD - The path to the wxrc program (with different name).
78 # WX_VERSION - The wxWidgets version that is going to be used.
79 # WX_UNICODE - If this variable is not defined by the port (which means it
80 # requires the Unicode version of wxWidgets), it will be
81 # defined in the case the Unicode version is used (enabled by
82 # WITH_UNICODE or WANT_UNICODE).
83 # HAVE_WX - The list of wxWidgets components installed, if WANT_WX was
84 # defined. The components will have version suffix if it was
88 # - A port that needs wxWidgets 2.8 and contributed libraries with Unicode.
90 # WX_COMPS= wx contrib
92 # - A port that needs WxPython 2.8 for running.
95 # WX_COMPS= python:run
96 # - A port that needs WxPython 2.8 or 3.0 for building.
99 # WX_COMPS= python:build
100 # - A port that needs wxWidgets version 2.8 or higher and contributed
103 # WX_COMPS= wx contrib
104 # - A port that needs wxWidgets of any version other than 2.8.
108 WX_Include_MAINTAINER= alepulver@FreeBSD.org
111 # Global definitions.
114 .if !defined(_WX_Definitions_Done)
115 _WX_Definitions_Done= yes
119 # _WX_COMPS_ALL - List of valid components.
120 # _WX_DEP_TYPES_ALL - List of valid dependency types.
121 # _WX_VERS_ALL - List of supported versions.
122 # _WX_VERS_UC_ALL - List of Unicode capable versions.
123 # _WX_VERS_LISTS - Reverse lists preference order.
126 _WX_COMPS_ALL= wx contrib python
127 _WX_DEP_TYPES_ALL= build lib run
128 _WX_VERS_ALL= 2.8 3.0
129 _WX_VERS_UC_ALL= 2.8 3.0
131 _WX_VERS_LISTS= WANT_WX_VER WITH_WX_VER _WX_VER_INSTALLED
134 # Variables used to determine what is needed:
135 # _WX_PORT_comp_ver - Port directory.
136 # _WX_LIB_comp_ver - Name of the shared library (optional).
137 # _WX_SHVER_comp_ver - Shared library version (optional).
138 # _WX_FILE_comp_ver - File installed by that component.
139 # _WX_DEPTYPE_comp_ver - Default dependency type (optional).
143 _WX_PORT_wx_2.8= x11-toolkits/wxgtk28${_WX_UCL}
144 _WX_LIB_wx_2.8= wx_base${_WX_UC}-2.8
146 _WX_PORT_contrib_2.8= x11-toolkits/wxgtk28${_WX_UCL}-contrib
147 _WX_LIB_contrib_2.8= wx_gtk2${_WX_UC}_fl-2.8
149 _WX_PORT_python_2.8= x11-toolkits/py-wxPython28${_WX_UCL}
150 _WX_FILE_python_2.8= ${PYTHON_SITELIBDIR}/wx-2.8-gtk2${_WX_PYSUFX}/wx/__init__.py
153 _WX_PORT_wx_3.0= x11-toolkits/wxgtk30
154 _WX_LIB_wx_3.0= wx_baseu-3.0
156 _WX_PORT_python_3.0= x11-toolkits/py-wxPython30
157 _WX_FILE_python_3.0= ${PYTHON_SITELIBDIR}/wx-3.0-gtk2/wx/__init__.py
159 # Set _WX_SHVER_comp_ver to 0 and _WX_FILE_comp_ver for libs appropiately.
160 # Set _WX_DEPTYPE_comp_ver for "python" to "run", and others to "lib".
162 . for comp in ${_WX_COMPS_ALL}
164 . for ver in ${_WX_VERS_ALL}
165 . if defined(_WX_LIB_${comp}_${ver})
166 _WX_SHVER_${comp}_${ver}= 0
167 _WX_FILE_${comp}_${ver}= ${LOCALBASE}/lib/lib${_WX_LIB_${comp}_${ver}}.so.${_WX_SHVER_${comp}_${ver}}
169 . if ${_WX_COMP} == "python"
170 _WX_DEPTYPE_${comp}_${ver}= run
172 _WX_DEPTYPE_${comp}_${ver}= lib
176 .endif # !_WX_Defined_Done
179 # Check if the user/port wants Unicode.
182 .if (!defined(WITHOUT_UNICODE) && \
183 (defined(WITH_UNICODE) || defined(WANT_UNICODE)))
184 _WX_UC_AVAILABLE= yes
186 . undef _WX_UC_AVAILABLE
190 # Check if we are going to determine the version.
193 .if !defined(_WX_Version_Done) && (defined(_POSTMKINCLUDED) || \
194 (defined(WX_PREMK) && defined(BEFOREPORTMK) && \
195 (defined(USE_WX) || defined(USE_WX_NOT))))
196 _WX_Need_Version= yes
200 # Check for present components.
203 # Requested by the user.
205 .if defined(WANT_WX) && defined(BEFOREPORTMK)
209 # Used for autodetection of installed versions.
211 .if defined(_WX_Need_Version)
215 .if defined(_WANT_WX)
217 # Check if Unicode will be used.
219 . for __WANT_WX in ${_WANT_WX}
220 . if defined(_WX_UC_AVAILABLE) && \
221 (${_WX_VERS_UC_ALL:M${__WANT_WX}} != "" || ${_WANT_WX:tl} == "yes")
222 _WX_WANT_UNICODE= yes
226 # These variables are reprocessed later so they won't affect other parts.
228 . if defined(WX_UNICODE) || defined(_WX_WANT_UNICODE)
229 _WX_VER_FINAL= ${_WX_VERS_UC_ALL}
234 _WX_VER_FINAL= ${_WX_VERS_ALL}
240 # Fill _HAVE_WX with the installed components.
243 . for __WANT_WX in ${_WANT_WX}
244 # Check if _WANT_WX contains more than one word.
245 . if defined(_HAVE_WX)
246 IGNORE?= selected multiple values for WANT_WX: ${_WANT_WX}
249 # Check for all versions.
250 . if ${_WANT_WX:tl} == "yes"
251 . for comp in ${_WX_COMPS_ALL}
252 . for ver in ${_WX_VER_FINAL}
253 _WX_COMP= _WX_FILE_${comp}_${ver}
254 . if defined(${_WX_COMP}) && exists(${${_WX_COMP}})
255 _HAVE_WX+= ${comp}-${ver}
259 # Check for a specific version.
260 . elif ${_WX_VERS_ALL:M${__WANT_WX}}
261 . for comp in ${_WX_COMPS_ALL}
262 . if exists(${_WX_FILE_${comp}_${__WANT_WX}})
267 IGNORE?= selected an invalid value for WANT_WX: ${__WANT_WX}
272 # Requested by the user.
274 .if defined(WANT_WX) && defined(BEFOREPORTMK)
275 HAVE_WX:= ${_HAVE_WX}
278 # Used for autodetection of installed versions.
280 .if defined(_WX_Need_Version)
281 _WX_VER_INSTALLED:= ${_HAVE_WX:Mwx-*:S/wx-//}
285 # Select wxWidgets version.
288 .if defined(_WX_Need_Version)
289 _WX_Version_Done= yes
292 # Basic component parsing (ignores dependency types).
294 # The variables used are:
295 # _WX_COMP - Component part.
296 # _WX_COMPS_FINAL - Final list of components.
299 # Detect duplicated components.
302 .for comp in ${WX_COMPS}
303 _WX_COMP= ${comp:C/:([[:alpha:]]+)$//}
304 . for __WX_COMP in ${_WX_COMP}
305 . if ${_WX_COMPS_ALL:M${__WX_COMP}} == ""
306 IGNORE?= selected an invalid wxWidgets component: ${__WX_COMP}
309 . for newcomp in ${_WX_COMP}
310 . if ${_WX_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
311 _WX_COMPS_FINAL+= ${newcomp}
316 # Set defaults (if one isn't present).
318 USE_WX?= ${_WX_VERS_ALL}
322 # Make lists of valid and invalid versions.
324 # The following variables are used:
325 # _WX_VER_CHECK - If the version is a single one, express in a range.
326 # _WX_VER_MIN - Lower version of the range.
327 # _WX_VER_MAX - Higher version of the range.
328 # _WX_VER_LIST - List of requested versions.
329 # _WX_VER_NOT_LIST - List of disallowed versions.
330 # _WX_VER_MERGED - List of requested version without disallowed ones.
333 .for list in VER VER_NOT
335 . for ver in ${USE_WX${list:C/VER//}}
336 _WX_VER_CHECK:= ${ver:C/^([[:digit:]]+(\.[[:digit:]]+)*)$/\1-\1/}
337 _WX_VER_MIN:= ${_WX_VER_CHECK:C/([[:digit:]]+(\.[[:digit:]]+)*)[-+].*/\1/}
338 _WX_VER_MAX:= ${_WX_VER_CHECK:C/.*-([[:digit:]]+(\.[[:digit:]]+)*)/\1/}
339 # Minimum version not specified.
340 . if ${_WX_VER_MIN} == ${_WX_VER_CHECK}
342 . for v in ${_WX_VERS_ALL}
343 . if ${_WX_VER_CHECK:C/[-+]//} == ${v} || ${_WX_VERS_SKIP:M${v}} == ""
348 # Maximum version not specified.
349 . if ${_WX_VER_MAX} == ${_WX_VER_CHECK}
350 . for v in ${_WX_VERS_ALL}
351 . if ${_WX_VER_CHECK:C/[-+]//} == ${v} || ${_WX_VERS_SKIP:M${v}} == ""
356 # Expand versions and add valid ones to each list.
357 . for v in ${_WX_VERS_ALL}
358 . if ${_WX_VER_MIN} <= ${v} && ${_WX_VER_MAX} >= ${v} && \
359 ${_WX_${list}_LIST:M${v}} == ""
360 _WX_${list}_LIST+= ${v}
366 # Merge the lists into a single list of valid versions.
369 .for ver in ${_WX_VER_LIST}
370 . if ${_WX_VER_NOT_LIST:M${ver}} == ""
371 _WX_VER_MERGED+= ${ver}
375 # Check for a null version.
377 .if empty(_WX_VER_MERGED)
378 IGNORE?= selected a null or invalid wxWidgets version
381 # Avoid versions which have unavailable components.
383 .for ver in ${_WX_VER_MERGED}
384 . for comp in ${_WX_COMPS_FINAL}
385 . if !defined(_WX_PORT_${comp}_${ver})
386 _WX_WRONG_COMPS+= ${comp}
387 _WX_WRONG_VERS+= ${ver}
388 _WX_VER_MERGED:= ${_WX_VER_MERGED:N${ver}}
393 .if empty(_WX_VER_MERGED)
394 IGNORE?= selected wxWidgets versions (${_WX_WRONG_VERS}) which do not have the selected components (${_WX_WRONG_COMPS})
401 # Create a list of capable versions.
404 .for ver in ${_WX_VER_MERGED}
405 . if ${_WX_VERS_UC_ALL:M${ver}} != ""
410 # Requested by the user or port (optional).
412 .if defined(_WX_UC_AVAILABLE)
413 . for ver in ${_WX_VER_UC}
414 . if ${_WX_VERS_UC_ALL:M${ver}} != ""
420 # Requested by the port (mandatory).
422 .if defined(WX_UNICODE)
423 . if empty(_WX_VER_UC)
424 IGNORE?= selected a wxWidgets version which does not support Unicode: ${_WX_VER_MERGED}
428 # Set Unicode variables.
430 .if defined(WX_UNICODE)
431 _WX_VER_FINAL= ${_WX_VER_UC}
436 _WX_VER_FINAL= ${_WX_VER_MERGED}
442 # Remove unusable installed versions.
444 .for ver in ${_WX_VER_INSTALLED}
445 . if ${_WX_VER_FINAL:M${ver}} == ""
446 _WX_VER_INSTALLED:= ${_WX_VER_INSTALLED:N${ver}}
451 # Choose final version.
455 # Check for the following (in order):
456 # 1) WITH_WX_VER - User preference.
457 # 2) WANT_WX_VER - Port preference.
458 # 3) _WX_VER_INSTALLED - Installed versions.
459 # 4) _WX_VER_FINAL - Available versions.
462 .for list in _WX_VER_FINAL ${_WX_VERS_LISTS}
463 . if defined(${list})
464 . for ver in ${${list}}
465 . if ${_WX_VER_FINAL:M${ver}} != ""
476 WX_CONFIG?= ${LOCALBASE}/bin/wxgtk2${_WX_UC}-${_WX_VER}-config
477 WXRC_CMD?= ${LOCALBASE}/bin/wxrc-gtk2${_WX_UC}-${_WX_VER}
478 WX_VERSION?= ${_WX_VER}
480 .endif # _WX_Need_Version
483 # Process components list and add dependencies, variables, etc.
486 .if defined(_POSTMKINCLUDED)
491 # The variables used are:
492 # _WX_COMP - Component part.
493 # _WX_DEP_TYPE - Dependency type part.
494 # _WX_COMP_NEW - Component + dependency type.
495 # _WX_COMPS_FINAL - Final list of components with dependency types.
498 # Default components.
502 # Detect invalid and duplicated components.
505 .for comp in ${WX_COMPS}
506 _WX_COMP= ${comp:C/:([[:alpha:]]+)$//}
507 . if ${_WX_COMP} == ${comp}
508 _WX_DEP_TYPE= ${_WX_DEPTYPE_${comp}_${_WX_VER}}
510 _WX_DEP_TYPE= ${comp:C/.+:([[:alpha:]]+)$/\1/}
512 _WX_COMP_NEW= ${_WX_COMP}_${_WX_DEP_TYPE}
513 . for __WX_COMP in ${_WX_COMP}
514 . if ${_WX_COMPS_ALL:M${__WX_COMP}} == ""
515 IGNORE?= selected an invalid wxWidgets component: ${__WX_COMP}
518 . for __WX_DEP_TYPE in ${_WX_DEP_TYPE}
519 . if ${_WX_DEP_TYPES_ALL:M${__WX_DEP_TYPE}} == ""
520 IGNORE?= selected an invalid wxWidgets dependency type: ${__WX_DEP_TYPE}
523 . if !defined(_WX_PORT_${_WX_COMP}_${_WX_VER})
524 IGNORE?= selected a wxWidgets component (${_WX_COMP}) which is not available for the selected version (${_WX_VER})
526 . for newcomp in ${_WX_COMP_NEW}
527 . if ${_WX_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
528 _WX_COMPS_FINAL+= ${newcomp}
535 # The variable used are:
536 # _WX_COMP - Component part.
537 # _WX_DEP_TYPE - Dependency type part.
539 .for comp in ${_WX_COMPS_FINAL}
540 _WX_COMP= ${comp:C/_([[:alpha:]]+)$//}
541 _WX_DEP_TYPE= ${comp:C/.+_([[:alpha:]]+)$/\1/}
542 # XXX Need a .for loop here so the variable is expanded before the assignment.
543 . for comp_part in ${_WX_COMP}
544 . if ${_WX_DEP_TYPE} == "lib"
545 . if defined(_WX_LIB_${_WX_COMP}_${_WX_VER})
546 LIB_DEPENDS+= lib${_WX_LIB_${comp_part}_${_WX_VER}}.so:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
548 BUILD_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
549 RUN_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
552 ${_WX_DEP_TYPE:tu}_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
558 # Set build related variables.
561 MAKE_ENV+= WX_CONFIG=${WX_CONFIG}
562 CONFIGURE_ENV+= WX_CONFIG=${WX_CONFIG}
564 .if defined(WX_CONF_ARGS)
565 . if ${WX_CONF_ARGS:tl} == "absolute"
566 CONFIGURE_ARGS+= --with-wx-config=${WX_CONFIG}
567 . elif ${WX_CONF_ARGS:tl} == "relative"
568 CONFIGURE_ARGS+= --with-wx=${LOCALBASE} \
569 --with-wx-config=${WX_CONFIG:T}
571 IGNORE?= selected an invalid wxWidgets configure argument type: ${WX_CONF_ARGS}
575 .endif # _POSTMKINCLUDED