groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] preconv autoconfigury


From: Bruno Haible
Subject: [Groff] preconv autoconfigury
Date: Sat, 31 Dec 2005 16:02:11 +0100
User-agent: KMail/1.5

Hello Werner,

Here's a little bit of advice on the autoconf stuff for preconv.

- <locale.h> and setlocale() can be used unconditionally. There's no known
  platform which lacks it.

- For iconv() I recommend to take the AM_ICONV macro from gnulib. It comes
  as a set of five files:
    m4/iconv.m4
    m4/lib-ld.m4
    m4/lib-link.m4
    m4/lib-prefix.m4
    build-aux/config.rpath
  AM_ICONV is documented in the GNU gettext manual. It deals with all
  possible complexities of non-GNU and GNU iconv implementations.

- For nl_langinfo(CODESET), there is a macro AM_LANGINFO_CODESET
  in gnulib. One file:
    m4/codeset.m4
  Alternatively, you can also use the gnulib module 'localcharset',
  which does the same thing in a more portable way. I.e. it solves the
  portability problems to FreeBSD, NetBSD, OpenBSD, MacOS X, Solaris 7,
  Woe32, VMS and others.

Find attached a patch which looks for iconv() and for nl_langinfo(CODESET).
For easier future upgrade, I don't add the .m4 files to aclocal.m4 manually,
but instead put them into an m4/ directory.

Bruno


2005-12-30  Bruno Haible  <address@hidden>

        * m4/groff.m4: Renamed from aclocal.m4.
        * m4/codeset.m4: New file, from gnulib.
        * m4/iconv.m4: New file, from gnulib.
        * m4/lib-ld.m4, m4/lib-link.m4, m4/lib-prefix.m4: New files, from
        gnulib.
        * config.rpath: New file, from gnulib.
        * config.guess, config.sub: New files, from gnulib.
        * Makefile.sub (M4MACROS): New variable.
        (configure): Fix typo.
        (aclocal.m4): New rule.
        * configure.ac: Invoke AM_ICONV and AM_LANGINFO_CODESET.
        * Makefile.in (LIBICONV): New variable.
        (MDEFINES): Pass it to recursive makes.
        * src/preproc/preconv/preconv.cpp: Use HAVE_LANGINFO_CODESET and
        HAVE_ICONV instead of I18N macro.
        * src/preproc/preconv/Makefile.sub (EXTRA_LDFLAGS): New variable.

*** Makefile.sub.bak    2004-10-15 07:21:55.000000000 +0200
--- Makefile.sub        2005-12-31 02:16:34.000000000 +0100
***************
*** 12,28 ****
    groff.log
  CLEANADD=Makefile.cfg conftest*
  
  distfiles: configure
  
! $(scrdir)/configure: configure.ac aclocal.m4
        cd $(srcdir) && autoconf
  
  config.status: configure
        $(SHELL) config.status --recheck
  
  # autoheader might not change config.hin, so touch a stamp file.
  $(srcdir)/config.hin: stamp-h.in
! $(srcdir)/stamp-h.in: configure.ac aclocal.m4
        cd $(srcdir) && autoheader
        echo timestamp > $(srcdir)/stamp-h.in
       
--- 12,37 ----
    groff.log
  CLEANADD=Makefile.cfg conftest*
  
+ M4MACROS = \
+   $(srcdir)/m4/groff.m4 \
+   $(srcdir)/m4/codeset.m4 \
+   $(srcdir)/m4/iconv.m4 \
+   $(srcdir)/m4/lib-link.m4 $(srcdir)/m4/lib-ld.m4 $(srcdir)/m4/lib-prefix.m4
+ 
  distfiles: configure
  
! $(srcdir)/configure: configure.ac $(srcdir)/aclocal.m4
        cd $(srcdir) && autoconf
  
+ $(srcdir)/aclocal.m4: $(M4MACROS)
+       cd $(srcdir) && aclocal -I m4
+ 
  config.status: configure
        $(SHELL) config.status --recheck
  
  # autoheader might not change config.hin, so touch a stamp file.
  $(srcdir)/config.hin: stamp-h.in
! $(srcdir)/stamp-h.in: configure.ac $(srcdir)/aclocal.m4
        cd $(srcdir) && autoheader
        echo timestamp > $(srcdir)/stamp-h.in
       
*** configure.ac.bak    2005-12-30 16:27:46.000000000 +0100
--- configure.ac        2005-12-31 02:10:28.000000000 +0100
***************
*** 86,91 ****
--- 86,92 ----
  # checks for libraries
  GROFF_LIBC
  GROFF_LIBM
+ AM_ICONV
  
  # checks for functions
  AC_FUNC_MMAP
***************
*** 99,104 ****
--- 100,106 ----
  AC_CHECK_FUNCS([gettimeofday isatty kill rename setlocale strsep])
  GROFF_MKSTEMP
  AC_CHECK_DECLS([sys_siglist])
+ AM_LANGINFO_CODESET
  
  # checks for compiler characteristics
  GROFF_ARRAY_DELETE
