1 dnl SMB Build Environment CC Checks
2 dnl -------------------------------------------------------
3 dnl Copyright (C) Stefan (metze) Metzmacher 2004
4 dnl Released under the GNU GPL
5 dnl -------------------------------------------------------
9 if test x"$CC" = x""; then
10 AC_MSG_WARN([No c compiler was not found!])
11 AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
14 dnl needed before AC_TRY_COMPILE
17 dnl Check if C compiler understands -c and -o at the same time
19 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
26 AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
27 dnl Check whether the compiler can generate precompiled headers
29 if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
30 samba_cv_precompiled_headers=yes
32 samba_cv_precompiled_headers=no
35 if test x"$samba_cv_precompiled_headers" = x"yes"; then
38 AC_SUBST(PCH_AVAILABLE)
41 dnl Check if the C compiler understands volatile (it should, being ANSI).
42 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
43 AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
44 samba_cv_volatile=yes,samba_cv_volatile=no)])
45 if test x"$samba_cv_volatile" = x"yes"; then
46 AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
49 ############################################
50 # check if the compiler can do immediate structures
51 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
55 typedef struct {unsigned x;} FOOBAR;
56 #define X_FOOBAR(x) ((FOOBAR) { x })
57 #define FOO_ONE X_FOOBAR(1)
65 samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
66 if test x"$samba_cv_immediate_structures" = x"yes"; then
67 AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
70 ############################################
71 # check if the compiler can handle negative enum values
72 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
76 enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
78 SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
79 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
80 AC_MSG_WARN([using --unit-enums for pidl])
81 PIDL_ARGS="$PIDL_ARGS --uint-enums"
84 AC_MSG_CHECKING([for test routines])
85 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
87 AC_MSG_ERROR([cant find test code. Aborting config]),
88 AC_MSG_WARN([cannot run when cross-compiling]))
91 # Check if the compiler can handle the options we selected by
94 if test -n "$DEVELOPER_CFLAGS"; then
95 OLD_CFLAGS="${CFLAGS}"
96 CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
97 AC_MSG_CHECKING([that the C compiler can use the DEVELOPER_CFLAGS])
98 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
100 DEVELOPER_CFLAGS=""; AC_MSG_RESULT(no),
101 AC_MSG_WARN([cannot run when cross-compiling]))
102 CFLAGS="${OLD_CFLAGS}"