19b41a091SWill Estes#                                               -*- Autoconf -*-
29b41a091SWill Estes# Process this file with autoconf to produce a configure script.
31d7763d7SWill Estes
49b41a091SWill Estes# This file is part of flex.
51d7763d7SWill Estes
69b41a091SWill Estes# Redistribution and use in source and binary forms, with or without
79b41a091SWill Estes# modification, are permitted provided that the following conditions
89b41a091SWill Estes# are met:
91d7763d7SWill Estes
109b41a091SWill Estes# 1. Redistributions of source code must retain the above copyright
119b41a091SWill Estes# notice, this list of conditions and the following disclaimer.
129b41a091SWill Estes# 2. Redistributions in binary form must reproduce the above copyright
139b41a091SWill Estes# notice, this list of conditions and the following disclaimer in the
149b41a091SWill Estes# documentation and/or other materials provided with the distribution.
151d7763d7SWill Estes
169b41a091SWill Estes# Neither the name of the University nor the names of its contributors
179b41a091SWill Estes# may be used to endorse or promote products derived from this software
189b41a091SWill Estes# without specific prior written permission.
191d7763d7SWill Estes
209b41a091SWill Estes# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
219b41a091SWill Estes# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
229b41a091SWill Estes# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
239b41a091SWill Estes# PURPOSE.
241d7763d7SWill Estes
259b41a091SWill Estes# autoconf requirements and initialization
26737e7e83SWill Estes
277e4d5387SWill EstesAC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex])
2824fd0551SExplorerAC_PREREQ([2.60])
29269620b9SWill EstesAC_CONFIG_SRCDIR([src/scan.l])
30d6dfc4caSWill EstesAC_CONFIG_AUX_DIR([build-aux])
3124fd0551SExplorerAC_USE_SYSTEM_EXTENSIONS
32b6fa146aSWill EstesLT_INIT
3319cffb0fSWill EstesAM_INIT_AUTOMAKE([1.15 -Wno-portability foreign std-options dist-lzip parallel-tests subdir-objects])
34269620b9SWill EstesAC_CONFIG_HEADER([src/config.h])
3583f0c4caSWill EstesAC_CONFIG_LIBOBJ_DIR([lib])
36269620b9SWill EstesAC_CONFIG_MACRO_DIR([m4])
37d6dfc4caSWill EstesSHARED_VERSION_INFO="2:0:0"
38d6dfc4caSWill EstesAC_SUBST(SHARED_VERSION_INFO)
39737e7e83SWill Estes
409b41a091SWill Estes# checks for programs
41737e7e83SWill Estes
428f45da06SWill EstesAM_GNU_GETTEXT([external])
4319cffb0fSWill EstesAM_GNU_GETTEXT_VERSION([0.19.7])
44ada836d6SWill EstesAC_PROG_YACC
45546851baSExplorerAS_IF([test "$YACC" != 'bison -y'], [
46546851baSExplorer	YACC="\${top_srcdir}/build-aux/missing bison -y"
47546851baSExplorer	AC_MSG_NOTICE(no bison program found: only required for maintainers)
48546851baSExplorer	])
49546851baSExplorerAM_CONDITIONAL([HAVE_BISON], [test "$YACC" = 'bison -y'])
50ada836d6SWill EstesAM_PROG_LEX
51a18c8b7bSWill EstesAC_PROG_CC
5289f10ee3SAlastair HughesAX_PROG_CC_FOR_BUILD
538be706bbSWill EstesAC_PROG_CXX
540063632bSWill EstesAM_PROG_CC_C_O
55e3a27d6aSWill EstesAC_PROG_LN_S
569b41a091SWill EstesAC_PROG_AWK
579b41a091SWill EstesAC_PROG_INSTALL
58e3a27d6aSWill Estes
59c1ed5df2STyler Slabinskipkgconfigdir=${libdir}/pkgconfig
60c1ed5df2STyler SlabinskiAC_SUBST(pkgconfigdir)
61c1ed5df2STyler Slabinski
62f1ce4768SRobert Larice# allow passing a variable `WARNINGFLAGS',
63f1ce4768SRobert Larice#   either when invoking `configure', or when invoking `make'
64f1ce4768SRobert Larice# default to something useful if GCC was detected
65f1ce4768SRobert Larice
66f1ce4768SRobert LariceAC_ARG_ENABLE([warnings],
67f1ce4768SRobert Larice  [AS_HELP_STRING([--enable-warnings],
68f1ce4768SRobert Larice                  [enable a bunch of compiler warning flags (defaults to GCC warning flags).])],
690af671a2SThomas Klausner  [AS_IF([test "x$GCC" = xyes],
70f1ce4768SRobert Larice    [ : ${WARNINGFLAGS="-Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wconversion -Wno-unused-but-set-variable"} ])])
71f1ce4768SRobert Larice
72f1ce4768SRobert LariceAC_SUBST([WARNINGFLAGS])
73f1ce4768SRobert Larice
745d71e9ffSExplorerAC_ARG_ENABLE([libfl],
755d71e9ffSExplorer  [AS_HELP_STRING([--disable-libfl],
765d71e9ffSExplorer                  [do not build -lfl runtime support library])],
775d71e9ffSExplorer  [], [enable_libfl=yes])
78935478c3SExplorerAM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes])
795d71e9ffSExplorer
80adddfba7SExplorer# --disable-bootstrap is intended only to workaround problems with bootstrap
81adddfba7SExplorer# (e.g. when cross-compiling flex or when bootstrapping has bugs).
82adddfba7SExplorer# Ideally we should be able to bootstrap even when cross-compiling.
83adddfba7SExplorerAC_ARG_ENABLE([bootstrap],
84adddfba7SExplorer  [AS_HELP_STRING([--disable-bootstrap],
85adddfba7SExplorer                  [don't perform a bootstrap when building flex])],
86adddfba7SExplorer  [], [enable_bootstrap=yes])
87adddfba7SExplorerAM_CONDITIONAL([ENABLE_BOOTSTRAP], [test "x$enable_bootstrap" = xyes])
88adddfba7SExplorer
8989f10ee3SAlastair HughesAM_CONDITIONAL([CROSS], [test "x$cross_compiling" = xyes])
9089f10ee3SAlastair Hughes
910e2b8c0fSWill EstesAC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man])
9275f4305eSAlastair Hughes  AS_IF([test "$HELP2MAN" = "\${top_srcdir}/build-aux/missing help2man"],
9375f4305eSAlastair Hughes    AC_MSG_WARN(help2man: program not found: building man page will not work)
940e2b8c0fSWill Estes  )
959e24fe5eSMightyjo
960e2b8c0fSWill EstesAC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi])
9775f4305eSAlastair Hughes  AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"],
980e2b8c0fSWill Estes    AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work)
990e2b8c0fSWill Estes  )
10055c14ab0SJohn Millaway
1015d81852cSWill Estes# Check for a m4 that supports -P
1025d81852cSWill Estes
1035d81852cSWill EstesAC_CACHE_CHECK([for m4 that supports -P], [ac_cv_path_M4],
1045d81852cSWill Estes[AC_PATH_PROGS_FEATURE_CHECK([M4], [gm4 gnum4 m4],
1055d81852cSWill Estes              [[m4out=`echo 'm''4_divnum' | $ac_path_M4 -P`]
1065d81852cSWill Estes                [test "x$m4out" = x0 \
1075d81852cSWill Estes                && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
1085d81852cSWill Estes              [AC_MSG_ERROR([could not find m4 that supports -P])])])
1095d81852cSWill EstesAC_SUBST([M4], [$ac_cv_path_M4])
1105d81852cSWill EstesAC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the m4 executable name.])
11155c14ab0SJohn Millaway
1128db5267aSExplorerAC_PATH_PROG([INDENT], indent, [\${top_srcdir}/build-aux/missing indent])
1138db5267aSExplorer  AC_MSG_CHECKING(if $INDENT is GNU indent)
1148db5267aSExplorer  AS_IF([$INDENT --version 2>/dev/null | head -n 1 | grep "GNU indent" >/dev/null],
1158db5267aSExplorer    [AC_MSG_RESULT(yes)],
1168db5267aSExplorer    [AC_MSG_RESULT(no)
1178db5267aSExplorer     AC_MSG_WARN($INDENT does not appear to be GNU indent; 'make indent' may not function properly)
1188db5267aSExplorer    ])
11995932f8eSVern Paxson
1200063632bSWill Estes# checks for headers
121737e7e83SWill Estes
122dada40b5SExplorerAC_CHECK_HEADERS([regex.h strings.h sys/wait.h unistd.h], [],
123dbb4e94dSExplorer  [AC_MSG_ERROR(required header not found on your system)])
124dbb4e94dSExplorer
125dbb4e94dSExplorerAC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h])
1260063632bSWill Estes
1270063632bSWill Estes# checks for libraries
128737e7e83SWill Estes
1292ca08588SWill Estes# The test test-pthread uses libpthread, so we check for it here, but
1302ca08588SWill Estes# all we need is the preprocessor symbol defined since we don't need
1312ca08588SWill Estes# LIBS to include libpthread for building flex.
1322ca08588SWill Estes
133122e5896SExplorerLIBPTHREAD=''
1342ca08588SWill EstesAC_CHECK_LIB(pthread, pthread_mutex_lock,
135122e5896SExplorer   [AC_CHECK_HEADERS([pthread.h], [LIBPTHREAD=-lpthread],
136122e5896SExplorer      [AC_MSG_WARN([pthread tests will be skipped])])],
137122e5896SExplorer   [AC_MSG_WARN([pthread tests will be skipped])])
138122e5896SExplorerAC_SUBST([LIBPTHREAD])
1392ca08588SWill Estes
1400063632bSWill EstesAC_CHECK_LIB(m, log10)
1410063632bSWill Estes
1429b41a091SWill Estes# Checks for typedefs, structures, and compiler characteristics.
143737e7e83SWill Estes
1449b41a091SWill EstesAC_HEADER_STDBOOL
1459b41a091SWill EstesAC_C_CONST
146737e7e83SWill EstesAC_TYPE_SIZE_T
147737e7e83SWill Estes
1489b41a091SWill Estes# Checks for library functions.
149737e7e83SWill Estes
1500063632bSWill EstesAC_FUNC_ALLOCA
1519b41a091SWill EstesAC_FUNC_FORK
15244fa7589SExplorerdnl Autoconf bug: AC_FUNC_MALLOC and AC_FUNC_REALLOC might not warn of cross
15344fa7589SExplorerdnl compilation. Workaround this.
1549b41a091SWill EstesAC_FUNC_MALLOC
15544fa7589SExplorerAS_IF([test "$cross_compiling" = yes],
15644fa7589SExplorer   AC_MSG_WARN([result $ac_cv_func_malloc_0_nonnull guessed because of cross compilation]))
1579b41a091SWill EstesAC_FUNC_REALLOC
15844fa7589SExplorerAS_IF([test "$cross_compiling" = yes],
15944fa7589SExplorer   AC_MSG_WARN([result $ac_cv_func_realloc_0_nonnull guessed because of cross compilation]))
16077e54b25SMichael McConville
161c42de062SExplorerdnl Autoheader (<= 2.69) bug: "dnl" comments in a quoted argument of
162c42de062SExplorerdnl AC_CHECK_FUNCS will expand wierdly in config.h.in.
163c42de062SExplorerdnl (https://lists.gnu.org/archive/html/bug-autoconf/2018-02/msg00005.html)
164c42de062SExplorer
165c42de062SExplorerAC_CHECK_FUNCS([dup2 memset regcomp strcasecmp strchr strdup strtol], [],
166c42de062SExplorer  [AC_MSG_ERROR(required library function not found on your system)])
167c42de062SExplorer
168c42de062SExplorer# Optional library functions:
169c42de062SExplorer# pow - Used only by "examples/manual/expr".
170c42de062SExplorer# setlocale - Needed only if NLS is enabled.
171c42de062SExplorer# reallocarr - NetBSD function. Use reallocarray if not available.
172c42de062SExplorer# reallocarray - OpenBSD function. We have replacement if not available.
173c42de062SExplorerAC_CHECK_FUNCS([pow setlocale reallocarr reallocarray])
174737e7e83SWill Estes
1753cfbabfeSJohn MillawayAC_CONFIG_FILES(
176043a8337SWill EstesMakefile
177c863276fSWill Estesdoc/Makefile
178043a8337SWill Estesexamples/Makefile
179043a8337SWill Estesexamples/fastwc/Makefile
180043a8337SWill Estesexamples/manual/Makefile
181043a8337SWill Estespo/Makefile.in
1827e064071SExplorersrc/libfl.pc
183269620b9SWill Estessrc/Makefile
18445fe3acdSWill Estestools/Makefile
185a18c8b7bSWill Estestests/Makefile
186043a8337SWill Estes)
18719d2aafeSWill Estes
1888fe1b00aSWill EstesAC_OUTPUT
189