summary refs log tree commit diff
path: root/configure.ac
diff options
context:
space:
mode:
authorBrian Koropoff <bkoropoff@gmail.com>2011-03-15 15:35:14 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2011-03-15 15:35:14 +0800
commitbfcdc4969510997fe81debf52982641febfa1bdf (patch)
tree695ccd9508035cc35be2cfe1ed6f2ae7e892c11e /configure.ac
parent[BUILTIN] Fix backslash handling in read(1) (diff)
downloaddash-bfcdc4969510997fe81debf52982641febfa1bdf.tar.gz
dash-bfcdc4969510997fe81debf52982641febfa1bdf.zip
[SHELL] Port to Solaris
- Solaris lacks paths.h and the various _PATH_* #defines.
  Check for them in configure.ac and fall back on the
  usual suspects when they are missing.

- Older Solaris lacks isblank(), and versions that have it
  use a macro.  Check for the declaration in configure.ac
  and fall back on a naive version when missing.

- Older Solaris does not support %jd (intmax_t) in format
  strings, but it does support the PRIdMAX macro from inttypes.h.
  Do a configure check for PRIdMAX and use it in the code.
  If it doesn't exist, define it to "lld" when sizeof(long long)
  equals sizeof(intmax_t) as this is more likely to work on
  older systems.  Otherwise, use "jd" and hope for the best.

- Older Solaris lacks stdint.h, but inttypes.h provides the
  same types and works on all platforms I've tried dash on,
  so just use it instead.

- Older Solaris doesn't like it when vsnprintf() is passed
  a NULL buffer (in violation of the POSIX spec, of course).
  Pass a 1-byte dummy buffer instead.

- Solaris lacks tempfile and mktemp programs.  Fall back on a
  "good-enough" custom function in mkbuiltins.

Signed-off-by: Brian Koropoff <bkoropoff@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac41
1 files changed, 40 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index c943725..effdffc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,7 +43,46 @@ AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
 dnl Checks for libraries.
 
 dnl Checks for header files.
-AC_CHECK_HEADERS(alloca.h)
+AC_CHECK_HEADERS(alloca.h paths.h)
+
+dnl Check for declarations
+AC_CHECK_DECL([_PATH_BSHELL],,AC_DEFINE_UNQUOTED([_PATH_BSHELL], "/bin/sh", [Define to system shell path]),[
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+])
+AC_CHECK_DECL([_PATH_DEVNULL],,AC_DEFINE_UNQUOTED([_PATH_DEVNULL], "/dev/null", [Define to devnull device node path]),[
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+])
+AC_CHECK_DECL([_PATH_TTY],,AC_DEFINE_UNQUOTED([_PATH_TTY], "/dev/tty", [Define to tty device node path]),[
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+])
+
+dnl Some systems lack isblank
+AC_CHECK_DECLS([isblank],,,[#include <ctype.h>])
+
+dnl Check for sizes of types
+AC_CHECK_SIZEOF([intmax_t])
+AC_CHECK_SIZEOF([long long int])
+
+dnl Select a fallback format string for intmax_t in case we don't find PRIdMAX
+if test "x$ac_cv_sizeof_intmax_t" = "x$ac_cv_sizeof_long_long_int"; then
+  intmax_fstr="lld"
+else
+  intmax_fstr="jd"
+fi
+
+dnl Check for PRIdMAX and define it to a fallback if not found
+AC_CHECK_DECL([PRIdMAX],,
+	[AC_DEFINE_UNQUOTED([PRIdMAX], "$intmax_fstr",
+				       [Define to printf format string for intmax_t])],
+        [
+#include <inttypes.h>
+])
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit imaxdiv isalpha killpg \