Bump to dash 0.5.11.5
[platform/upstream/dash.git] / configure.ac
1 AC_INIT([dash],[0.5.11.5])
2 AM_INIT_AUTOMAKE([foreign subdir-objects])
3 AC_CONFIG_SRCDIR([src/main.c])
4
5 AC_CONFIG_HEADERS(config.h)
6
7 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
8
9 dnl Checks for programs.
10 AC_PROG_CC
11 AC_USE_SYSTEM_EXTENSIONS
12
13 AC_MSG_CHECKING([for build system compiler])
14 if test "$cross_compiling" = yes; then
15         CC_FOR_BUILD=${CC_FOR_BUILD-cc}
16 else
17         CC_FOR_BUILD=${CC}
18 fi
19 AC_MSG_RESULT(${CC_FOR_BUILD})
20 AC_SUBST(CC_FOR_BUILD)
21
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")));],
26                                 [a();])],
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])
32 fi
33
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 -Wl,--fatal-warnings"
38 fi
39
40 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \
41                                       [Use fnmatch(3) from libc]))
42 AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
43
44 dnl Checks for libraries.
45
46 dnl Checks for header files.
47 AC_CHECK_HEADERS(alloca.h paths.h)
48
49 dnl Check for declarations
50 AC_CHECK_DECL([_PATH_BSHELL],,AC_DEFINE_UNQUOTED([_PATH_BSHELL], "/bin/sh", [Define to system shell path]),[
51 #ifdef HAVE_PATHS_H
52 #include <paths.h>
53 #endif
54 ])
55 AC_CHECK_DECL([_PATH_DEVNULL],,AC_DEFINE_UNQUOTED([_PATH_DEVNULL], "/dev/null", [Define to devnull device node path]),[
56 #ifdef HAVE_PATHS_H
57 #include <paths.h>
58 #endif
59 ])
60 AC_CHECK_DECL([_PATH_TTY],,AC_DEFINE_UNQUOTED([_PATH_TTY], "/dev/tty", [Define to tty device node path]),[
61 #ifdef HAVE_PATHS_H
62 #include <paths.h>
63 #endif
64 ])
65
66 dnl Some systems lack isblank
67 AC_CHECK_DECLS([isblank],,,[#include <ctype.h>])
68
69 dnl Check for sizes of types
70 AC_CHECK_SIZEOF([intmax_t])
71 AC_CHECK_SIZEOF([long long int])
72
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
75   intmax_fstr="lld"
76 else
77   intmax_fstr="jd"
78 fi
79
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])],
84         [
85 #include <inttypes.h>
86 ])
87
88 dnl Checks for library functions.
89 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \
90                mempcpy \
91                sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
92                strtoumax sysconf)
93
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.
97 dnl
98 dnl Unaffected kernels:
99 dnl
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
104 dnl
105 dnl Also worked around in Debian's libc0.1 2.13-19 when using
106 dnl kFreeBSD 8.
107
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])
111
112 if test "enable_test_workaround" = "auto" &&
113    test "$ac_cv_func_faccessat" = yes; then
114         case `uname -s 2>/dev/null` in
115         GNU/kFreeBSD | \
116         FreeBSD)
117                 enable_test_workaround=yes
118         esac
119 fi
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])
123 fi
124
125 if test "$enable_fnmatch" = yes; then
126         use_fnmatch=
127         AC_CHECK_FUNCS(fnmatch, use_fnmatch=yes)
128 fi
129
130 if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
131         AC_CHECK_FUNCS(glob)
132 fi
133
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])])
140 fi
141
142 dnl Check for stat64 (dietlibc/klibc).
143 AC_CHECK_FUNC(stat64,, [
144         AC_DEFINE(fstat64, fstat, [64-bit operations are the same as 32-bit])
145         AC_DEFINE(lstat64, lstat, [64-bit operations are the same as 32-bit])
146         AC_DEFINE(stat64, stat, [64-bit operations are the same as 32-bit])
147 ])
148
149 dnl OS X apparently has stat64 but not open64.
150 AC_CHECK_FUNC(open64,, [
151         AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
152         AC_DEFINE(readdir64, readdir,
153                   [64-bit operations are the same as 32-bit])
154         AC_DEFINE(dirent64, dirent,
155                   [64-bit operations are the same as 32-bit])
156 ])
157
158 dnl Check if struct stat has st_mtim.
159 AC_MSG_CHECKING(for stat::st_mtim)
160 AC_COMPILE_IFELSE(
161 [AC_LANG_PROGRAM([#include <time.h>
162 #include <sys/time.h>
163 #include <sys/stat.h>],
164 [struct stat foo; return sizeof(foo.st_mtim.tv_sec)])],
165 have_st_mtim=yes, have_st_mtim=no)
166 AC_MSG_RESULT($have_st_mtim)
167 if test "$have_st_mtim" = "yes"; then
168         AC_DEFINE([HAVE_ST_MTIM], [1],
169                 [Define if your `struct stat' has `st_mtim'])
170 fi
171
172 AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
173 use_libedit=
174 if test "$with_libedit" = "yes"; then
175         AC_CHECK_LIB(edit, history_init, [
176                 AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
177                                 AC_MSG_ERROR(
178                                         [Can't find required header files.]))])
179 fi
180 if test "$use_libedit" != "yes"; then
181         AC_DEFINE([SMALL], 1, [Define if you build with -DSMALL])
182 else
183         export LIBS="$LIBS -ledit"
184 fi
185 AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \
186                                      [Disable LINENO support]))
187 if test "$enable_lineno" != "no"; then
188         AC_DEFINE([WITH_LINENO], 1, [Define if you build with -DWITH_LINENO])
189 fi
190 AC_CONFIG_FILES([Makefile src/Makefile])
191 AC_OUTPUT