1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4# This file is part of flex.
5
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9
10# 1. Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
15
16# Neither the name of the University nor the names of its contributors
17# may be used to endorse or promote products derived from this software
18# without specific prior written permission.
19
20# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
21# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
22# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23# PURPOSE.
24
25# autoconf requirements and initialization
26
27AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex])
28AC_CONFIG_SRCDIR([src/scan.l])
29AC_CONFIG_AUX_DIR([build-aux])
30LT_INIT
31AM_INIT_AUTOMAKE([1.11.3 -Wno-portability foreign check-news std-options dist-lzip parallel-tests subdir-objects])
32AC_CONFIG_HEADER([src/config.h])
33AC_CONFIG_LIBOBJ_DIR([lib])
34AC_CONFIG_MACRO_DIR([m4])
35SHARED_VERSION_INFO="2:0:0"
36AC_SUBST(SHARED_VERSION_INFO)
37
38# checks for programs
39
40AM_GNU_GETTEXT([external])
41AM_GNU_GETTEXT_VERSION([0.18])
42AC_PROG_YACC
43AS_IF([test "$YACC" != 'bison -y'], [
44	YACC="\${top_srcdir}/build-aux/missing bison -y"
45	AC_MSG_NOTICE(no bison program found: only required for maintainers)
46	])
47AM_CONDITIONAL([HAVE_BISON], [test "$YACC" = 'bison -y'])
48AM_PROG_LEX
49AC_PROG_CC
50AX_PROG_CC_FOR_BUILD
51AC_PROG_CXX
52AM_PROG_CC_C_O
53AC_PROG_LN_S
54AC_PROG_AWK
55AC_PROG_INSTALL
56
57# allow passing a variable `WARNINGFLAGS',
58#   either when invoking `configure', or when invoking `make'
59# default to something useful if GCC was detected
60
61AC_ARG_ENABLE([warnings],
62  [AS_HELP_STRING([--enable-warnings],
63                  [enable a bunch of compiler warning flags (defaults to GCC warning flags).])],
64  [AS_IF([test "x$GCC" = xyes],
65    [ : ${WARNINGFLAGS="-Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wconversion -Wno-unused-but-set-variable"} ])])
66
67AC_SUBST([WARNINGFLAGS])
68
69AC_ARG_ENABLE([libfl],
70  [AS_HELP_STRING([--disable-libfl],
71                  [do not build -lfl runtime support library])],
72  [], [enable_libfl=yes])
73AM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes])
74
75# --disable-bootstrap is intended only to workaround problems with bootstrap
76# (e.g. when cross-compiling flex or when bootstrapping has bugs).
77# Ideally we should be able to bootstrap even when cross-compiling.
78AC_ARG_ENABLE([bootstrap],
79  [AS_HELP_STRING([--disable-bootstrap],
80                  [don't perform a bootstrap when building flex])],
81  [], [enable_bootstrap=yes])
82AM_CONDITIONAL([ENABLE_BOOTSTRAP], [test "x$enable_bootstrap" = xyes])
83
84AM_CONDITIONAL([CROSS], [test "x$cross_compiling" = xyes])
85
86AC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man])
87  AS_IF([test "$HELP2MAN" = "\${top_srcdir}/build-aux/missing help2man"],
88    AC_MSG_WARN(help2man: program not found: building man page will not work)
89  )
90
91AC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi])
92  AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"],
93    AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work)
94  )
95
96# Check for a m4 that supports -P
97
98AC_CACHE_CHECK([for m4 that supports -P], [ac_cv_path_M4],
99[AC_PATH_PROGS_FEATURE_CHECK([M4], [gm4 gnum4 m4],
100              [[m4out=`echo 'm''4_divnum' | $ac_path_M4 -P`]
101                [test "x$m4out" = x0 \
102                && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
103              [AC_MSG_ERROR([could not find m4 that supports -P])])])
104AC_SUBST([M4], [$ac_cv_path_M4])
105AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the m4 executable name.])
106
107AC_PATH_PROG([INDENT], indent, [\${top_srcdir}/build-aux/missing indent])
108  AC_MSG_CHECKING(if $INDENT is GNU indent)
109  AS_IF([$INDENT --version 2>/dev/null | head -n 1 | grep "GNU indent" >/dev/null],
110    [AC_MSG_RESULT(yes)],
111    [AC_MSG_RESULT(no)
112     AC_MSG_WARN($INDENT does not appear to be GNU indent; 'make indent' may not function properly)
113    ])
114
115# checks for headers
116
117AC_CHECK_HEADERS([regex.h strings.h sys/stat.h sys/wait.h unistd.h], [],
118  [AC_MSG_ERROR(required header not found on your system)])
119
120AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h])
121
122# checks for libraries
123
124# The test test-pthread uses libpthread, so we check for it here, but
125# all we need is the preprocessor symbol defined since we don't need
126# LIBS to include libpthread for building flex.
127
128LIBPTHREAD=''
129AC_CHECK_LIB(pthread, pthread_mutex_lock,
130   [AC_CHECK_HEADERS([pthread.h], [LIBPTHREAD=-lpthread],
131      [AC_MSG_WARN([pthread tests will be skipped])])],
132   [AC_MSG_WARN([pthread tests will be skipped])])
133AC_SUBST([LIBPTHREAD])
134
135AC_CHECK_LIB(m, log10)
136
137# Checks for typedefs, structures, and compiler characteristics.
138
139AC_HEADER_STDBOOL
140AC_C_CONST
141AC_TYPE_SIZE_T
142
143# Checks for library functions.
144
145AC_FUNC_ALLOCA
146AC_FUNC_FORK
147dnl Autoconf bug: AC_FUNC_MALLOC and AC_FUNC_REALLOC might not warn of cross
148dnl compilation. Workaround this.
149AC_FUNC_MALLOC
150AS_IF([test "$cross_compiling" = yes],
151   AC_MSG_WARN([result $ac_cv_func_malloc_0_nonnull guessed because of cross compilation]))
152AC_FUNC_REALLOC
153AS_IF([test "$cross_compiling" = yes],
154   AC_MSG_WARN([result $ac_cv_func_realloc_0_nonnull guessed because of cross compilation]))
155
156AC_CHECK_FUNCS([dup2 dnl
157memset dnl
158regcomp dnl
159strcasecmp dnl
160strchr dnl
161strdup dnl
162strtol dnl
163], [], [AC_MSG_ERROR(required library function not found on your system)])
164
165# Optional library functions
166AC_CHECK_FUNCS([dnl
167pow dnl           Used only by "examples/manual/expr"
168setlocale dnl     Needed only if NLS is enabled
169reallocarray dnl  OpenBSD function. We have replacement if not available.
170])
171
172AC_CONFIG_FILES(
173Makefile
174doc/Makefile
175examples/Makefile
176examples/fastwc/Makefile
177examples/manual/Makefile
178po/Makefile.in
179src/Makefile
180tools/Makefile
181tests/Makefile
182)
183
184AC_OUTPUT
185