Opened 12 years ago

Closed 12 years ago

#4525 closed defect (fixed)

Test for ICONV_CPP_CONST fails to include CPPFLAGS appropriately, gets it wrong on systems that install iconv.h outside of /usr/include.

Reported by: tvrusso Owned by: Even Rouault
Priority: normal Milestone: 1.9.1
Component: ConfigBuild Version: 1.9.0
Severity: normal Keywords:
Cc:

Description

The test in configure that checks for whether iconv needs a "const" or not runs ${CXX} without passing it the active set of CPPFLAGS. This causes failure on systems where something needs to be in CPPFLAGS for "iconv.h" even to be found.

On FreeBSD, among other systems, third-party libraries and headers are installed into /usr/local/, not /usr as on Linux. Thus, in order for iconv.h to be found, the C preprocessor requires -I/usr/local/include. Most tests in configure use CPPFLAGS appropriately, but this test does not.

This test was added in changeset 23653, on 29 Dec 2011.

The offending test is:

dnl Extra test needed for GCC 4.5 on Solaris 11, where there is
dnl a different behaviour if the tests are compiled with gcc or g++.
dnl So we introduce a ICONV_CPP_CONST that must be used instead of
dnl ICONV_CONST when used from .cpp files.
if test "$am_func_iconv" = "yes"; then
    rm -f testiconv.*
    echo '#include <iconv.h>' > testiconv.cpp
    echo 'int main(int argc, char** argv) { iconv_t cd; return iconv (cd, (const char **) 0, 0, 0, 0); } ' >> testiconv.cpp
    if test -z "`${CXX} testiconv.cpp -c 2>&1`" ; then
        AC_MSG_RESULT([using ICONV_CPP_CONST="const"])
        ICONV_CPP_CONST="const"
    else
        AC_MSG_RESULT([using ICONV_CPP_CONST=""])
        ICONV_CPP_CONST=""
    fi
    rm -f testiconv.*

    AC_DEFINE_UNQUOTED(ICONV_CPP_CONST,$ICONV_CPP_CONST, [For.cpp files, define as const if the declaration of iconv() needs const.])
fi

On FreeBSD, the compilation fails because iconf.h is not found. This is improperly interpreted by the test above as saying the iconv needs no "const" qualifier. Later, when cpl_recode_iconv.cpp is compiled, there is a failure because iconv does, in fact, need a const.

This can be fixed on FreeBSD by adding ${CPPFLAGS} to the compilation line:

dnl Extra test needed for GCC 4.5 on Solaris 11, where there is
dnl a different behaviour if the tests are compiled with gcc or g++.
dnl So we introduce a ICONV_CPP_CONST that must be used instead of
dnl ICONV_CONST when used from .cpp files.
if test "$am_func_iconv" = "yes"; then
    rm -f testiconv.*
    echo '#include <iconv.h>' > testiconv.cpp
    echo 'int main(int argc, char** argv) { iconv_t cd; return iconv (cd, (const char **) 0, 0, 0, 0); } ' >> testiconv.cpp
    if test -z "`${CXX} ${CPPFLAGS} testiconv.cpp -c 2>&1`" ; then
        AC_MSG_RESULT([using ICONV_CPP_CONST="const"])
        ICONV_CPP_CONST="const"
    else
        AC_MSG_RESULT([using ICONV_CPP_CONST=""])
        ICONV_CPP_CONST=""
    fi
    rm -f testiconv.*

    AC_DEFINE_UNQUOTED(ICONV_CPP_CONST,$ICONV_CPP_CONST, [For.cpp files, define as const if the declaration of iconv() needs const.])
fi

Change History (2)

comment:1 by Even Rouault, 12 years ago

Owner: changed from warmerdam to Even Rouault

comment:2 by Even Rouault, 12 years ago

Milestone: 1.9.1
Resolution: fixed
Status: newclosed
Version: svn-trunk1.9.0

Fixed in trunk (r24002) and in branches/1.9 (r24003)

Note: See TracTickets for help on using tickets.