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 -------------------------------------------------------
8 # don't let the AC_PROG_CC macro auto set the CFLAGS
11 CFLAGS="${OLD_CFLAGS}"
12 if test x"$CC" = x""; then
13 AC_MSG_WARN([No c compiler was not found!])
14 AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
17 if test x"$GCC" = x"yes" ; then
18 AC_MSG_CHECKING([for version of gcc])
19 GCC_VERSION=`$CC -dumpversion`
20 AC_MSG_RESULT(${GCC_VERSION})
24 # Set the debug symbol option if we have
25 # --enable-*developer or --enable-debug
26 # and the compiler supports it
28 if test x$ac_cv_prog_cc_g = xyes -a x$debug = xyes; then
32 dnl needed before AC_TRY_COMPILE
35 ############################################
36 # check if the compiler handles c99 struct initialization
37 LIBREPLACE_C99_STRUCT_INIT(samba_cv_c99_struct_initialization=yes,
38 samba_cv_c99_struct_initialization=no)
40 if test x"$samba_cv_c99_struct_initialization" != x"yes"; then
41 AC_MSG_WARN([C compiler does not support c99 struct initialization!])
42 AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
45 ############################################
46 # check if the compiler can handle negative enum values
47 # and don't truncate the values to INT_MAX
48 # a runtime test is needed here
49 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
53 enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
55 enum negative_values v1 = NEGATIVE_VALUE;
56 unsigned v2 = NEGATIVE_VALUE;
58 if (v1 != 0xFFFFFFFF) {
59 printf("%u != 0xFFFFFFFF\n", v1);
62 if (v2 != 0xFFFFFFFF) {
63 printf("%u != 0xFFFFFFFF\n", v2);
70 SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
71 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
72 AC_MSG_WARN([using --unit-enums for pidl])
73 PIDL_ARGS="$PIDL_ARGS --uint-enums"
76 AC_MSG_CHECKING([for test routines])
77 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
79 AC_MSG_ERROR([cant find test code. Aborting config]),
80 AC_MSG_WARN([cannot run when cross-compiling]))
83 # Check if the compiler support ELF visibility for symbols
86 visibility_attribute=no
88 if test x"$GCC" = x"yes" ; then
89 AX_CFLAGS_GCC_OPTION([-fvisibility=hidden], VISIBILITY_CFLAGS)
92 if test -n "$VISIBILITY_CFLAGS"; then
93 AC_MSG_CHECKING([whether the C compiler supports the visibility attribute])
96 CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
98 void vis_foo1(void) {}
99 __attribute__((visibility("default"))) void vis_foo2(void) {}
100 #include "${srcdir-.}/build/tests/trivial.c"
103 AC_DEFINE(HAVE_VISIBILITY_ATTR,1,[Whether the C compiler supports the visibility attribute])
104 visibility_attribute=yes
110 AC_SUBST(visibility_attribute)
113 # Check if the compiler can handle the options we selected by
114 # --enable-*developer
117 if test x$developer = xyes; then
118 OLD_CFLAGS="${CFLAGS}"
120 CFLAGS="${CFLAGS} -D_SAMBA_DEVELOPER_DONNOT_USE_O2_"
121 DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
122 if test x"$GCC" = x"yes" ; then
124 # warnings we want...
126 AX_CFLAGS_GCC_OPTION(-Wall, DEVELOPER_CFLAGS)
127 AX_CFLAGS_GCC_OPTION(-Wshadow, DEVELOPER_CFLAGS)
128 AX_CFLAGS_GCC_OPTION(-Werror-implicit-function-declaration, DEVELOPER_CFLAGS)
129 AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes, DEVELOPER_CFLAGS)
130 AX_CFLAGS_GCC_OPTION(-Wpointer-arith, DEVELOPER_CFLAGS)
131 AX_CFLAGS_GCC_OPTION(-Wcast-qual, DEVELOPER_CFLAGS)
132 AX_CFLAGS_GCC_OPTION(-Wcast-align, DEVELOPER_CFLAGS)
133 AX_CFLAGS_GCC_OPTION(-Wwrite-strings, DEVELOPER_CFLAGS)
134 AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute, DEVELOPER_CFLAGS)
135 AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS)
136 AX_CFLAGS_GCC_OPTION(-Wdeclaration-after-statement, DEVELOPER_CFLAGS)
137 AX_CFLAGS_GCC_OPTION(-Wunused-macros, DEVELOPER_CFLAGS)
138 # AX_CFLAGS_GCC_OPTION(-Wextra, DEVELOPER_CFLAGS)
139 # AX_CFLAGS_GCC_OPTION(-Wc++-compat, DEVELOPER_CFLAGS)
140 # AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes, DEVELOPER_CFLAGS)
141 # AX_CFLAGS_GCC_OPTION(-Wmissing-declarations, DEVELOPER_CFLAGS)
142 # AX_CFLAGS_GCC_OPTION(-Wmissing-field-initializers, DEVELOPER_CFLAGS)
144 # warnings we don't want...
146 AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS)
147 AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter, DEVELOPER_CFLAGS)
149 AX_CFLAGS_IRIX_OPTION(-fullwarn, DEVELOPER_CFLAGS)
152 CFLAGS="${OLD_CFLAGS}"
154 if test -n "$DEVELOPER_CFLAGS"; then
155 OLD_CFLAGS="${CFLAGS}"
156 CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
157 AC_MSG_CHECKING([that the C compiler can use the DEVELOPER_CFLAGS])
158 AC_TRY_COMPILE([],[],
160 DEVELOPER_CFLAGS=""; AC_MSG_RESULT(no))
161 CFLAGS="${OLD_CFLAGS}"
165 # Config CPPFLAG settings for strange OS's that must be set
166 # before other tests.
169 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
171 # mmap on HPUX is completely broken...
172 AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
176 if test "${GCC}" != "yes"; then
177 ## for funky AIX compiler using strncpy()
178 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
183 # VOS may need to have POSIX support and System V compatibility enabled.
187 *-D_POSIX_C_SOURCE*);;
189 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
190 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
194 *-D_SYSV*|*-D_SVID_SOURCE*);;
196 CPPFLAGS="$CPPFLAGS -D_SYSV"
197 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
203 # allow for --with-hostcc=gcc
204 AC_ARG_WITH(hostcc,[ --with-hostcc=compiler choose host compiler],
207 if test z"$cross_compiling" = "yes"; then
215 AC_PATH_PROG(GCOV,gcov)
217 AC_PATH_PROG(MAKE,make)
219 AC_CACHE_CHECK([whether we have GNU make], samba_cv_gnu_make, [
220 if $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null
222 samba_cv_gnu_make=yes
228 GNU_MAKE=$samba_cv_gnu_make
231 if test "x$GNU_MAKE" = x"yes"; then
232 AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[
233 samba_cv_gnu_make_version=`$ac_cv_path_MAKE --version | head -1 | cut -d " " -f 3 2>/dev/null`
235 GNU_MAKE_VERSION=$samba_cv_gnu_make_version
236 AC_SUBST(GNU_MAKE_VERSION)
241 AC_MSG_CHECKING([for GNU make >= 3.81])
242 if test x$GNU_MAKE = x"yes"; then
243 if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then
247 AC_MSG_RESULT($new_make)
248 automatic_dependencies=no
249 AX_CFLAGS_GCC_OPTION([-M -MT conftest.d -MF conftest.o], [], [ automatic_dependencies=$new_make ], [])
250 AC_MSG_CHECKING([Whether to use automatic dependencies])
251 AC_MSG_RESULT($automatic_dependencies)
252 AC_SUBST(automatic_dependencies)