|
From: <zw...@ma...> - 2009-05-06 09:18:05
|
Author: zwelch
Date: 2009-05-06 09:17:57 +0200 (Wed, 06 May 2009)
New Revision: 1610
Modified:
trunk/configure.in
trunk/src/helper/jim.c
Log:
Add autoconf check to determine where environ should be declared.
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2009-05-06 06:40:56 UTC (rev 1609)
+++ trunk/configure.in 2009-05-06 07:17:57 UTC (rev 1610)
@@ -784,6 +784,37 @@
AM_PROG_CC_C_O
AC_PROG_RANLIB
+# Look for environ alternatives. Possibility #1: is environ in unistd.h?
+AC_MSG_CHECKING([for environ in unistd.h])
+AC_COMPILE_IFELSE([
+#define _GNU_SOURCE
+#include <unistd.h>
+int main(int argc, char **argv) { char **ep = environ; }
+ ], [
+ AC_MSG_RESULT([yes])
+ has_environ=yes
+ ], [
+ AC_MSG_RESULT([no])
+
+ # Possibility #2: can environ be found in an available library?
+ AC_MSG_CHECKING([for extern environ])
+ AC_LINK_IFELSE([
+extern char **environ;
+int main(int argc, char **argv) { char **ep = environ; }
+ ], [
+ AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
+ has_environ=yes
+ ], [
+ has_environ=no
+ ])
+ AC_MSG_RESULT([${has_environ}])
+ ])
+
+if test "${has_environ}" != "yes" ; then
+ AC_MSG_FAILURE([Could find 'environ' in unistd.h or available libraries.])
+fi
+
+
# set default gcc warnings
GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security"
if test "${gcc_wextra}" = yes; then
Modified: trunk/src/helper/jim.c
===================================================================
--- trunk/src/helper/jim.c 2009-05-06 06:40:56 UTC (rev 1609)
+++ trunk/src/helper/jim.c 2009-05-06 07:17:57 UTC (rev 1610)
@@ -11984,7 +11984,7 @@
if (argc == 1) {
-#if !defined(HAVE_UNISTD_H) || !defined(__GNU_LIBRARY__)
+#ifdef NEED_ENVIRON_EXTERN
extern char **environ;
#endif
|