summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-06 07:17:57 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-06 07:17:57 +0000
commit7e50a3977327c52e9e04f9cf3ac1cd0a54f042b2 (patch)
tree7265b60950e66097037e59fdfa7a9d1bd9f0975f /configure.in
parent213368e21f892a4c6df80cbdae1a163df36c1d51 (diff)
downloadopenocd+libswd-7e50a3977327c52e9e04f9cf3ac1cd0a54f042b2.tar.gz
openocd+libswd-7e50a3977327c52e9e04f9cf3ac1cd0a54f042b2.tar.bz2
openocd+libswd-7e50a3977327c52e9e04f9cf3ac1cd0a54f042b2.tar.xz
openocd+libswd-7e50a3977327c52e9e04f9cf3ac1cd0a54f042b2.zip
Add autoconf check to determine where environ should be declared.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1610 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in31
1 files changed, 31 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 3b1d49e4..50c149a8 100644
--- a/configure.in
+++ b/configure.in
@@ -784,6 +784,37 @@ AC_PROG_CC
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