After 2013-10-08 (254273),
FreeBSD 10-CURRENT and newer versions have a native
iconv in the operating system. On earlier
versions, converters/libiconv
was used as a dependency.
For software that needs iconv, define
USES=iconv. FreeBSD versions before
10-CURRENT on 2013-08-13 (254273) do
not have a native iconv. On these earlier
versions, a dependency on
converters/libiconv will be
added automatically.
When a port defines USES=iconv, these
variables will be available:
| Variable name | Purpose | Value before FreeBSD 10-CURRENT 254273 (2013-08-13) | Value after FreeBSD 10-CURRENT 254273 (2013-08-13) |
|---|---|---|---|
ICONV_CMD | Directory where the iconv
binary resides | ${LOCALBASE}/bin/iconv | /usr/bin/iconv |
ICONV_LIB | ld argument to link to
libiconv (if needed) | -liconv | (空) |
ICONV_PREFIX | Directory where the iconv
implementation resides (useful for configure
scripts) | ${LOCALBASE} | /usr |
ICONV_CONFIGURE_ARG | Preconstructed configure argument for configure scripts | --with-libiconv-prefix=${LOCALBASE} | (空) |
ICONV_CONFIGURE_BASE | Preconstructed configure argument for configure scripts | --with-libiconv=${LOCALBASE} | (空) |
These two examples automatically populate the variables
with the correct value for systems using
converters/libiconv or the
native iconv respectively:
As shown above, ICONV_LIB is empty when
a native iconv is present. This can be
used to detect the native iconv and respond
appropriately.
Sometimes a program has an ld argument
or search path hardcoded in a Makefile or
configure script. This approach can be used to solve that
problem:
-liconvUSES= iconv
post-patch:
@${REINPLACE_CMD} -e 's/-liconv/${ICONV_LIB}/' ${WRKSRC}/MakefileIn some cases it is necessary to set alternate values or
perform operations depending on whether there is a native
iconv.
bsd.port.pre.mk must be included before
testing the value of ICONV_LIB:
iconv
AvailabilityUSES= iconv
.include <bsd.port.pre.mk>
post-patch:
.if empty(ICONV_LIB)
# native iconv detected
@${REINPLACE_CMD} -e 's|iconv||' ${WRKSRC}/Config.sh
.endif
.include <bsd.port.post.mk>本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。