expand: Fix double-decrement in argstr
[dash.git] / configure.ac
blob036730d26950f3280313a9a7f1188ac4520b81fe
1 AC_INIT([dash],[0.5.10.2])
2 AM_INIT_AUTOMAKE([foreign subdir-objects])
3 AC_CONFIG_SRCDIR([src/main.c])
5 AC_CONFIG_HEADERS(config.h)
7 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
9 dnl Checks for programs.
10 AC_PROG_CC
11 AC_USE_SYSTEM_EXTENSIONS
12 AC_PROG_YACC
14 AC_MSG_CHECKING([for build system compiler])
15 if test "$cross_compiling" = yes; then
16         CC_FOR_BUILD=${CC_FOR_BUILD-cc}
17 else
18         CC_FOR_BUILD=${CC}
20 AC_MSG_RESULT(${CC_FOR_BUILD})
21 AC_SUBST(CC_FOR_BUILD)
23 AC_MSG_CHECKING([for __attribute__((__alias__()))])
24 dash_cv_have_attribute_alias=no
25 AC_LINK_IFELSE([AC_LANG_PROGRAM([void t() {}
26                                  void a() __attribute__((__alias__("t")));],
27                                 [a();])],
28                [dash_cv_have_attribute_alias=yes])
29 AC_MSG_RESULT($dash_cv_have_attribute_alias)
30 if test "x$dash_cv_have_attribute_alias" = xyes; then
31   AC_DEFINE([HAVE_ALIAS_ATTRIBUTE], 1,
32             [Define if __attribute__((__alias__())) is supported])
35 AC_ARG_ENABLE(static, AS_HELP_STRING(--enable-static, \
36                                      [Build statical linked program]))
37 if test "$enable_static" = "yes"; then
38         export LDFLAGS="-static -Wl,--fatal-warnings"
41 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \
42                                       [Use fnmatch(3) from libc]))
43 AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
45 dnl Checks for libraries.
47 dnl Checks for header files.
48 AC_CHECK_HEADERS(alloca.h paths.h)
50 dnl Check for declarations
51 AC_CHECK_DECL([_PATH_BSHELL],,AC_DEFINE_UNQUOTED([_PATH_BSHELL], "/bin/sh", [Define to system shell path]),[
52 #ifdef HAVE_PATHS_H
53 #include <paths.h>
54 #endif
56 AC_CHECK_DECL([_PATH_DEVNULL],,AC_DEFINE_UNQUOTED([_PATH_DEVNULL], "/dev/null", [Define to devnull device node path]),[
57 #ifdef HAVE_PATHS_H
58 #include <paths.h>
59 #endif
61 AC_CHECK_DECL([_PATH_TTY],,AC_DEFINE_UNQUOTED([_PATH_TTY], "/dev/tty", [Define to tty device node path]),[
62 #ifdef HAVE_PATHS_H
63 #include <paths.h>
64 #endif
67 dnl Some systems lack isblank
68 AC_CHECK_DECLS([isblank],,,[#include <ctype.h>])
70 dnl Check for sizes of types
71 AC_CHECK_SIZEOF([intmax_t])
72 AC_CHECK_SIZEOF([long long int])
74 dnl Select a fallback format string for intmax_t in case we don't find PRIdMAX
75 if test "x$ac_cv_sizeof_intmax_t" = "x$ac_cv_sizeof_long_long_int"; then
76   intmax_fstr="lld"
77 else
78   intmax_fstr="jd"
81 dnl Check for PRIdMAX and define it to a fallback if not found
82 AC_CHECK_DECL([PRIdMAX],,
83         [AC_DEFINE_UNQUOTED([PRIdMAX], "$intmax_fstr",
84                                        [Define to printf format string for intmax_t])],
85         [
86 #include <inttypes.h>
89 dnl Checks for library functions.
90 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \
91                mempcpy \
92                sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
93                strtoumax sysconf)
95 dnl Check whether it's worth working around FreeBSD PR kern/125009.
96 dnl The traditional behavior of access/faccessat is crazy, but
97 dnl POSIX.1-2008 explicitly allows those functions to misbehave.
98 dnl
99 dnl Unaffected kernels:
101 dnl - all versions of Linux
102 dnl - NetBSD sys/kern/vfs_subr.c 1.64, 1997-04-23
103 dnl - FreeBSD 9 (r212002), 2010-09-10
104 dnl - OpenBSD sys/kern/vfs_subr.c 1.166, 2008-06-09
106 dnl Also worked around in Debian's libc0.1 2.13-19 when using
107 dnl kFreeBSD 8.
109 AC_ARG_ENABLE(test-workaround, AS_HELP_STRING(--enable-test-workaround, \
110         [Guard against faccessat(2) that tells root all files are executable]),,
111         [enable_test_workaround=auto])
113 if test "enable_test_workaround" = "auto" &&
114    test "$ac_cv_func_faccessat" = yes; then
115         case `uname -s 2>/dev/null` in
116         GNU/kFreeBSD | \
117         FreeBSD)
118                 enable_test_workaround=yes
119         esac
121 if test "$enable_test_workaround" = "yes"; then
122         AC_DEFINE([HAVE_TRADITIONAL_FACCESSAT], [1],
123                 [Define if your faccessat tells root all files are executable])
126 if test "$enable_fnmatch" = yes; then
127         use_fnmatch=
128         AC_CHECK_FUNCS(fnmatch, use_fnmatch=yes)
131 if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
132         AC_CHECK_FUNCS(glob)
135 dnl Check for klibc signal.
136 AC_CHECK_FUNC(signal)
137 if test "$ac_cv_func_signal" != yes; then
138         AC_CHECK_FUNC(bsd_signal,
139                       [AC_DEFINE(signal, bsd_signal,
140                                  [klibc has bsd_signal instead of signal])])
143 dnl Check for stat64 (dietlibc/klibc).
144 AC_CHECK_FUNC(stat64,, [
145         AC_DEFINE(fstat64, fstat, [64-bit operations are the same as 32-bit])
146         AC_DEFINE(lstat64, lstat, [64-bit operations are the same as 32-bit])
147         AC_DEFINE(stat64, stat, [64-bit operations are the same as 32-bit])
150 AC_CHECK_FUNC(open64,, [
151         AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
154 dnl Check if struct stat has st_mtim.
155 AC_MSG_CHECKING(for stat::st_mtim)
156 AC_COMPILE_IFELSE(
157 [AC_LANG_PROGRAM([#include <time.h>
158 #include <sys/time.h>
159 #include <sys/stat.h>],
160 [struct stat foo; return sizeof(foo.st_mtim.tv_sec)])],
161 have_st_mtim=yes, have_st_mtim=no)
162 AC_MSG_RESULT($have_st_mtim)
163 if test "$have_st_mtim" = "yes"; then
164         AC_DEFINE([HAVE_ST_MTIM], [1],
165                 [Define if your `struct stat' has `st_mtim'])
168 AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
169 use_libedit=
170 if test "$with_libedit" = "yes"; then
171         AC_CHECK_LIB(edit, history_init, [
172                 AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
173                                 AC_MSG_ERROR(
174                                         [Can't find required header files.]))])
176 if test "$use_libedit" != "yes"; then
177         AC_DEFINE([SMALL], 1, [Define if you build with -DSMALL])
178 else
179         export LIBS="$LIBS -ledit"
181 AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \
182                                      [Disable LINENO support]))
183 if test "$enable_lineno" != "no"; then
184         AC_DEFINE([WITH_LINENO], 1, [Define if you build with -DWITH_LINENO])
186 AC_CONFIG_FILES([Makefile src/Makefile])
187 AC_OUTPUT