1dnl cc-c-o.m4 -- Checks whether -o can be used with -c.
2dnl $Id: cc-c-o.m4 8407 2009-04-11 17:16:06Z iulius $
3dnl
4dnl Used to check whether -o can be provided with -c with the chosen compiler.
5dnl We need this if we're not using libtool so that object files can be built
6dnl in subdirectories.  This macro is stolen shamelessly from the libtool
7dnl macros.  Note that we don't use the Autoconf version because it both
8dnl checks too much (checking cc as well as the chosen compiler) and it sets a
9dnl compiler #define rather than setting a variable we can use.
10dnl
11dnl $compiler_c_o is set to yes if the compiler supports this and no if not.
12
13AC_DEFUN([INN_PROG_CC_C_O],
14[AC_REQUIRE([AC_OBJEXT])
15AC_MSG_CHECKING([if $CC supports -c -o file.$ac_objext])
16AC_CACHE_VAL([inn_cv_compiler_c_o],
17[rm -f -r conftest 2>/dev/null
18mkdir conftest
19cd conftest
20echo "int some_variable = 0;" > conftest.$ac_ext
21mkdir out
22# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
23# that will create temporary files in the current directory regardless of
24# the output directory.  Thus, making CWD read-only will cause this test
25# to fail, enabling locking or at least warning the user not to do parallel
26# builds.
27chmod -w .
28save_CFLAGS="$CFLAGS"
29CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
30compiler_c_o=no
31if { (eval $ac_compile) 2> out/conftest.err; } \
32    && test -s out/conftest2.$ac_objext; then
33  # The compiler can only warn and ignore the option if not recognized
34  # So say no if there are warnings
35  if test -s out/conftest.err; then
36    inn_cv_compiler_c_o=no
37  else
38    inn_cv_compiler_c_o=yes
39  fi
40else
41  # Append any errors to the config.log.
42  cat out/conftest.err 1>&AS_MESSAGE_LOG_FD
43  inn_cv_compiler_c_o=no
44fi
45CFLAGS="$save_CFLAGS"
46chmod u+w .
47rm -f conftest* out/*
48rmdir out
49cd ..
50rmdir conftest
51rm -f -r conftest 2>/dev/null])
52compiler_c_o=$inn_cv_compiler_c_o
53AC_MSG_RESULT([$compiler_c_o])])
54