4 # $FreeBSD: Mk/bsd.wx.mk 327608 2013-09-19 09:58:00Z gahr $
6 # bsd.wx.mk - Support for wxWidgets based ports.
8 # Created by: Alejandro Pulver <alepulver@FreeBSD.org>
10 # Please view me with 4 column tabs!
12 # The following variables can be defined in a port that uses the wxWidgets
13 # library, contributed libraries, WxPython and/or more wxWidgets related
14 # components (with run and/or build dependencies). It can be used after and/or
15 # before bsd.port.pre.mk, but Python components will only work if Python
16 # variables (e.g. USE_PYTHON) are defined before it (this is a bsd.python.mk
17 # limitation), at least it is manually included.
18 # USE_WX - Set to the list of wxWidgets versions that can be used by
19 # the port. The syntax allows the following elements:
20 # - Single version (e.g. "2.4").
21 # - Range of versions (e.g. "2.4-2.6"). Must be ascending.
22 # - Partial range: single version and upper (e.g. "2.4+").
23 # - Partial range: single version and lower (e.g. "-2.6").
24 # Multiple elements can be specified separated by spaces.
25 # USE_WX_NOT - Set to the list of wxWidgets versions that can't be used by
26 # the port. In other words, it removes some versions from
27 # USE_WX. If the latter is not defined, it will have the value
28 # of all the possible versions. The syntax is like USE_WX.
29 # WX_COMPS - Set to the list of wxWidgets components the port uses.
30 # Several components can be specified separated by spaces. By
31 # default it will have the value of "wx". Suffixes in the form
32 # ":xxx" may be added to the components to determine the
34 # The available components are:
35 # wx - The wxWidgets library.
36 # contrib - The wxWidgets contributed libraries.
37 # python - The wxWidgets API for Python.
38 # svg - WxSVG (only for 2.6).
39 # The available dependency types are:
40 # build - Requires component for building.
41 # lib - Requires component for building and running.
42 # run - Requires component for running.
43 # If no suffix is present then "run" will be used for "python"
44 # and "lib" for others.
45 # WX_CONF_ARGS - Set to "absolute" or "relative" if the port needs configure
46 # arguments in addition to the WX_CONFIG environment variable.
47 # It determines the type of parameters that have to be passed
48 # to the configure script. In the first case it adds
49 # "--with-wx-config=${WX_CONFIG}" (absolute path of
50 # WX_CONFIG), and in second one "--with-wx=${LOCALBASE}" plus
51 # "--with-wx-config=${WX_CONFIG:T} (prefix and name).
52 # WX_PREMK - Define to determine version and define WX_CONFIG/WX_VERSION
53 # after <bsd.port.pre.mk> (in case the port needs to manually run
55 # WX_UNICODE - Define if the port needs the Unicode version of the
56 # wxWidgets library and/or contributed libraries.
57 # NOTE: this should NOT be used for ports that can be compiled
58 # with Unicode or not, but for the ones that require it.
59 # WANT_UNICODE - Define if the port prefers Unicode, but doesn't require it.
60 # WANT_WX - Set to "yes" or a valid single version (no ranges, etc).
61 # In both cases it will detect the installed wxWidgets
62 # components and add them to the variable HAVE_WX. If a
63 # version is selected, HAVE_WX will contain a list of
64 # components in the other case it will contain a list of
65 # "component-version" pairs (e.g. wx-2.6, contrib-2.4, etc).
66 # It has to be used before bsd.port.pre.mk.
67 # WANT_WX_VER - Set to the prefered wxWidgets version for the port. It must
68 # be present in USE_WX or missing in USE_WX_NOT. This is
69 # overriden by the user variable WITH_WX_VER if set. It can
70 # contain multiple versions in order of preference (last ones
73 # The following variables are intended for the user and can be defined in
75 # WITH_UNICODE - Define if you prefer the Unicode version when available.
77 # - Define if you prefer the non Unicode version (this
78 # variable disables WITH_UNICODE and WANT_UNICODE).
79 # WITH_WX_VER - Define to the list of prefered versions in reverse order.
81 # The following variables are defined by this file, to be read from the port.
82 # WX_CONFIG - The path to the wx-config program (with different name).
83 # WXRC_CMD - The path to the wxrc program (with different name).
84 # WX_VERSION - The wxWidgets version that is going to be used.
85 # WX_UNICODE - If this variable is not defined by the port (which means it
86 # requires the Unicode version of wxWidgets), it will be
87 # defined in the case the Unicode version is used (enabled by
88 # WITH_UNICODE or WANT_UNICODE).
89 # HAVE_WX - The list of wxWidgets components installed, if WANT_WX was
90 # defined. The components will have version suffix if it was
94 # - A port that needs wxWidgets 2.6 and contributed libraries with Unicode.
96 # WX_COMPS= wx contrib
98 # - A port that needs WxPython 2.4 for running.
101 # WX_COMPS= python:run
102 # - A port that needs WxPython 2.4 or 2.6 for building.
105 # WX_COMPS= python:build
106 # - A port that needs wxWidgets version 2.4 or higher and contributed
109 # WX_COMPS= wx contrib
110 # - A port that needs wxWidgets of any version other than 2.4.
114 WX_Include_MAINTAINER= alepulver@FreeBSD.org
117 # Global definitions.
120 .if !defined(_WX_Definitions_Done)
121 _WX_Definitions_Done= yes
125 # _WX_COMPS_ALL - List of valid components.
126 # _WX_DEP_TYPES_ALL - List of valid dependency types.
127 # _WX_VERS_ALL - List of supported versions.
128 # _WX_VERS_UC_ALL - List of Unicode capable versions.
129 # _WX_VERS_LISTS - Reverse lists preference order.
132 _WX_COMPS_ALL= wx contrib python svg
133 _WX_DEP_TYPES_ALL= build lib run
134 _WX_VERS_ALL= 2.6 2.8 2.9
135 _WX_VERS_UC_ALL= 2.6 2.8 2.9
137 _WX_VERS_LISTS= WANT_WX_VER WITH_WX_VER _WX_VER_INSTALLED
140 # Variables used to determine what is needed:
141 # _WX_PORT_comp_ver - Port directory.
142 # _WX_LIB_comp_ver - Name of the shared library (optional).
143 # _WX_SHVER_comp_ver - Shared library version (optional).
144 # _WX_FILE_comp_ver - File installed by that component.
145 # _WX_DEPTYPE_comp_ver - Default dependency type (optional).
149 _WX_PORT_wx_2.6= x11-toolkits/wxgtk26${_WX_UCL}
150 _WX_LIB_wx_2.6= wx_base${_WX_UC}-2.6
152 _WX_PORT_common_2.6= x11-toolkits/wxgtk26-common
153 _WX_FILE_common_2.6= ${LOCALBASE}/include/wx-2.6/wx/wxprec.h
155 _WX_PORT_contrib_2.6= x11-toolkits/wxgtk26${_WX_UCL}-contrib
156 _WX_LIB_contrib_2.6= wx_gtk2${_WX_UC}_animate-2.6
158 _WX_PORT_python_2.6= x11-toolkits/py-wxPython26${_WX_UCL}
159 _WX_FILE_python_2.6= ${PYTHON_SITELIBDIR}/wx-2.6-gtk2${_WX_PYSUFX}/wx/__init__.py
162 _WX_PORT_wx_2.8= x11-toolkits/wxgtk28${_WX_UCL}
163 _WX_LIB_wx_2.8= wx_base${_WX_UC}-2.8
165 _WX_PORT_common_2.8= x11-toolkits/wxgtk28-common
166 _WX_FILE_common_2.8= ${LOCALBASE}/include/wx-2.8/wx/wxprec.h
168 _WX_PORT_contrib_2.8= x11-toolkits/wxgtk28${_WX_UCL}-contrib
169 _WX_LIB_contrib_2.8= wx_gtk2${_WX_UC}_fl-2.8
171 _WX_PORT_python_2.8= x11-toolkits/py-wxPython28${_WX_UCL}
172 _WX_FILE_python_2.8= ${PYTHON_SITELIBDIR}/wx-2.8-gtk2${_WX_PYSUFX}/wx/__init__.py
174 _WX_PORT_svg_2.8= graphics/wxsvg
175 _WX_LIB_svg_2.8= wxsvg
178 _WX_PORT_wx_2.9= x11-toolkits/wxgtk29
179 _WX_LIB_wx_2.9= wx_baseu-2.9
181 # Set _WX_SHVER_comp_ver to 0 and _WX_FILE_comp_ver for libs appropiately.
182 # Set _WX_DEPTYPE_comp_ver for "python" to "run", and others to "lib".
184 . for comp in ${_WX_COMPS_ALL}
186 . for ver in ${_WX_VERS_ALL}
187 . if defined(_WX_LIB_${comp}_${ver})
188 _WX_SHVER_${comp}_${ver}= 0
189 _WX_FILE_${comp}_${ver}= ${LOCALBASE}/lib/lib${_WX_LIB_${comp}_${ver}}.so.${_WX_SHVER_${comp}_${ver}}
191 . if ${_WX_COMP} == "python"
192 _WX_DEPTYPE_${comp}_${ver}= run
194 _WX_DEPTYPE_${comp}_${ver}= lib
198 .endif # !_WX_Defined_Done
201 # Check if the user/port wants Unicode.
204 .if (!defined(WITHOUT_UNICODE) && \
205 (defined(WITH_UNICODE) || defined(WANT_UNICODE)))
206 _WX_UC_AVAILABLE= yes
208 . undef _WX_UC_AVAILABLE
212 # Check if we are going to determine the version.
215 .if !defined(_WX_Version_Done) && (defined(_POSTMKINCLUDED) || \
216 (defined(WX_PREMK) && defined(BEFOREPORTMK) && \
217 (defined(USE_WX) || defined(USE_WX_NOT))))
218 _WX_Need_Version= yes
222 # Check for present components.
225 # Requested by the user.
227 .if defined(WANT_WX) && defined(BEFOREPORTMK)
231 # Used for autodetection of installed versions.
233 .if defined(_WX_Need_Version)
237 .if defined(_WANT_WX)
239 # Check if Unicode will be used.
241 . for __WANT_WX in ${_WANT_WX}
242 . if defined(_WX_UC_AVAILABLE) && \
243 (${_WX_VERS_UC_ALL:M${__WANT_WX}} != "" || ${_WANT_WX:tl} == "yes")
244 _WX_WANT_UNICODE= yes
248 # These variables are reprocessed later so they won't affect other parts.
250 . if defined(WX_UNICODE) || defined(_WX_WANT_UNICODE)
251 _WX_VER_FINAL= ${_WX_VERS_UC_ALL}
256 _WX_VER_FINAL= ${_WX_VERS_ALL}
262 # Fill _HAVE_WX with the installed components.
265 . for __WANT_WX in ${_WANT_WX}
266 # Check if _WANT_WX contains more than one word.
267 . if defined(_HAVE_WX)
268 IGNORE?= selected multiple values for WANT_WX: ${_WANT_WX}
271 # Check for all versions.
272 . if ${_WANT_WX:tl} == "yes"
273 . for comp in ${_WX_COMPS_ALL}
274 . for ver in ${_WX_VER_FINAL}
275 _WX_COMP= _WX_FILE_${comp}_${ver}
276 . if defined(${_WX_COMP}) && exists(${${_WX_COMP}})
277 _HAVE_WX+= ${comp}-${ver}
281 # Check for a specific version.
282 . elif ${_WX_VERS_ALL:M${__WANT_WX}}
283 . for comp in ${_WX_COMPS_ALL}
284 . if exists(${_WX_FILE_${comp}_${__WANT_WX}})
289 IGNORE?= selected an invalid value for WANT_WX: ${__WANT_WX}
294 # Requested by the user.
296 .if defined(WANT_WX) && defined(BEFOREPORTMK)
297 HAVE_WX:= ${_HAVE_WX}
300 # Used for autodetection of installed versions.
302 .if defined(_WX_Need_Version)
303 _WX_VER_INSTALLED:= ${_HAVE_WX:Mwx-*:S/wx-//}
307 # Select wxWidgets version.
310 .if defined(_WX_Need_Version)
311 _WX_Version_Done= yes
314 # Basic component parsing (ignores dependency types).
316 # The variables used are:
317 # _WX_COMP - Component part.
318 # _WX_COMPS_FINAL - Final list of components.
321 # Detect duplicated components.
324 .for comp in ${WX_COMPS}
325 _WX_COMP= ${comp:C/:([[:alpha:]]+)$//}
326 . for __WX_COMP in ${_WX_COMP}
327 . if ${_WX_COMPS_ALL:M${__WX_COMP}} == ""
328 IGNORE?= selected an invalid wxWidgets component: ${__WX_COMP}
331 . for newcomp in ${_WX_COMP}
332 . if ${_WX_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
333 _WX_COMPS_FINAL+= ${newcomp}
338 # Set defaults (if one isn't present).
340 USE_WX?= ${_WX_VERS_ALL}
344 # Make lists of valid and invalid versions.
346 # The following variables are used:
347 # _WX_VER_CHECK - If the version is a single one, express in a range.
348 # _WX_VER_MIN - Lower version of the range.
349 # _WX_VER_MAX - Higher version of the range.
350 # _WX_VER_LIST - List of requested versions.
351 # _WX_VER_NOT_LIST - List of disallowed versions.
352 # _WX_VER_MERGED - List of requested version without disallowed ones.
355 .for list in VER VER_NOT
357 . for ver in ${USE_WX${list:C/VER//}}
358 _WX_VER_CHECK:= ${ver:C/^([[:digit:]]+(\.[[:digit:]]+)*)$/\1-\1/}
359 _WX_VER_MIN:= ${_WX_VER_CHECK:C/([[:digit:]]+(\.[[:digit:]]+)*)[-+].*/\1/}
360 _WX_VER_MAX:= ${_WX_VER_CHECK:C/.*-([[:digit:]]+(\.[[:digit:]]+)*)/\1/}
361 # Minimum version not specified.
362 . if ${_WX_VER_MIN} == ${_WX_VER_CHECK}
364 . for v in ${_WX_VERS_ALL}
365 . if ${_WX_VER_CHECK:C/[-+]//} == ${v} || ${_WX_VERS_SKIP:M${v}} == ""
370 # Maximum version not specified.
371 . if ${_WX_VER_MAX} == ${_WX_VER_CHECK}
372 . for v in ${_WX_VERS_ALL}
373 . if ${_WX_VER_CHECK:C/[-+]//} == ${v} || ${_WX_VERS_SKIP:M${v}} == ""
378 # Expand versions and add valid ones to each list.
379 . for v in ${_WX_VERS_ALL}
380 . if ${_WX_VER_MIN} <= ${v} && ${_WX_VER_MAX} >= ${v} && \
381 ${_WX_${list}_LIST:M${v}} == ""
382 _WX_${list}_LIST+= ${v}
388 # Merge the lists into a single list of valid versions.
391 .for ver in ${_WX_VER_LIST}
392 . if ${_WX_VER_NOT_LIST:M${ver}} == ""
393 _WX_VER_MERGED+= ${ver}
397 # Check for a null version.
399 .if empty(_WX_VER_MERGED)
400 IGNORE?= selected a null or invalid wxWidgets version
403 # Avoid versions which have unavailable components.
405 .for ver in ${_WX_VER_MERGED}
406 . for comp in ${_WX_COMPS_FINAL}
407 . if !defined(_WX_PORT_${comp}_${ver})
408 _WX_WRONG_COMPS+= ${comp}
409 _WX_WRONG_VERS+= ${ver}
410 _WX_VER_MERGED:= ${_WX_VER_MERGED:N${ver}}
415 .if empty(_WX_VER_MERGED)
416 IGNORE?= selected wxWidgets versions (${_WX_WRONG_VERS}) which do not have the selected components (${_WX_WRONG_COMPS})
423 # Create a list of capable versions.
426 .for ver in ${_WX_VER_MERGED}
427 . if ${_WX_VERS_UC_ALL:M${ver}} != ""
432 # Requested by the user or port (optional).
434 .if defined(_WX_UC_AVAILABLE)
435 . for ver in ${_WX_VER_UC}
436 . if ${_WX_VERS_UC_ALL:M${ver}} != ""
442 # Requested by the port (mandatory).
444 .if defined(WX_UNICODE)
445 . if empty(_WX_VER_UC)
446 IGNORE?= selected a wxWidgets version which does not support Unicode: ${_WX_VER_MERGED}
450 # Set Unicode variables.
452 .if defined(WX_UNICODE)
453 _WX_VER_FINAL= ${_WX_VER_UC}
458 _WX_VER_FINAL= ${_WX_VER_MERGED}
464 # Remove unusable installed versions.
466 .for ver in ${_WX_VER_INSTALLED}
467 . if ${_WX_VER_FINAL:M${ver}} == ""
468 _WX_VER_INSTALLED:= ${_WX_VER_INSTALLED:N${ver}}
473 # Choose final version.
477 # Check for the following (in order):
478 # 1) WITH_WX_VER - User preference.
479 # 2) WANT_WX_VER - Port preference.
480 # 3) _WX_VER_INSTALLED - Installed versions.
481 # 4) _WX_VER_FINAL - Available versions.
484 .for list in _WX_VER_FINAL ${_WX_VERS_LISTS}
485 . if defined(${list})
486 . for ver in ${${list}}
487 . if ${_WX_VER_FINAL:M${ver}} != ""
498 WX_CONFIG?= ${LOCALBASE}/bin/wxgtk2${_WX_UC}-${_WX_VER}-config
499 WXRC_CMD?= ${LOCALBASE}/bin/wxrc-gtk2${_WX_UC}-${_WX_VER}
500 WX_VERSION?= ${_WX_VER}
502 .endif # _WX_Need_Version
505 # Process components list and add dependencies, variables, etc.
508 .if defined(_POSTMKINCLUDED)
513 # The variables used are:
514 # _WX_COMP - Component part.
515 # _WX_DEP_TYPE - Dependency type part.
516 # _WX_COMP_NEW - Component + dependency type.
517 # _WX_COMPS_FINAL - Final list of components with dependency types.
520 # Default components.
524 # Detect invalid and duplicated components.
527 .for comp in ${WX_COMPS}
528 _WX_COMP= ${comp:C/:([[:alpha:]]+)$//}
529 . if ${_WX_COMP} == ${comp}
530 _WX_DEP_TYPE= ${_WX_DEPTYPE_${comp}_${_WX_VER}}
532 _WX_DEP_TYPE= ${comp:C/.+:([[:alpha:]]+)$/\1/}
534 _WX_COMP_NEW= ${_WX_COMP}_${_WX_DEP_TYPE}
535 . for __WX_COMP in ${_WX_COMP}
536 . if ${_WX_COMPS_ALL:M${__WX_COMP}} == ""
537 IGNORE?= selected an invalid wxWidgets component: ${__WX_COMP}
540 . for __WX_DEP_TYPE in ${_WX_DEP_TYPE}
541 . if ${_WX_DEP_TYPES_ALL:M${__WX_DEP_TYPE}} == ""
542 IGNORE?= selected an invalid wxWidgets dependency type: ${__WX_DEP_TYPE}
545 . if !defined(_WX_PORT_${_WX_COMP}_${_WX_VER})
546 IGNORE?= selected a wxWidgets component (${_WX_COMP}) which is not available for the selected version (${_WX_VER})
548 . for newcomp in ${_WX_COMP_NEW}
549 . if ${_WX_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
550 _WX_COMPS_FINAL+= ${newcomp}
557 # The variable used are:
558 # _WX_COMP - - Component part.
559 # _WX_DEP_TYPE - Dependency type part.
561 .for comp in ${_WX_COMPS_FINAL}
562 _WX_COMP= ${comp:C/_([[:alpha:]]+)$//}
563 _WX_DEP_TYPE= ${comp:C/.+_([[:alpha:]]+)$/\1/}
564 # XXX Need a .for loop here so the variable is expanded before the assignment.
565 . for comp_part in ${_WX_COMP}
566 . if ${_WX_DEP_TYPE} == "lib"
567 . if defined(_WX_LIB_${_WX_COMP}_${_WX_VER})
568 LIB_DEPENDS+= ${_WX_LIB_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
569 BUILD_DEPENDS+= ${_WX_FILE_common_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_common_${_WX_VER}}
571 BUILD_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
572 RUN_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
575 ${_WX_DEP_TYPE:tu}_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
581 # Set build related variables.
584 MAKE_ENV+= WX_CONFIG=${WX_CONFIG}
585 CONFIGURE_ENV+= WX_CONFIG=${WX_CONFIG}
587 .if defined(WX_CONF_ARGS)
588 . if ${WX_CONF_ARGS:tl} == "absolute"
589 CONFIGURE_ARGS+= --with-wx-config=${WX_CONFIG}
590 . elif ${WX_CONF_ARGS:tl} == "relative"
591 CONFIGURE_ARGS+= --with-wx=${LOCALBASE} \
592 --with-wx-config=${WX_CONFIG:T}
594 IGNORE?= selected an invalid wxWidgets configure argument type: ${WX_CONF_ARGS}
598 .endif # _POSTMKINCLUDED