2 AM_INIT_AUTOMAKE([foreign])
3 AC_CONFIG_SRCDIR([src/main.c])
5 AC_CONFIG_HEADERS(config.h)
7 dnl Checks for programs.
12 AC_MSG_CHECKING([for build system compiler])
13 if test "$cross_compiling" = yes; then
14 CC_FOR_BUILD=${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")));],
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]),[
54 AC_CHECK_DECL([_PATH_DEVNULL],,AC_DEFINE_UNQUOTED([_PATH_DEVNULL], "/dev/null", [Define to devnull device node path]),[
59 AC_CHECK_DECL([_PATH_TTY],,AC_DEFINE_UNQUOTED([_PATH_TTY], "/dev/tty", [Define to tty device node path]),[
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
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])],
87 dnl Checks for library functions.
88 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit imaxdiv isalpha killpg \
90 sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
93 if test "$enable_fnmatch" = yes; then
95 AC_CHECK_FUNCS(fnmatch, use_fnmatch=yes)
98 if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
102 dnl Check for klibc signal.
103 AC_CHECK_FUNC(signal)
104 if test "$ac_cv_func_signal" != yes; then
105 AC_CHECK_FUNC(bsd_signal,
106 [AC_DEFINE(signal, bsd_signal,
107 [klibc has bsd_signal instead of signal])])
110 dnl Check for stat64 (dietlibc/klibc).
111 AC_CHECK_FUNC(stat64,, [
112 AC_DEFINE(fstat64, fstat, [64-bit operations are the same as 32-bit])
113 AC_DEFINE(lstat64, lstat, [64-bit operations are the same as 32-bit])
114 AC_DEFINE(stat64, stat, [64-bit operations are the same as 32-bit])
117 AC_CHECK_FUNC(open64,, [
118 AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
121 AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
123 if test "$with_libedit" = "yes"; then
124 AC_CHECK_LIB(edit, history_init, [
125 AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
127 [Can't find required header files.]))])
129 if test "$use_libedit" != "yes"; then
130 AC_DEFINE([SMALL], 1, [Define if you build with -DSMALL])
132 export LIBS="$LIBS -ledit"
134 AC_CONFIG_FILES([Makefile src/Makefile])