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