]> granicus.if.org Git - flex/blob - configure.ac
build: AC_USE_SYSTEM_EXTENSIONS in configure.ac.
[flex] / configure.ac
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
27 AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex])
28 AC_PREREQ([2.60])
29 AC_CONFIG_SRCDIR([src/scan.l])
30 AC_CONFIG_AUX_DIR([build-aux])
31 AC_USE_SYSTEM_EXTENSIONS
32 LT_INIT
33 AM_INIT_AUTOMAKE([1.15 -Wno-portability foreign std-options dist-lzip parallel-tests subdir-objects])
34 AC_CONFIG_HEADER([src/config.h])
35 AC_CONFIG_LIBOBJ_DIR([lib])
36 AC_CONFIG_MACRO_DIR([m4])
37 SHARED_VERSION_INFO="2:0:0"
38 AC_SUBST(SHARED_VERSION_INFO)
39
40 # checks for programs
41
42 AM_GNU_GETTEXT([external])
43 AM_GNU_GETTEXT_VERSION([0.19.7])
44 AC_PROG_YACC
45 AS_IF([test "$YACC" != 'bison -y'], [
46         YACC="\${top_srcdir}/build-aux/missing bison -y"
47         AC_MSG_NOTICE(no bison program found: only required for maintainers)
48         ])
49 AM_CONDITIONAL([HAVE_BISON], [test "$YACC" = 'bison -y'])
50 AM_PROG_LEX
51 AC_PROG_CC
52 AX_PROG_CC_FOR_BUILD
53 AC_PROG_CXX
54 AM_PROG_CC_C_O
55 AC_PROG_LN_S
56 AC_PROG_AWK
57 AC_PROG_INSTALL
58
59 pkgconfigdir=${libdir}/pkgconfig
60 AC_SUBST(pkgconfigdir)
61
62 # allow passing a variable `WARNINGFLAGS',
63 #   either when invoking `configure', or when invoking `make'
64 # default to something useful if GCC was detected
65
66 AC_ARG_ENABLE([warnings],
67   [AS_HELP_STRING([--enable-warnings],
68                   [enable a bunch of compiler warning flags (defaults to GCC warning flags).])],
69   [AS_IF([test "x$GCC" = xyes],
70     [ : ${WARNINGFLAGS="-Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wconversion -Wno-unused-but-set-variable"} ])])
71
72 AC_SUBST([WARNINGFLAGS])
73
74 AC_ARG_ENABLE([libfl],
75   [AS_HELP_STRING([--disable-libfl],
76                   [do not build -lfl runtime support library])],
77   [], [enable_libfl=yes])
78 AM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes])
79
80 # --disable-bootstrap is intended only to workaround problems with bootstrap
81 # (e.g. when cross-compiling flex or when bootstrapping has bugs).
82 # Ideally we should be able to bootstrap even when cross-compiling.
83 AC_ARG_ENABLE([bootstrap],
84   [AS_HELP_STRING([--disable-bootstrap],
85                   [don't perform a bootstrap when building flex])],
86   [], [enable_bootstrap=yes])
87 AM_CONDITIONAL([ENABLE_BOOTSTRAP], [test "x$enable_bootstrap" = xyes])
88
89 AM_CONDITIONAL([CROSS], [test "x$cross_compiling" = xyes])
90
91 AC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man])
92   AS_IF([test "$HELP2MAN" = "\${top_srcdir}/build-aux/missing help2man"],
93     AC_MSG_WARN(help2man: program not found: building man page will not work)
94   )
95
96 AC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi])
97   AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"],
98     AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work)
99   )
100
101 # Check for a m4 that supports -P
102
103 AC_CACHE_CHECK([for m4 that supports -P], [ac_cv_path_M4],
104 [AC_PATH_PROGS_FEATURE_CHECK([M4], [gm4 gnum4 m4],
105               [[m4out=`echo 'm''4_divnum' | $ac_path_M4 -P`]
106                 [test "x$m4out" = x0 \
107                 && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
108               [AC_MSG_ERROR([could not find m4 that supports -P])])])
109 AC_SUBST([M4], [$ac_cv_path_M4])
110 AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the m4 executable name.])
111
112 AC_PATH_PROG([INDENT], indent, [\${top_srcdir}/build-aux/missing indent])
113   AC_MSG_CHECKING(if $INDENT is GNU indent)
114   AS_IF([$INDENT --version 2>/dev/null | head -n 1 | grep "GNU indent" >/dev/null],
115     [AC_MSG_RESULT(yes)],
116     [AC_MSG_RESULT(no)
117      AC_MSG_WARN($INDENT does not appear to be GNU indent; 'make indent' may not function properly)
118     ])
119
120 # checks for headers
121
122 AC_CHECK_HEADERS([regex.h strings.h sys/stat.h sys/wait.h unistd.h], [],
123   [AC_MSG_ERROR(required header not found on your system)])
124
125 AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h])
126
127 # checks for libraries
128
129 # The test test-pthread uses libpthread, so we check for it here, but
130 # all we need is the preprocessor symbol defined since we don't need
131 # LIBS to include libpthread for building flex.
132
133 LIBPTHREAD=''
134 AC_CHECK_LIB(pthread, pthread_mutex_lock,
135    [AC_CHECK_HEADERS([pthread.h], [LIBPTHREAD=-lpthread],
136       [AC_MSG_WARN([pthread tests will be skipped])])],
137    [AC_MSG_WARN([pthread tests will be skipped])])
138 AC_SUBST([LIBPTHREAD])
139
140 AC_CHECK_LIB(m, log10)
141
142 # Checks for typedefs, structures, and compiler characteristics.
143
144 AC_HEADER_STDBOOL
145 AC_C_CONST
146 AC_TYPE_SIZE_T
147
148 # Checks for library functions.
149
150 AC_FUNC_ALLOCA
151 AC_FUNC_FORK
152 dnl Autoconf bug: AC_FUNC_MALLOC and AC_FUNC_REALLOC might not warn of cross
153 dnl compilation. Workaround this.
154 AC_FUNC_MALLOC
155 AS_IF([test "$cross_compiling" = yes],
156    AC_MSG_WARN([result $ac_cv_func_malloc_0_nonnull guessed because of cross compilation]))
157 AC_FUNC_REALLOC
158 AS_IF([test "$cross_compiling" = yes],
159    AC_MSG_WARN([result $ac_cv_func_realloc_0_nonnull guessed because of cross compilation]))
160
161 AC_CHECK_FUNCS([dup2 dnl
162 memset dnl
163 regcomp dnl
164 strcasecmp dnl
165 strchr dnl
166 strdup dnl
167 strtol dnl
168 ], [], [AC_MSG_ERROR(required library function not found on your system)])
169
170 # Optional library functions
171 AC_CHECK_FUNCS([dnl
172 pow dnl           Used only by "examples/manual/expr"
173 setlocale dnl     Needed only if NLS is enabled
174 reallocarr dnl    NetBSD function. Use reallocarray if not available.
175 reallocarray dnl  OpenBSD function. We have replacement if not available.
176 ])
177
178 AC_CONFIG_FILES(
179 Makefile
180 doc/Makefile
181 examples/Makefile
182 examples/fastwc/Makefile
183 examples/manual/Makefile
184 po/Makefile.in
185 src/libfl.pc
186 src/Makefile
187 tools/Makefile
188 tests/Makefile
189 )
190
191 AC_OUTPUT