Release 0.5.9.
[dash.git] / configure.ac
blob4c2c179198a3cad026f37a15c40e73cd26473c80
1 AC_INIT(dash, 0.5.9)
2 AM_INIT_AUTOMAKE([foreign])
3 AC_CONFIG_SRCDIR([src/main.c])
5 AC_CONFIG_HEADERS(config.h)
7 dnl Checks for programs.
8 AC_PROG_CC
9 AC_GNU_SOURCE
10 AC_PROG_YACC
12 AC_MSG_CHECKING([for build system compiler])
13 if test "$cross_compiling" = yes; then
14         CC_FOR_BUILD=${CC_FOR_BUILD-cc}
15 else
16         CC_FOR_BUILD=${CC}
18 AC_MSG_RESULT(${CC_FOR_BUILD})
19 AC_SUBST(CC_FOR_BUILD)
21 AC_MSG_CHECKING([for __attribute__((__alias__()))])
22 dash_cv_have_attribute_alias=no
23 AC_LINK_IFELSE([AC_LANG_PROGRAM([void t() {}
24                                  void a() __attribute__((__alias__("t")));],
25                                 [a();])],
26                [dash_cv_have_attribute_alias=yes])
27 AC_MSG_RESULT($dash_cv_have_attribute_alias)
28 if test "x$dash_cv_have_attribute_alias" = xyes; then
29   AC_DEFINE([HAVE_ALIAS_ATTRIBUTE], 1,
30             [Define if __attribute__((__alias__())) is supported])
33 AC_ARG_ENABLE(static, AS_HELP_STRING(--enable-static, \
34                                      [Build statical linked program]))
35 if test "$enable_static" = "yes"; then
36         export LDFLAGS="-static -Wl,--fatal-warnings"
39 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \
40                                       [Use fnmatch(3) from libc]))
41 AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
43 dnl Checks for libraries.
45 dnl Checks for header files.
46 AC_CHECK_HEADERS(alloca.h paths.h)
48 dnl Check for declarations
49 AC_CHECK_DECL([_PATH_BSHELL],,AC_DEFINE_UNQUOTED([_PATH_BSHELL], "/bin/sh", [Define to system shell path]),[
50 #ifdef HAVE_PATHS_H
51 #include <paths.h>
52 #endif
54 AC_CHECK_DECL([_PATH_DEVNULL],,AC_DEFINE_UNQUOTED([_PATH_DEVNULL], "/dev/null", [Define to devnull device node path]),[
55 #ifdef HAVE_PATHS_H
56 #include <paths.h>
57 #endif
59 AC_CHECK_DECL([_PATH_TTY],,AC_DEFINE_UNQUOTED([_PATH_TTY], "/dev/tty", [Define to tty device node path]),[
60 #ifdef HAVE_PATHS_H
61 #include <paths.h>
62 #endif
65 dnl Some systems lack isblank
66 AC_CHECK_DECLS([isblank],,,[#include <ctype.h>])
68 dnl Check for sizes of types
69 AC_CHECK_SIZEOF([intmax_t])
70 AC_CHECK_SIZEOF([long long int])
72 dnl Select a fallback format string for intmax_t in case we don't find PRIdMAX
73 if test "x$ac_cv_sizeof_intmax_t" = "x$ac_cv_sizeof_long_long_int"; then
74   intmax_fstr="lld"
75 else
76   intmax_fstr="jd"
79 dnl Check for PRIdMAX and define it to a fallback if not found
80 AC_CHECK_DECL([PRIdMAX],,
81         [AC_DEFINE_UNQUOTED([PRIdMAX], "$intmax_fstr",
82                                        [Define to printf format string for intmax_t])],
83         [
84 #include <inttypes.h>
87 dnl Checks for library functions.
88 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \
89                mempcpy \
90                sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
91                strtoumax sysconf)
93 dnl Check whether it's worth working around FreeBSD PR kern/125009.
94 dnl The traditional behavior of access/faccessat is crazy, but
95 dnl POSIX.1-2008 explicitly allows those functions to misbehave.
96 dnl
97 dnl Unaffected kernels:
98 dnl
99 dnl - all versions of Linux
100 dnl - NetBSD sys/kern/vfs_subr.c 1.64, 1997-04-23
101 dnl - FreeBSD 9 (r212002), 2010-09-10
102 dnl - OpenBSD sys/kern/vfs_subr.c 1.166, 2008-06-09
104 dnl Also worked around in Debian's libc0.1 2.13-19 when using
105 dnl kFreeBSD 8.
107 AC_ARG_ENABLE(test-workaround, AS_HELP_STRING(--enable-test-workaround, \
108         [Guard against faccessat(2) that tells root all files are executable]),,
109         [enable_test_workaround=auto])
111 if test "enable_test_workaround" = "auto" &&
112    test "$ac_cv_func_faccessat" = yes; then
113         case `uname -s 2>/dev/null` in
114         GNU/kFreeBSD | \
115         FreeBSD)
116                 enable_test_workaround=yes
117         esac
119 if test "$enable_test_workaround" = "yes"; then
120         AC_DEFINE([HAVE_TRADITIONAL_FACCESSAT], [1],
121                 [Define if your faccessat tells root all files are executable])
124 if test "$enable_fnmatch" = yes; then
125         use_fnmatch=
126         AC_CHECK_FUNCS(fnmatch, use_fnmatch=yes)
129 if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
130         AC_CHECK_FUNCS(glob)
133 dnl Check for klibc signal.
134 AC_CHECK_FUNC(signal)
135 if test "$ac_cv_func_signal" != yes; then
136         AC_CHECK_FUNC(bsd_signal,
137                       [AC_DEFINE(signal, bsd_signal,
138                                  [klibc has bsd_signal instead of signal])])
141 dnl Check for stat64 (dietlibc/klibc).
142 AC_CHECK_FUNC(stat64,, [
143         AC_DEFINE(fstat64, fstat, [64-bit operations are the same as 32-bit])
144         AC_DEFINE(lstat64, lstat, [64-bit operations are the same as 32-bit])
145         AC_DEFINE(stat64, stat, [64-bit operations are the same as 32-bit])
148 AC_CHECK_FUNC(open64,, [
149         AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
152 AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
153 use_libedit=
154 if test "$with_libedit" = "yes"; then
155         AC_CHECK_LIB(edit, history_init, [
156                 AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
157                                 AC_MSG_ERROR(
158                                         [Can't find required header files.]))])
160 if test "$use_libedit" != "yes"; then
161         AC_DEFINE([SMALL], 1, [Define if you build with -DSMALL])
162 else
163         export LIBS="$LIBS -ledit"
165 AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \
166                                      [Disable LINENO support]))
167 if test "$enable_lineno" != "no"; then
168         AC_DEFINE([WITH_LINENO], 1, [Define if you build with -DWITH_LINENO])
170 AC_CONFIG_FILES([Makefile src/Makefile])
171 AC_OUTPUT