1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_INIT(cpplib, [ ], gcc-bugs@gcc.gnu.org, cpplib)
5AC_CONFIG_SRCDIR(ucnid.h)
6AC_CONFIG_MACRO_DIR(../config)
7AC_CANONICAL_SYSTEM
8
9# Checks for programs.
10AC_PROG_MAKE_SET
11AC_PROG_INSTALL
12AC_PROG_CC
13AC_PROG_CXX
14AC_PROG_RANLIB
15
16AC_USE_SYSTEM_EXTENSIONS
17AC_SYS_LARGEFILE
18
19MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
20AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
21AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
22AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
23
24# Figure out what compiler warnings we can enable.
25# See config/warnings.m4 for details.
26
27ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \
28			  -Wmissing-format-attribute], [warn])
29ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
30			  -Wold-style-definition -Wc++-compat], [c_warn])
31ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
32
33# Disable exceptions and RTTI if building with g++
34ACX_PROG_CC_WARNING_OPTS(
35       m4_quote(m4_do([-fno-exceptions -fno-rtti])), [noexception_flags])
36
37# Only enable with --enable-werror-always until existing warnings are
38# corrected.
39ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
40
41# Dependency checking.
42ZW_CREATE_DEPDIR
43AC_LANG_PUSH([C++])
44AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [],
45		  [AC_MSG_ERROR([C++ compiler missing or inoperational])])
46AC_LANG_POP([C++])
47ZW_PROG_COMPILER_DEPENDENCIES([CXX])
48
49# Checks for header files.
50AC_HEADER_TIME
51ACX_HEADER_STRING
52
53AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
54	stdlib.h strings.h string.h sys/file.h unistd.h)
55
56# Checks for typedefs, structures, and compiler characteristics.
57AC_C_BIGENDIAN
58AC_C_CONST
59AC_C_INLINE
60AC_FUNC_OBSTACK
61AC_TYPE_OFF_T
62AC_TYPE_SIZE_T
63AC_TYPE_SSIZE_T
64AC_TYPE_UINTPTR_T
65AC_CHECK_TYPE(ptrdiff_t, int)
66AC_TYPE_UINT64_T
67if test x"$ac_cv_c_uint64_t" = x"no"; then
68  AC_MSG_ERROR([uint64_t not found])
69fi
70AC_STRUCT_TM
71AC_CHECK_SIZEOF(int)
72AC_CHECK_SIZEOF(long)
73define(libcpp_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl
74  ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl
75  fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl
76  fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
77  putchar_unlocked putc_unlocked)
78AC_CHECK_FUNCS(libcpp_UNLOCKED_FUNCS)
79AC_CHECK_DECLS([abort, asprintf, basename(char *), errno, getopt, vasprintf])
80AC_CHECK_DECLS(m4_split(m4_normalize(libcpp_UNLOCKED_FUNCS)))
81
82# Checks for library functions.
83AC_FUNC_ALLOCA
84AC_HEADER_STDC
85AM_LANGINFO_CODESET
86ZW_GNU_GETTEXT_SISTER_DIR
87
88AC_CACHE_CHECK(for uchar, gcc_cv_type_uchar,
89[AC_TRY_COMPILE([
90#include <sys/types.h>
91],
92[if ((uchar *)0) return 0;
93 if (sizeof(uchar)) return 0;],
94ac_cv_type_uchar=yes, ac_cv_type_uchar=no)])
95if test $ac_cv_type_uchar = yes; then
96  AC_DEFINE(HAVE_UCHAR, 1,
97  [Define if <sys/types.h> defines \`uchar'.])
98fi
99
100# g++ on Solaris 10+ defines _XOPEN_SOURCE=600, which exposes a different
101# iconv() prototype.
102AC_LANG_PUSH([C++])
103AM_ICONV
104AC_LANG_POP([C++])
105
106# More defines and substitutions.
107PACKAGE="$PACKAGE_TARNAME"
108AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Define to the name of this package.])
109AC_SUBST(PACKAGE)
110
111if test "x$enable_nls" != xno; then
112  USED_CATALOGS='$(CATALOGS)'
113else
114  USED_CATALOGS=
115fi
116AC_SUBST(USED_CATALOGS)
117
118AC_ARG_ENABLE(maintainer-mode,
119[  --enable-maintainer-mode enable rules only needed by maintainers],,
120enable_maintainer_mode=no)
121
122if test "x$enable_maintainer_mode" = xno; then
123  MAINT='#'
124else
125  MAINT=
126fi
127AC_SUBST(MAINT)
128
129# Enable expensive internal checks
130is_release=
131if test -f $srcdir/../gcc/DEV-PHASE \
132   && test x"`cat $srcdir/../gcc/DEV-PHASE`" != xexperimental; then
133  is_release=yes
134fi
135
136AC_ARG_ENABLE(checking,
137[AS_HELP_STRING([[--enable-checking[=LIST]]],
138		[enable expensive run-time checks.  With LIST,
139		 enable only specific categories of checks.
140		 Categories are: yes,no,all,none,release.
141		 Flags are: misc,valgrind or other strings])],
142[ac_checking_flags="${enableval}"],[
143# Determine the default checks.
144if test x$is_release = x ; then
145  ac_checking_flags=yes
146else
147  ac_checking_flags=release
148fi])
149IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="$IFS,"
150for check in release $ac_checking_flags
151do
152	case $check in
153	# these set all the flags to specific states
154	yes|all) ac_checking=1 ; ac_assert_checking=1 ; ac_valgrind_checking= ;;
155	no|none) ac_checking= ; ac_assert_checking= ; ac_valgrind_checking= ;;
156	release) ac_checking= ; ac_assert_checking=1 ; ac_valgrind_checking= ;;
157	# these enable particular checks
158	assert) ac_assert_checking=1 ;;
159	misc) ac_checking=1 ;;
160	valgrind) ac_valgrind_checking=1 ;;
161	# accept
162	*) ;;
163	esac
164done
165IFS="$ac_save_IFS"
166
167if test x$ac_checking != x ; then
168  AC_DEFINE(CHECKING_P, 1,
169[Define to 1 if you want more run-time sanity checks.])
170else
171  AC_DEFINE(CHECKING_P, 0)
172fi
173
174if test x$ac_assert_checking != x ; then
175  AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
176[Define if you want assertions enabled.  This is a cheap check.])
177fi
178
179if test x$ac_valgrind_checking != x ; then
180  AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
181[Define if you want to workaround valgrind (a memory checker) warnings about
182 possible memory leaks because of libcpp use of interior pointers.])
183fi
184
185AC_ARG_ENABLE(canonical-system-headers,
186[  --enable-canonical-system-headers
187                          enable or disable system headers canonicalization],
188[],
189enable_canonical_system_headers=yes)
190if test $enable_canonical_system_headers != no; then
191  AC_DEFINE(ENABLE_CANONICAL_SYSTEM_HEADERS,
192            1, [Define to enable system headers canonicalization.])
193fi
194
195case $target in
196  i?86-* | x86_64-*)
197    AC_TRY_COMPILE([], [asm ("pcmpestri %0, %%xmm0, %%xmm1" : : "i"(0))],
198      [AC_DEFINE([HAVE_SSE4], [1],
199		 [Define to 1 if you can assemble SSE4 insns.])])
200esac
201
202# Enable --enable-host-shared.
203AC_ARG_ENABLE(host-shared,
204[AS_HELP_STRING([--enable-host-shared],
205		[build host code as shared libraries])],
206[PICFLAG=-fPIC], [PICFLAG=])
207AC_SUBST(PICFLAG)
208
209AC_ARG_ENABLE(valgrind-annotations,
210[AS_HELP_STRING([--enable-valgrind-annotations],
211		[enable valgrind runtime interaction])], [],
212[enable_valgrind_annotations=no])
213if test x$enable_valgrind_annotations != xno \
214    || test x$ac_valgrind_checking != x; then
215  if (test $have_valgrind_h = no \
216      && test $gcc_cv_header_memcheck_h = no \
217      && test $gcc_cv_header_valgrind_memcheck_h = no); then
218    AC_MSG_ERROR([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
219  fi
220  AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
221[Define to get calls to the valgrind runtime enabled.])
222fi
223
224# Output.
225
226AC_CONFIG_HEADERS(config.h:config.in, [echo timestamp > stamp-h1])
227AC_CONFIG_FILES(Makefile)
228AC_OUTPUT
229