X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=configure.in;h=07203e137c1efa7643daa3c950d6028c53869c60;hp=3b1d49e4f2bed99888f8181ed20318ca4b558dd1;hb=b227b5eb762f86725d711fb84d665190622e9adc;hpb=caf14c53db57b48303a8f5f3f001faaf0e117f9d diff --git a/configure.in b/configure.in index 3b1d49e4f2..07203e137c 100644 --- a/configure.in +++ b/configure.in @@ -781,9 +781,41 @@ AM_CONDITIONAL(BITQ, test $build_bitq = yes) AC_LANG_C AC_PROG_CC +AC_PROG_CC_C99 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 +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 not 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