1 AC_INIT([dash],[0.5.12])
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.
11 AC_USE_SYSTEM_EXTENSIONS
13 AC_MSG_CHECKING([for build system compiler])
14 if test "$cross_compiling" = yes; then
15 CC_FOR_BUILD=${CC_FOR_BUILD-cc}
19 AC_MSG_RESULT(${CC_FOR_BUILD})
20 AC_SUBST(CC_FOR_BUILD)
22 AC_MSG_CHECKING([for __attribute__((__alias__()))])
23 dash_cv_have_attribute_alias=no
24 AC_LINK_IFELSE([AC_LANG_PROGRAM([void t() {}
25 void a() __attribute__((__alias__("t")));],
27 [dash_cv_have_attribute_alias=yes])
28 AC_MSG_RESULT($dash_cv_have_attribute_alias)
29 if test "x$dash_cv_have_attribute_alias" = xyes; then
30 AC_DEFINE([HAVE_ALIAS_ATTRIBUTE], 1,
31 [Define if __attribute__((__alias__())) is supported])
34 AC_ARG_ENABLE(static, AS_HELP_STRING(--enable-static, \
35 [Build statical linked program]))
36 if test "$enable_static" = "yes"; then
37 export LDFLAGS="-static"
40 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--disable-fnmatch, \
41 [Do not use fnmatch(3) from libc]))
42 AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
44 dnl Checks for libraries.
46 dnl Checks for header files.
47 AC_CHECK_HEADERS(alloca.h paths.h)
49 dnl Check for declarations
50 AC_CHECK_DECL([_PATH_BSHELL],,AC_DEFINE_UNQUOTED([_PATH_BSHELL], "/bin/sh", [Define to system shell path]),[
55 AC_CHECK_DECL([_PATH_DEVNULL],,AC_DEFINE_UNQUOTED([_PATH_DEVNULL], "/dev/null", [Define to devnull device node path]),[
60 AC_CHECK_DECL([_PATH_TTY],,AC_DEFINE_UNQUOTED([_PATH_TTY], "/dev/tty", [Define to tty device node path]),[
66 dnl Some systems lack isblank
67 AC_CHECK_DECLS([isblank],,,[#include <ctype.h>])
69 dnl Check for sizes of types
70 AC_CHECK_SIZEOF([intmax_t])
71 AC_CHECK_SIZEOF([long long int])
73 dnl Select a fallback format string for intmax_t in case we don't find PRIdMAX
74 if test "x$ac_cv_sizeof_intmax_t" = "x$ac_cv_sizeof_long_long_int"; then
80 dnl Check for PRIdMAX and define it to a fallback if not found
81 AC_CHECK_DECL([PRIdMAX],,
82 [AC_DEFINE_UNQUOTED([PRIdMAX], "$intmax_fstr",
83 [Define to printf format string for intmax_t])],
88 dnl Checks for library functions.
89 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \
91 sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
94 dnl Check whether it's worth working around FreeBSD PR kern/125009.
95 dnl The traditional behavior of access/faccessat is crazy, but
96 dnl POSIX.1-2008 explicitly allows those functions to misbehave.
98 dnl Unaffected kernels:
100 dnl - all versions of Linux
101 dnl - NetBSD sys/kern/vfs_subr.c 1.64, 1997-04-23
102 dnl - FreeBSD 9 (r212002), 2010-09-10
103 dnl - OpenBSD sys/kern/vfs_subr.c 1.166, 2008-06-09
105 dnl Also worked around in Debian's libc0.1 2.13-19 when using
108 AC_ARG_ENABLE(test-workaround, AS_HELP_STRING(--enable-test-workaround, \
109 [Guard against faccessat(2) that tells root all files are executable]),,
110 [enable_test_workaround=auto])
112 if test "enable_test_workaround" = "auto" &&
113 test "$ac_cv_func_faccessat" = yes; then
114 case `uname -s 2>/dev/null` in
117 enable_test_workaround=yes
120 if test "$enable_test_workaround" = "yes"; then
121 AC_DEFINE([HAVE_TRADITIONAL_FACCESSAT], [1],
122 [Define if your faccessat tells root all files are executable])
125 if test "$enable_fnmatch" != no; then
127 AC_CHECK_FUNCS(fnmatch, use_fnmatch=yes)
130 if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
134 dnl Check for klibc signal.
135 AC_CHECK_FUNC(signal)
136 if test "$ac_cv_func_signal" != yes; then
137 AC_CHECK_FUNC(bsd_signal,
138 [AC_DEFINE(signal, bsd_signal,
139 [klibc has bsd_signal instead of signal])])
142 dnl Check for stat64 (dietlibc/klibc).
143 AC_CHECK_DECL(stat64, AC_CHECK_FUNC(stat64))
144 if test "$ac_cv_func_stat64" != yes; then
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(glob64,, [
151 AC_DEFINE(glob64_t, glob_t, [64-bit operations are the same as 32-bit])
152 AC_DEFINE(glob64, glob, [64-bit operations are the same as 32-bit])
153 AC_DEFINE(globfree64, globfree,
154 [64-bit operations are the same as 32-bit])
157 dnl OS X apparently has stat64 but not open64.
158 AC_CHECK_FUNC(open64,, [
159 AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
160 AC_DEFINE(readdir64, readdir,
161 [64-bit operations are the same as 32-bit])
162 AC_DEFINE(dirent64, dirent,
163 [64-bit operations are the same as 32-bit])
166 dnl Check if struct stat has st_mtim.
167 AC_MSG_CHECKING(for stat::st_mtim)
169 [AC_LANG_PROGRAM([#include <time.h>
170 #include <sys/time.h>
171 #include <sys/stat.h>],
172 [struct stat foo; return sizeof(foo.st_mtim.tv_sec)])],
173 have_st_mtim=yes, have_st_mtim=no)
174 AC_MSG_RESULT($have_st_mtim)
175 if test "$have_st_mtim" = "yes"; then
176 AC_DEFINE([HAVE_ST_MTIM], [1],
177 [Define if your `struct stat' has `st_mtim'])
180 dnl F_DUPFD_CLOEXEC is a mandatory part of POSIX since Issue 7
181 AC_MSG_CHECKING(for F_DUPFD_CLOEXEC)
183 [AC_LANG_PROGRAM([#include <unistd.h>
185 [return fcntl(0, F_DUPFD_CLOEXEC, 0)])],
186 have_dupfd_cloexec=1, have_dupfd_cloexec=0)
187 AC_MSG_RESULT($(expr yes \& $have_dupfd_cloexec \| no))
188 AC_DEFINE_UNQUOTED([HAVE_F_DUPFD_CLOEXEC], [$have_dupfd_cloexec],
189 [Define to 1 your system supports F_DUPFD_CLOEXEC])
191 AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
193 if test "$with_libedit" = "yes"; then
194 AC_CHECK_LIB(edit, history_init, [
195 AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
197 [Can't find required header files.]))], [
198 AC_MSG_ERROR([Can't find libedit.])])
200 if test "$use_libedit" != "yes"; then
201 AC_DEFINE([SMALL], 1, [Define if you build with -DSMALL])
203 export LIBS="$LIBS -ledit"
205 AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \
206 [Disable LINENO support]))
207 if test "$enable_lineno" != "no"; then
208 AC_DEFINE([WITH_LINENO], 1, [Define if you build with -DWITH_LINENO])
210 AC_CONFIG_FILES([Makefile src/Makefile])