freebsd-ports/Mk/Uses/iconv.mk
Raphael Kubo da Costa f358732b18 Uses/iconv.mk: Set iconv-related CMake variables.
The way we deal with iconv in base and ports across different FreeBSD
releases is complicated: 9.x does not have iconv.h in base, 10.1 has it with
a different prototype for iconv(3) and later versions have the right
iconv(3) prototype. And, in some cases (USES=iconv:{translit,wchar_t}), we
must always use the libiconv port.

This is why there are so many checks in Uses/iconv.mk: we need to know the
situation we currently have in order to decide whether to pull iconv from
converters/libiconv, whether to just use its header (and pull the library
from base) or whether to use everything from base.

r384038 adjusted several CMake-based ports, but did so in a way that was not
very scalable and required a few intrusive patches to some ports. Most ports
that have both USES=cmake and USES=iconv use variations of FindIconv.cmake
that behave similarly. This change passes the header and library values we
really want to use to CMake using the most common variable names, bypassing
the calls to find_path() and find_library() that would sometimes end up
finding the wrong file. The few ports that use different variable names have
had their Makefiles adjusted (we manually pass the values we want via
CMAKE_ARGS).

Other changes:
- chinese/fcitx: Explicitly set LIBICONV_LIBC_HAS_ICONV_OPEN=OFF as we
  always want the version from ports because of USES=iconv:wchar_t.
- editors/calligra: Explicitly use iconv:translit because Kexi needs it.
- irc/weechat and irc/weechat-devel: The FindIconv.cmake patches could not
  be entirely removed because the check_library_exists() calls are wrong.
  Sent upstream: https://github.com/weechat/weechat/pull/513
- textproc/ctpp2: Use iconv:translit when the TRANSLITERATE option is used.

PORTREVISION has been bumped in editors/calligra and textproc/ctpp2 because
their dependency list has changed in 10.2 and later as the ports version is
always used now.

PR:		202798
Reviewed by:	antoine, tijl
Approved by:	portmgr (antoine)
2015-09-03 15:44:13 +00:00

69 lines
2.1 KiB
Makefile

# $FreeBSD$
#
# handle dependency on the iconv port
#
# Feature: iconv
# Usage: USES=iconv or USES=iconv:ARGS
# Valid ARGS: lib (default, implicit), build, patch,
# wchar_t (port uses "WCHAR_T" extension),
# translit (port uses "//TRANSLIT" extension)
#
# MAINTAINER: portmgr@FreeBSD.org
.if !defined(_INCLUDE_USES_ICONV_MK)
_INCLUDE_USES_ICONV_MK= yes
.if !exists(/usr/include/iconv.h) || ${iconv_ARGS:Mwchar_t} || ${iconv_ARGS:Mtranslit}
ICONV_CMD= ${LOCALBASE}/bin/iconv
ICONV_LIB= -liconv
ICONV_PREFIX= ${LOCALBASE}
ICONV_CONFIGURE_ARG= --with-libiconv-prefix=${LOCALBASE}
ICONV_CONFIGURE_BASE= --with-libiconv=${LOCALBASE}
ICONV_INCLUDE_PATH= ${LOCALBASE}/include
ICONV_LIB_PATH= ${LOCALBASE}/lib/libiconv.so
.if ${iconv_ARGS:Mbuild}
BUILD_DEPENDS+= ${ICONV_CMD}:${PORTSDIR}/converters/libiconv
.elif ${iconv_ARGS:Mpatch}
PATCH_DEPENDS+= ${ICONV_CMD}:${PORTSDIR}/converters/libiconv
.else
LIB_DEPENDS+= libiconv.so:${PORTSDIR}/converters/libiconv
.endif
.else
ICONV_CMD= /usr/bin/iconv
ICONV_LIB=
ICONV_PREFIX= /usr
ICONV_CONFIGURE_ARG=
ICONV_CONFIGURE_BASE=
ICONV_INCLUDE_PATH= /usr/include
ICONV_LIB_PATH= /usr/lib/libc.so
.if ${OPSYS} == DragonFly || (${OPSYS} == FreeBSD && (${OSVERSION} < 1001514 \
|| (${OSVERSION} >= 1100000 && ${OSVERSION} < 1100069))) \
|| exists(${LOCALBASE}/include/iconv.h)
BUILD_DEPENDS+= libiconv>=1.14_8:${PORTSDIR}/converters/libiconv
CPPFLAGS+= -DLIBICONV_PLUG
CFLAGS+= -DLIBICONV_PLUG
CXXFLAGS+= -DLIBICONV_PLUG
OBJCFLAGS+= -DLIBICONV_PLUG
ICONV_INCLUDE_PATH= ${LOCALBASE}/include
.endif
.endif
# These are the most common names for the iconv-related variables found in
# CMake-based ports. We set them here via CMAKE_ARGS to make sure that the best
# combination is always used (ie. we prefer the version in libc whenever it is
# available, and sometimes have to fall back to the iconv.h header from ports
# while still using the library from base).
CMAKE_ARGS+= -DICONV_INCLUDE_DIR=${ICONV_INCLUDE_PATH} \
-DICONV_LIBRARIES=${ICONV_LIB_PATH} \
-DICONV_LIBRARY=${ICONV_LIB_PATH} \
-DLIBICONV_INCLUDE_DIR=${ICONV_INCLUDE_PATH} \
-DLIBICONV_LIBRARIES=${ICONV_LIB_PATH} \
-DLIBICONV_LIBRARY=${ICONV_LIB_PATH}
.endif