Fix macro file 'serial' numbers for 'aclocal --install'.
[libiconv.git] / configure.ac
blob95bd2f3606eeb6a979467f069750ad5f05defb98
1 dnl Copyright (C) 1999-2011, 2016, 2018-2023 Free Software Foundation, Inc.
2 dnl This file is part of the GNU LIBICONV Library.
3 dnl
4 dnl The GNU LIBICONV Library is free software; you can redistribute it
5 dnl and/or modify it under the terms of the GNU Lesser General Public
6 dnl License as published by the Free Software Foundation; either version 2.1
7 dnl of the License, or (at your option) any later version.
8 dnl
9 dnl The GNU LIBICONV Library is distributed in the hope that it will be
10 dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 dnl Lesser General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU Lesser General Public
15 dnl License along with the GNU LIBICONV Library; see the file COPYING.LIB.
16 dnl If not, see <https://www.gnu.org/licenses/>.
18 AC_PREREQ([2.64])
19 AC_INIT([libiconv], [1.17])
20 AC_CONFIG_SRCDIR([lib/iconv.c])
21 AC_CONFIG_AUX_DIR([build-aux])
22 AM_INIT_AUTOMAKE
23 AC_CONFIG_HEADERS([config.h lib/config.h])
24 AC_PROG_MAKE_SET
26 dnl           checks for basic programs
28 AC_PROG_CC
29 AC_PROG_CPP
30 AC_PROG_INSTALL
32 AC_PATH_PROG([STRIP], [strip], [:]) dnl sets STRIP
33 AM_PROG_INSTALL_STRIP               dnl overrides STRIP when cross-compiling,
34                                     dnl sets INSTALL_STRIP_PROGRAM
36 dnl           check for host type
38 AC_CANONICAL_HOST
40 dnl           hack
42 dnl Hack to work around limitations of automake and error.m4 regarding LIBOBJS.
43 dnl "srclib/Makefile.am:32: automatically discovered file `error.h' should not be explicitly mentioned"
44 AC_DEFUN([my_SRCLIB_OBJ],[SRCLIBOBJS="$SRCLIBOBJS $1.$ac_objext"])
45 AC_DEFUN([my_SRCLIB_REPLACE_FUNCS], [AC_CHECK_FUNCS([$1], , [my_SRCLIB_OBJ($ac_func)])])
46 m4_pushdef([AC_LIBOBJ], m4_defn([my_SRCLIB_OBJ]))
47 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([my_SRCLIB_REPLACE_FUNCS]))
49 dnl           checks for UNIX variants that set DEFS
51 gl_EARLY
53 dnl           checks for build configuration
55 LT_INIT([disable-static win32-dll])
56 gl_RELOCATABLE
58 AC_ARG_ENABLE([extra-encodings],
59   [AS_HELP_STRING([--enable-extra-encodings],
60                   [add support for a few rarely used encodings])],
61   [AC_DEFINE([ENABLE_EXTRA], 1,
62              [Define to 1 to enable a few rarely used encodings.])
63    USE_EXTRA_ENCODINGS=yes],
64   [USE_EXTRA_ENCODINGS=no])
65 AC_SUBST([USE_EXTRA_ENCODINGS])
67 dnl           checks for programs
69 CL_PROG_CP
70 CL_PROG_LN
71 AC_PROG_LN_S
73 dnl           checks for compiler output filename suffixes
75 AC_OBJEXT
76 AC_EXEEXT
78 dnl           checks for build configuration
80 dnl Prepares the libtool configuration for handling of Windows resources, and
81 dnl sets the RC variable to a program that compiles Windows resource files.
82 LT_LANG([Windows Resource])
84 dnl On native Windows and Cygwin, we can activate special Makefile rules which
85 dnl add version information to the executables.
86 case "$host_os" in
87   mingw* | windows* | cygwin*) is_woe32=yes ;;
88   *) is_woe32=no ;;
89 esac
90 WOE32=$is_woe32
91 AC_SUBST([WOE32])
92 if test $WOE32 = yes; then
93   dnl Check for a program that compiles Windows resource files.
94   AC_CHECK_TOOL([WINDRES], [windres])
97 gl_VISIBILITY
98 AM_ICONV
99 AM_GNU_GETTEXT([external], [need-ngettext])
101 dnl           checks for typedefs
103 AC_TYPE_MBSTATE_T
104 gt_TYPE_WCHAR_T
106 dnl           checks for header files, functions and declarations
108 if test "$am_cv_func_iconv" = yes -a -n "$iconv_arg1"; then
109   ICONV_CONST="const"
110 else
111   ICONV_CONST=""
113 AC_SUBST([ICONV_CONST])
115 if test $gt_cv_c_wchar_t = yes; then
116   HAVE_WCHAR_T=1
117 else
118   HAVE_WCHAR_T=0
120 AC_SUBST([HAVE_WCHAR_T])
122 AC_CHECK_FUNCS([getc_unlocked mbrtowc wcrtomb mbsinit setlocale])
124 dnl mbstate_t is used if HAVE_WCRTOMB || HAVE_MBRTOWC, see lib/loop_wchar.h.
125 if test $ac_cv_func_wcrtomb = yes || test $ac_cv_func_mbrtowc = yes; then
126   USE_MBSTATE_T=1
127 else
128   USE_MBSTATE_T=0
130 AC_SUBST([USE_MBSTATE_T])
132 AC_CACHE_CHECK([whether <wchar.h> is standalone],
133   [gl_cv_header_wchar_h_standalone],
134   [AC_COMPILE_IFELSE(
135      [AC_LANG_PROGRAM(
136         [[#include <wchar.h>
137           wchar_t w;]],
138         [[]])],
139     [gl_cv_header_wchar_h_standalone=yes],
140     [gl_cv_header_wchar_h_standalone=no])])
141 if test $gl_cv_header_wchar_h_standalone = yes; then
142   BROKEN_WCHAR_H=0
143 else
144   BROKEN_WCHAR_H=1
146 AC_SUBST([BROKEN_WCHAR_H])
148 AC_REPLACE_FUNCS([memmove])
150 AM_LANGINFO_CODESET
151 gl_FCNTL_O_FLAGS
153 AC_EILSEQ
155 AC_C_BIGENDIAN([],
156   [AC_DEFINE([WORDS_LITTLEENDIAN], [1],
157      [Define if the machine's byte ordering is little endian.])
158   ])
160 gl_INIT
162 dnl           hack
164 dnl End of hack to work around limitations of automake and error.m4.
165 m4_popdef([AC_REPLACE_FUNCS])
166 m4_popdef([AC_LIBOBJ])
167 AC_SUBST([SRCLIBOBJS])
169 dnl Compilation on native Windows and Cygwin needs special Makefile rules,
170 dnl because
171 dnl 1. when we install a shared library, we must arrange to export
172 dnl    auxiliary pointer variables for every exported variable,
173 dnl 2. when we install a shared library and a static library simultaneously
174 dnl    (e.g. when the user overrides the 'disable-static' default above by
175 dnl    passing the configure options --enable-shared --enable-static),
176 dnl    the include file specifies __declspec(dllimport) and therefore we
177 dnl    must arrange to define the auxiliary pointer variables for the
178 dnl    exported variables _also_ in the static library.
179 if test "$enable_shared" = yes; then
180   case "$host_os" in
181     mingw* | windows* | cygwin*) is_woe32dll=yes ;;
182     *) is_woe32dll=no ;;
183   esac
184 else
185   is_woe32dll=no
187 WOE32DLL=$is_woe32dll
188 AC_SUBST([WOE32DLL])
189 if test $is_woe32dll = yes; then
190   DLL_VARIABLE='__declspec (dllimport)'
191 else
192   DLL_VARIABLE=
194 AC_SUBST([DLL_VARIABLE])
196 AH_BOTTOM([
197 /* On Windows, variables that may be in a DLL must be marked specially.
198    The symbols marked with DLL_VARIABLE should be exported if and only if the
199    object file gets included in a DLL.  Libtool, on Windows platforms, defines
200    the C macro DLL_EXPORT (together with PIC) when compiling for a shared
201    library (called DLL under Windows) and does not define it when compiling
202    an object file meant to be linked statically into some executable.  */
203 #if defined _MSC_VER && defined DLL_EXPORT
204 # define DLL_VARIABLE __declspec (dllimport)
205 #else
206 # define DLL_VARIABLE
207 #endif
210 AC_CONFIG_SUBDIRS([libcharset])
211 AC_CONFIG_FILES([Makefile])
212 AC_CONFIG_FILES([lib/Makefile])
213 AC_CONFIG_FILES([srclib/Makefile])
214 AC_CONFIG_FILES([src/Makefile])
215 AC_CONFIG_FILES([po/Makefile.in])
216 AC_CONFIG_FILES([man/Makefile])
217 if test -d "${srcdir}/tests"; then
218   AC_CONFIG_FILES([tests/Makefile])
220 AC_CONFIG_FILES([include/iconv.h:include/iconv.h.build.in])
221 AC_CONFIG_FILES([include/iconv.h.inst:include/iconv.h.in])
222 AC_OUTPUT