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 # Set _WX_SHVER_comp_ver to 0 and _WX_FILE_comp_ver for libs appropiately.
157 # Set _WX_DEPTYPE_comp_ver for "python" to "run", and others to "lib".
159 . for comp in ${_WX_COMPS_ALL}
161 . for ver in ${_WX_VERS_ALL}
162 . if defined(_WX_LIB_${comp}_${ver})
163 _WX_SHVER_${comp}_${ver}= 0
164 _WX_FILE_${comp}_${ver}= ${LOCALBASE}/lib/lib${_WX_LIB_${comp}_${ver}}.so.${_WX_SHVER_${comp}_${ver}}
166 . if ${_WX_COMP} == "python"
167 _WX_DEPTYPE_${comp}_${ver}= run
169 _WX_DEPTYPE_${comp}_${ver}= lib
173 .endif # !_WX_Defined_Done
176 # Check if the user/port wants Unicode.
179 .if (!defined(WITHOUT_UNICODE) && \
180 (defined(WITH_UNICODE) || defined(WANT_UNICODE)))
181 _WX_UC_AVAILABLE= yes
183 . undef _WX_UC_AVAILABLE
187 # Check if we are going to determine the version.
190 .if !defined(_WX_Version_Done) && (defined(_POSTMKINCLUDED) || \
191 (defined(WX_PREMK) && defined(BEFOREPORTMK) && \
192 (defined(USE_WX) || defined(USE_WX_NOT))))
193 _WX_Need_Version= yes
197 # Check for present components.
200 # Requested by the user.
202 .if defined(WANT_WX) && defined(BEFOREPORTMK)
206 # Used for autodetection of installed versions.
208 .if defined(_WX_Need_Version)
212 .if defined(_WANT_WX)
214 # Check if Unicode will be used.
216 . for __WANT_WX in ${_WANT_WX}
217 . if defined(_WX_UC_AVAILABLE) && \
218 (${_WX_VERS_UC_ALL:M${__WANT_WX}} != "" || ${_WANT_WX:tl} == "yes")
219 _WX_WANT_UNICODE= yes
223 # These variables are reprocessed later so they won't affect other parts.
225 . if defined(WX_UNICODE) || defined(_WX_WANT_UNICODE)
226 _WX_VER_FINAL= ${_WX_VERS_UC_ALL}
231 _WX_VER_FINAL= ${_WX_VERS_ALL}
237 # Fill _HAVE_WX with the installed components.
240 . for __WANT_WX in ${_WANT_WX}
241 # Check if _WANT_WX contains more than one word.
242 . if defined(_HAVE_WX)
243 IGNORE?= selected multiple values for WANT_WX: ${_WANT_WX}
246 # Check for all versions.
247 . if ${_WANT_WX:tl} == "yes"
248 . for comp in ${_WX_COMPS_ALL}
249 . for ver in ${_WX_VER_FINAL}
250 _WX_COMP= _WX_FILE_${comp}_${ver}
251 . if defined(${_WX_COMP}) && exists(${${_WX_COMP}})
252 _HAVE_WX+= ${comp}-${ver}
256 # Check for a specific version.
257 . elif ${_WX_VERS_ALL:M${__WANT_WX}}
258 . for comp in ${_WX_COMPS_ALL}
259 . if exists(${_WX_FILE_${comp}_${__WANT_WX}})
264 IGNORE?= selected an invalid value for WANT_WX: ${__WANT_WX}
269 # Requested by the user.
271 .if defined(WANT_WX) && defined(BEFOREPORTMK)
272 HAVE_WX:= ${_HAVE_WX}
275 # Used for autodetection of installed versions.
277 .if defined(_WX_Need_Version)
278 _WX_VER_INSTALLED:= ${_HAVE_WX:Mwx-*:S/wx-//}
282 # Select wxWidgets version.
285 .if defined(_WX_Need_Version)
286 _WX_Version_Done= yes
289 # Basic component parsing (ignores dependency types).
291 # The variables used are:
292 # _WX_COMP - Component part.
293 # _WX_COMPS_FINAL - Final list of components.
296 # Detect duplicated components.
299 .for comp in ${WX_COMPS}
300 _WX_COMP= ${comp:C/:([[:alpha:]]+)$//}
301 . for __WX_COMP in ${_WX_COMP}
302 . if ${_WX_COMPS_ALL:M${__WX_COMP}} == ""
303 IGNORE?= selected an invalid wxWidgets component: ${__WX_COMP}
306 . for newcomp in ${_WX_COMP}
307 . if ${_WX_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
308 _WX_COMPS_FINAL+= ${newcomp}
313 # Set defaults (if one isn't present).
315 USE_WX?= ${_WX_VERS_ALL}
319 # Make lists of valid and invalid versions.
321 # The following variables are used:
322 # _WX_VER_CHECK - If the version is a single one, express in a range.
323 # _WX_VER_MIN - Lower version of the range.
324 # _WX_VER_MAX - Higher version of the range.
325 # _WX_VER_LIST - List of requested versions.
326 # _WX_VER_NOT_LIST - List of disallowed versions.
327 # _WX_VER_MERGED - List of requested version without disallowed ones.
330 .for list in VER VER_NOT
332 . for ver in ${USE_WX${list:C/VER//}}
333 _WX_VER_CHECK:= ${ver:C/^([[:digit:]]+(\.[[:digit:]]+)*)$/\1-\1/}
334 _WX_VER_MIN:= ${_WX_VER_CHECK:C/([[:digit:]]+(\.[[:digit:]]+)*)[-+].*/\1/}
335 _WX_VER_MAX:= ${_WX_VER_CHECK:C/.*-([[:digit:]]+(\.[[:digit:]]+)*)/\1/}
336 # Minimum version not specified.
337 . if ${_WX_VER_MIN} == ${_WX_VER_CHECK}
339 . for v in ${_WX_VERS_ALL}
340 . if ${_WX_VER_CHECK:C/[-+]//} == ${v} || ${_WX_VERS_SKIP:M${v}} == ""
345 # Maximum version not specified.
346 . if ${_WX_VER_MAX} == ${_WX_VER_CHECK}
347 . for v in ${_WX_VERS_ALL}
348 . if ${_WX_VER_CHECK:C/[-+]//} == ${v} || ${_WX_VERS_SKIP:M${v}} == ""
353 # Expand versions and add valid ones to each list.
354 . for v in ${_WX_VERS_ALL}
355 . if ${_WX_VER_MIN} <= ${v} && ${_WX_VER_MAX} >= ${v} && \
356 ${_WX_${list}_LIST:M${v}} == ""
357 _WX_${list}_LIST+= ${v}
363 # Merge the lists into a single list of valid versions.
366 .for ver in ${_WX_VER_LIST}
367 . if ${_WX_VER_NOT_LIST:M${ver}} == ""
368 _WX_VER_MERGED+= ${ver}
372 # Check for a null version.
374 .if empty(_WX_VER_MERGED)
375 IGNORE?= selected a null or invalid wxWidgets version
378 # Avoid versions which have unavailable components.
380 .for ver in ${_WX_VER_MERGED}
381 . for comp in ${_WX_COMPS_FINAL}
382 . if !defined(_WX_PORT_${comp}_${ver})
383 _WX_WRONG_COMPS+= ${comp}
384 _WX_WRONG_VERS+= ${ver}
385 _WX_VER_MERGED:= ${_WX_VER_MERGED:N${ver}}
390 .if empty(_WX_VER_MERGED)
391 IGNORE?= selected wxWidgets versions (${_WX_WRONG_VERS}) which do not have the selected components (${_WX_WRONG_COMPS})
398 # Create a list of capable versions.
401 .for ver in ${_WX_VER_MERGED}
402 . if ${_WX_VERS_UC_ALL:M${ver}} != ""
407 # Requested by the user or port (optional).
409 .if defined(_WX_UC_AVAILABLE)
410 . for ver in ${_WX_VER_UC}
411 . if ${_WX_VERS_UC_ALL:M${ver}} != ""
417 # Requested by the port (mandatory).
419 .if defined(WX_UNICODE)
420 . if empty(_WX_VER_UC)
421 IGNORE?= selected a wxWidgets version which does not support Unicode: ${_WX_VER_MERGED}
425 # Set Unicode variables.
427 .if defined(WX_UNICODE)
428 _WX_VER_FINAL= ${_WX_VER_UC}
433 _WX_VER_FINAL= ${_WX_VER_MERGED}
439 # Remove unusable installed versions.
441 .for ver in ${_WX_VER_INSTALLED}
442 . if ${_WX_VER_FINAL:M${ver}} == ""
443 _WX_VER_INSTALLED:= ${_WX_VER_INSTALLED:N${ver}}
448 # Choose final version.
452 # Check for the following (in order):
453 # 1) WITH_WX_VER - User preference.
454 # 2) WANT_WX_VER - Port preference.
455 # 3) _WX_VER_INSTALLED - Installed versions.
456 # 4) _WX_VER_FINAL - Available versions.
459 .for list in _WX_VER_FINAL ${_WX_VERS_LISTS}
460 . if defined(${list})
461 . for ver in ${${list}}
462 . if ${_WX_VER_FINAL:M${ver}} != ""
473 WX_CONFIG?= ${LOCALBASE}/bin/wxgtk2${_WX_UC}-${_WX_VER}-config
474 WXRC_CMD?= ${LOCALBASE}/bin/wxrc-gtk2${_WX_UC}-${_WX_VER}
475 WX_VERSION?= ${_WX_VER}
477 .endif # _WX_Need_Version
480 # Process components list and add dependencies, variables, etc.
483 .if defined(_POSTMKINCLUDED)
488 # The variables used are:
489 # _WX_COMP - Component part.
490 # _WX_DEP_TYPE - Dependency type part.
491 # _WX_COMP_NEW - Component + dependency type.
492 # _WX_COMPS_FINAL - Final list of components with dependency types.
495 # Default components.
499 # Detect invalid and duplicated components.
502 .for comp in ${WX_COMPS}
503 _WX_COMP= ${comp:C/:([[:alpha:]]+)$//}
504 . if ${_WX_COMP} == ${comp}
505 _WX_DEP_TYPE= ${_WX_DEPTYPE_${comp}_${_WX_VER}}
507 _WX_DEP_TYPE= ${comp:C/.+:([[:alpha:]]+)$/\1/}
509 _WX_COMP_NEW= ${_WX_COMP}_${_WX_DEP_TYPE}
510 . for __WX_COMP in ${_WX_COMP}
511 . if ${_WX_COMPS_ALL:M${__WX_COMP}} == ""
512 IGNORE?= selected an invalid wxWidgets component: ${__WX_COMP}
515 . for __WX_DEP_TYPE in ${_WX_DEP_TYPE}
516 . if ${_WX_DEP_TYPES_ALL:M${__WX_DEP_TYPE}} == ""
517 IGNORE?= selected an invalid wxWidgets dependency type: ${__WX_DEP_TYPE}
520 . if !defined(_WX_PORT_${_WX_COMP}_${_WX_VER})
521 IGNORE?= selected a wxWidgets component (${_WX_COMP}) which is not available for the selected version (${_WX_VER})
523 . for newcomp in ${_WX_COMP_NEW}
524 . if ${_WX_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
525 _WX_COMPS_FINAL+= ${newcomp}
532 # The variable used are:
533 # _WX_COMP - Component part.
534 # _WX_DEP_TYPE - Dependency type part.
536 .for comp in ${_WX_COMPS_FINAL}
537 _WX_COMP= ${comp:C/_([[:alpha:]]+)$//}
538 _WX_DEP_TYPE= ${comp:C/.+_([[:alpha:]]+)$/\1/}
539 # XXX Need a .for loop here so the variable is expanded before the assignment.
540 . for comp_part in ${_WX_COMP}
541 . if ${_WX_DEP_TYPE} == "lib"
542 . if defined(_WX_LIB_${_WX_COMP}_${_WX_VER})
543 LIB_DEPENDS+= lib${_WX_LIB_${comp_part}_${_WX_VER}}.so:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
545 BUILD_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
546 RUN_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
549 ${_WX_DEP_TYPE:tu}_DEPENDS+= ${_WX_FILE_${comp_part}_${_WX_VER}}:${PORTSDIR}/${_WX_PORT_${comp_part}_${_WX_VER}}
555 # Set build related variables.
558 MAKE_ENV+= WX_CONFIG=${WX_CONFIG}
559 CONFIGURE_ENV+= WX_CONFIG=${WX_CONFIG}
561 .if defined(WX_CONF_ARGS)
562 . if ${WX_CONF_ARGS:tl} == "absolute"
563 CONFIGURE_ARGS+= --with-wx-config=${WX_CONFIG}
564 . elif ${WX_CONF_ARGS:tl} == "relative"
565 CONFIGURE_ARGS+= --with-wx=${LOCALBASE} \
566 --with-wx-config=${WX_CONFIG:T}
568 IGNORE?= selected an invalid wxWidgets configure argument type: ${WX_CONF_ARGS}
572 .endif # _POSTMKINCLUDED