]> granicus.if.org Git - re2c/blob - configure.ac
Added include/ subdirectory to distribution and updated bootsrap files.
[re2c] / configure.ac
1 AC_INIT([re2c],[1.1.1],[re2c-general@lists.sourceforge.net])
2 AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz no-dist-gzip])
3 AM_SILENT_RULES([yes])
4
5
6 AC_CONFIG_SRCDIR([src/main.cc])
7 AC_CONFIG_HEADERS([config.h])
8
9
10 AC_SUBST(PACKAGE_DATE, `date +'%d %b %Y'`)
11 AC_SUBST(PACKAGE_VERSION)
12 AC_SUBST(PACKAGE_NAME)
13 AC_SUBST(PACKAGE_TARNAME)
14 AC_SUBST(PACKAGE_RELEASE, ${PACKAGE_RELEASE:-1})
15
16
17 # without this, --std=c++98 disables POSIX functions on Cygwin
18 AC_USE_SYSTEM_EXTENSIONS
19
20
21 # --enable-debug
22 AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],
23     [enable checks and assertions])])
24 AM_CONDITIONAL([DEBUG], [test "x$enable_debug" = "xyes"])
25
26
27 # --enable-docs
28 AC_ARG_ENABLE([docs], [AS_HELP_STRING([--enable-docs], [regenerate manpage])])
29 AM_CONDITIONAL([REBUILD_DOCS], [test "x$enable_docs" = "xyes"])
30 AM_COND_IF([REBUILD_DOCS], [
31     AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], no)
32     AS_IF([test "x$RST2MAN" = "xno"], [
33         AC_MSG_ERROR([need rst2man or rst2man.py for --enable-docs])
34     ])
35 ])
36
37
38 # --enable-libs
39 AC_ARG_ENABLE([libs], [AS_HELP_STRING([--enable-libs], [build libraries])])
40 AM_CONDITIONAL([WITH_LIBS], [test "x$enable_libs" = "xyes"])
41 AM_COND_IF([WITH_LIBS], [
42     AC_SUBST(LDFLAGS_RE2, [])
43     AC_LANG_PUSH([C++])
44     AC_CHECK_HEADERS([re2/re2.h], [AS_VAR_SET([LDFLAGS_RE2], ["-lre2"])], [], [[]])
45     AC_LANG_POP([C++])
46 ])
47
48
49 # checks for programs
50 AC_PATH_PROG(BISON, bison, no)
51 AC_PROG_CC # used in skeleton tests
52 AC_PROG_CXX
53 AC_PROG_INSTALL
54
55
56 # checks for C++ compiler flags
57 AC_SUBST(CXXFLAGSDEFAULT, [])
58 # TRY_CXXFLAG (flag [implied-flags])
59 # Iff C++ compiler recognizes 'flag', append 'flag' and 'implied-flags' to CXXFLAGSDEFAULT
60 # (Second param 'implied-flags' is needed for warning suppressions '-Wno-<warning>':
61 # GCC warns about unrecognized suppressions options only in presence of other warnings,
62 # which makes it hard to test for them with autoconf.)
63 AC_DEFUN([TRY_CXXFLAG], [
64     AC_MSG_CHECKING([C++ compiler flag $1])
65     AS_VAR_SET([CXXFLAGS_BACKUP], ["$CXXFLAGS"])
66     AS_VAR_SET([CXXFLAGS], ["$CXXFLAGS $1"])
67     AC_LANG_PUSH([C++])
68     AC_COMPILE_IFELSE(
69         [AC_LANG_PROGRAM()],
70         [
71             AS_VAR_SET([TRY_CXXFLAG_RESULT], [yes])
72             AS_VAR_SET([CXXFLAGSDEFAULT], ["$CXXFLAGSDEFAULT $1 $2"])
73         ],
74         [AS_VAR_SET([TRY_CXXFLAG_RESULT], [no])]
75     )
76     AC_LANG_POP([C++])
77     AS_VAR_SET([CXXFLAGS], ["$CXXFLAGS_BACKUP"])
78     AC_MSG_RESULT([$TRY_CXXFLAG_RESULT])
79 ])
80 TRY_CXXFLAG([-std=c++98])
81 TRY_CXXFLAG([-W])
82 TRY_CXXFLAG([-Wall])
83 TRY_CXXFLAG([-Wextra])
84 TRY_CXXFLAG([-Weffc++])
85 TRY_CXXFLAG([-pedantic])
86 TRY_CXXFLAG([-Wformat=2])
87 TRY_CXXFLAG([-Wredundant-decls])
88 TRY_CXXFLAG([-Wsuggest-attribute=format])
89 TRY_CXXFLAG([-Wconversion])
90 TRY_CXXFLAG([-Wsign-conversion])
91 TRY_CXXFLAG([-Werror=return-type])
92 TRY_CXXFLAG([-O2])
93 TRY_CXXFLAG([-Weverything], m4_join([ ],
94     [-Wno-unknown-warning-option], dnl CLANG eats some GCC options only to warn they are unknown
95     [-Wno-reserved-id-macro], dnl to allow header guards of the form '_RE2C_PATH_TO_HEADER_BASENAME_'
96     [-Wno-padded],
97     [-Wno-old-style-cast], dnl RE2C-generated lexer has lots of C-syle casts because of 're2c:yych:conversion = 1;'
98     [-Wno-nested-anon-types],
99     [-Wno-global-constructors] dnl initialization of global constants with std::numeric_limits<...> (mostly for size_t)
100     [-Wno-shadow-field-in-constructor] dnl using same names in ctor seems more like a feature
101     [-Wno-undefined-func-template])) dnl explicit specialization to reduce build dependencies
102
103
104 # needed by src/c99_stdint.h
105 # avoid AC_INCLUDES_DEFAULT
106 AC_CHECK_HEADERS([stdint.h],    [], [], [[]])
107 # needed for POSIX file API
108 AC_CHECK_HEADERS([sys/types.h], [], [], [[]])
109 AC_CHECK_HEADERS([sys/stat.h],  [], [], [[]])
110 AC_CHECK_HEADERS([fcntl.h],     [], [], [[]])
111 AC_CHECK_HEADERS([unistd.h],    [], [], [[]])
112 AC_CHECK_HEADERS([io.h],        [], [], [[]]) # windows POSIX-like API
113 # list of possible types to use in typedefs
114 AC_CHECK_SIZEOF([char],      [], [[]])
115 AC_CHECK_SIZEOF([short],     [], [[]])
116 AC_CHECK_SIZEOF([int],       [], [[]])
117 AC_CHECK_SIZEOF([long],      [], [[]])
118 AC_CHECK_SIZEOF([long long], [], [[]])
119 AC_CHECK_SIZEOF([__int64],   [], [[]])
120 # size of pointers
121 AC_CHECK_SIZEOF([void *],    [], [[]])
122 # 64-bit integer constant suffix
123 AC_CHECK_SIZEOF([0l],        [], [[]])
124 AC_CHECK_SIZEOF([0ll],       [], [[]])
125 AC_CHECK_SIZEOF([0i8],       [], [[]])
126
127
128 AC_CONFIG_FILES([\
129     Makefile \
130     doc/manpage.rst \
131     doc/help.rst \
132 ])
133 AC_CONFIG_FILES([run_tests.sh], [chmod +x run_tests.sh])
134
135
136 LT_INIT([dlopen win32-dll])
137 AC_CONFIG_MACRO_DIRS([m4])
138
139
140 AC_OUTPUT