*** Makefile.in.bak     2005-12-30 16:27:46.000000000 +0100
--- Makefile.in 2005-12-31 02:36:00.000000000 +0100
***************
*** 365,370 ****
--- 365,371 ----
  LIBEXT=`case $(OBJEXT) in obj) echo lib;; *) echo a;; esac`
  address@hidden@
  address@hidden@
+ address@hidden@
  address@hidden@
  address@hidden@
  address@hidden@
***************
*** 419,424 ****
--- 420,426 ----
    "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
    "LDFLAGS=$(LDFLAGS)" \
    "LIBEXT=$(LIBEXT)" \
+   "LIBICONV=$(LIBICONV)" \
    "LIBM=$(LIBM)" \
    "LIBOBJS=$(LIBOBJS)" \
    "LIBS=$(LIBS)" \
*** src/preproc/preconv/preconv.cpp.bakk        2005-12-31 00:58:11.000000000 
+0100
--- src/preproc/preconv/preconv.cpp     2005-12-31 02:23:06.000000000 +0100
***************
*** 19,26 ****
  with groff; see the file COPYING.  If not, write to the Free Software
  Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  
- #define I18N
- 
  #include "lib.h"
  
  #include <assert.h>
--- 19,24 ----
***************
*** 31,46 ****
  #include "nonposix.h"
  #include "stringclass.h"
  
! #ifdef I18N
! # include <locale.h>
  # include <langinfo.h>
  # include <iconv.h>
  # ifdef WORDS_BIGENDIAN
  #  define UNICODE "UTF-32BE"
  # else
  #  define UNICODE "UTF-32LE"
  # endif
! #endif /* I18N */
  
  #define MAX_VAR_LEN 100
  
--- 29,48 ----
  #include "nonposix.h"
  #include "stringclass.h"
  
! #include <locale.h>
! 
! #if HAVE_LANGINFO_CODESET
  # include <langinfo.h>
+ #endif
+ 
+ #if HAVE_ICONV
  # include <iconv.h>
  # ifdef WORDS_BIGENDIAN
  #  define UNICODE "UTF-32BE"
  # else
  #  define UNICODE "UTF-32LE"
  # endif
! #endif
  
  #define MAX_VAR_LEN 100
  
***************
*** 584,590 ****
  }
  
  // Locale-sensible conversion.
! #ifdef I18N
  void
  conversion_iconv(FILE *fp, const string &data, char *enc)
  {
--- 586,592 ----
  }
  
  // Locale-sensible conversion.
! #if HAVE_ICONV
  void
  conversion_iconv(FILE *fp, const string &data, char *enc)
  {
***************
*** 668,674 ****
    for (int *ptr = outbuf; (char *)ptr < limit; ptr++)
      unicode_entity(*ptr);
  }
! #endif /* I18N */
  
  // ---------------------------------------------------------
  // Handle Byte Order Mark.
--- 670,676 ----
    for (int *ptr = outbuf; (char *)ptr < limit; ptr++)
      unicode_entity(*ptr);
  }
! #endif /* HAVE_ICONV */
  
  // ---------------------------------------------------------
  // Handle Byte Order Mark.
***************
*** 980,986 ****
    else if (!strcasecmp(encoding, "cp1047"))
      conversion_cp1047(fp, data);
    else {
! #ifdef I18N
      conversion_iconv(fp, data, encoding);
  #else
      error("encoding system `%1' not supported", encoding);
--- 982,988 ----
    else if (!strcasecmp(encoding, "cp1047"))
      conversion_cp1047(fp, data);
    else {
! #if HAVE_ICONV
      conversion_iconv(fp, data, encoding);
  #else
      error("encoding system `%1' not supported", encoding);
***************
*** 1018,1025 ****
    // Determine the default encoding.  This must be done before
    // getopt() is called since the usage message shows the default
    // encoding.
- #ifdef I18N
    setlocale(LC_ALL, "");
    char *locale = setlocale(LC_CTYPE, NULL);
    if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
      default_encoding = "latin1";
--- 1020,1027 ----
    // Determine the default encoding.  This must be done before
    // getopt() is called since the usage message shows the default
    // encoding.
    setlocale(LC_ALL, "");
+ #if HAVE_LANGINFO_CODESET
    char *locale = setlocale(LC_CTYPE, NULL);
    if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
      default_encoding = "latin1";
***************
*** 1030,1036 ****
    }
  #else
    default_encoding = "latin1";
! #endif /* I18N */
  
    program_name = argv[0];
    int opt;
--- 1032,1038 ----
    }
  #else
    default_encoding = "latin1";
! #endif /* HAVE_LANGINFO_CODESET */
  
    program_name = argv[0];
    int opt;
*** src/preproc/preconv/Makefile.sub.bak        2005-12-30 10:31:50.000000000 
+0100
--- src/preproc/preconv/Makefile.sub    2005-12-31 02:30:22.000000000 +0100
***************
*** 2,6 ****
--- 2,7 ----
  # MAN1=preconv.n
  XLIBS=$(LIBGROFF)
  MLIB=$(LIBM)
+ EXTRA_LDFLAGS=$(LIBICONV)
  OBJS=preconv.$(OBJEXT)
  CCSRCS=$(srcdir)/preconv.cpp

Attachment: to-werner3.tgz
Description: preconv-new-files.tar.gz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]