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/])
16 dnl needed before AC_TRY_COMPILE
19 dnl Check if C compiler understands -c and -o at the same time
21 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
28 AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
29 dnl Check whether the compiler can generate precompiled headers
31 if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
32 samba_cv_precompiled_headers=yes
34 samba_cv_precompiled_headers=no
37 if test x"$samba_cv_precompiled_headers" = x"yes"; then
40 AC_SUBST(PCH_AVAILABLE)
43 dnl Check if the C compiler understands volatile (it should, being ANSI).
44 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
45 AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
46 samba_cv_volatile=yes,samba_cv_volatile=no)])
47 if test x"$samba_cv_volatile" = x"yes"; then
48 AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
51 ############################################
52 # check if the compiler can do immediate structures
53 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
57 typedef struct {unsigned x;} FOOBAR;
58 #define X_FOOBAR(x) ((FOOBAR) { x })
59 #define FOO_ONE X_FOOBAR(1)
67 samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
68 if test x"$samba_cv_immediate_structures" = x"yes"; then
69 AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
72 ############################################
73 # check if the compiler handles c99 struct initialization
74 AC_CACHE_CHECK([for c99 struct initialization],samba_cv_c99_struct_initialization, [
87 samba_cv_c99_struct_initialization=yes,samba_cv_c99_struct_initialization=no)])
88 if test x"$samba_cv_c99_struct_initialization" != x"yes"; then
89 AC_MSG_WARN([C compiler does not support c99 struct initialization!])
90 AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
93 ############################################
94 # check if the compiler can handle negative enum values
95 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
99 enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
101 SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
102 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
103 AC_MSG_WARN([using --unit-enums for pidl])
104 PIDL_ARGS="$PIDL_ARGS --uint-enums"
107 AC_MSG_CHECKING([for test routines])
108 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
110 AC_MSG_ERROR([cant find test code. Aborting config]),
111 AC_MSG_WARN([cannot run when cross-compiling]))
114 # Check if the compiler can handle the options we selected by
115 # --enable-*developer
117 if test -n "$DEVELOPER_CFLAGS"; then
118 OLD_CFLAGS="${CFLAGS}"
119 CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
120 AC_MSG_CHECKING([that the C compiler can use the DEVELOPER_CFLAGS])
121 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
123 DEVELOPER_CFLAGS=""; AC_MSG_RESULT(no),
124 AC_MSG_WARN([cannot run when cross-compiling]))
125 CFLAGS="${OLD_CFLAGS}"
128 # allow for --with-hostcc=gcc
129 AC_ARG_WITH(hostcc,[ --with-hostcc=compiler choose host compiler],[HOSTCC=$withval],[HOSTCC=$CC])