apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr-util/build apu-iconv.m4
Date Sun, 21 Jul 2002 11:09:12 GMT
jerenkrantz    2002/07/21 04:09:12

  Modified:    build    apu-iconv.m4
  Log:
  Revamp (again!) iconv autoconf tests
  
  - Define APU_TRY_ICONV macro that does the heavy lifting
  - Add --with-iconv support (will override system iconv)
  - Check for iconv.h header first
    - If present, run APU_TRY_ICONV
        - If successful, set to 1
        - If fails, add -liconv to LIBS and rerun APU_TRY_ICONV
            - If successful, add -liconv to APRUTIL{_EXPORT}_LIBS and set to 1
            - If fails, set to 0
    - If not present, set to 0
  
  If --with-iconv is specified, ensure that we found an iconv impl.  If so,
  then add the INCLUDES and LDFLAGS as appropriate (*may* need -R in LDFLAGS?).
  Otherwise, this is a fatal error.
  
  Obtained from: libxml's autoconf code (only conceptually)
  
  Revision  Changes    Path
  1.5       +46 -15    apr-util/build/apu-iconv.m4
  
  Index: apu-iconv.m4
  ===================================================================
  RCS file: /home/cvs/apr-util/build/apu-iconv.m4,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apu-iconv.m4	20 Jul 2002 08:06:33 -0000	1.4
  +++ apu-iconv.m4	21 Jul 2002 11:09:12 -0000	1.5
  @@ -3,26 +3,58 @@
   dnl
   
   dnl
  -dnl APU_FIND_ICONV: find an iconv library
  +dnl APU_TRY_ICONV[ IF-SUCCESS, IF-FAILURE ]: try to compile for iconv.
   dnl
  -AC_DEFUN(APU_FIND_ICONV,[
  +AC_DEFUN(APU_TRY_ICONV,[
  +  AC_TRY_LINK([
  +#include <stdlib.h>
  +#include <iconv.h>
  +],
  +[
  +  iconv_t cd = iconv_open("", "");
  +  iconv(cd, NULL, NULL, NULL, NULL);
  +], [$1], [$2])
  +])
   
   dnl
  -dnl TODO: Check for --with-iconv or --with-apr-iconv, or look for
  -dnl apr-iconv sources or an installed apr-iconv ...
  +dnl APU_FIND_ICONV: find an iconv library
   dnl
  +AC_DEFUN(APU_FIND_ICONV,[
   
  -AC_CHECK_FUNCS(iconv, [
  -  have_iconv="1"
  -], [ 
  -  AC_CHECK_LIB(iconv, iconv, [
  -    APR_ADDTO(APRUTIL_LIBS,[-liconv])
  -    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-liconv])
  -    have_iconv="1"
  -  ], [
  -    have_iconv="0"
  +apu_iconv_dir="unknown"
  +AC_ARG_WITH(iconv,[  --with-iconv[=DIR]        path to iconv installation],
  +  [ apu_iconv_dir="$withval"
  +    if test "$apu_iconv_dir" != "yes"; then
  +      APR_ADDTO(CPPFLAGS,[-I$apu_iconv_dir/include])
  +      APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
  +    fi
     ])
  -])
  +
  +AC_CHECK_HEADER(iconv.h, [
  +  APU_TRY_ICONV([ have_iconv="1" ], [
  +
  +   APR_ADDTO(LIBS,[-liconv])
  +
  +   APU_TRY_ICONV([
  +     APR_ADDTO(APRUTIL_LIBS,[-liconv])
  +     APR_ADDTO(APRUTIL_EXPORT_LIBS,[-liconv])
  +     have_iconv="1" ],
  +     [ have_iconv="0" ])
  +
  +   APR_REMOVEFROM(LIBS,[-liconv])
  +
  + ])
  +], [ have_iconv="0" ])
  +
  +if test "$apu_iconv_dir" != "unknown"; then
  +  if test "$have_iconv" != "1"; then
  +    AC_MSG_ERROR([iconv support requested, but not found])
  +  fi
  +  APR_REMOVEFROM(CPPFLAGS,[-I$apu_iconv_dir/include])
  +  APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
  +  APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include])
  +  APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
  +fi
   
   if test "$have_iconv" = "1"; then
     APU_CHECK_ICONV_INBUF
  @@ -34,7 +66,6 @@
   
   AC_SUBST(have_iconv)
   ])dnl
  -
   
   dnl
   dnl APU_CHECK_ICONV_INBUF
  
  
  

Mime
View raw message