dcee0648e4bce1d094a8bffd3763593e8f14cfb0
[awesomized/libmemcached] / m4 / pandora_optimize.m4
1 dnl Copyright (C) 2009 Sun Microsystems, Inc.
2 dnl This file is free software; Sun Microsystems, Inc.
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([PANDORA_OPTIMIZE],[
7 dnl Build optimized or debug version ?
8 dnl First check for gcc and g++
9 AS_IF([test "$GCC" = "yes" -a "$INTELCC" = "no"],[
10
11 dnl The following is required for portable results of floating point
12 dnl calculations on PowerPC. The same must also be done for IA-64, but
13 dnl this options is missing in the IA-64 gcc backend.
14 case "$target_cpu" in
15 *ppc* | *powerpc*)
16 AM_CFLAGS="-mno-fused-madd ${AM_CFLAGS}"
17 AM_CXXFLAGS="-mno-fused-madd ${AM_CXXFLAGS}"
18 ;;
19 esac
20
21 AM_CPPFLAGS="-ggdb ${AM_CPPFLAGS}"
22
23 DEBUG_CFLAGS="-O0"
24 DEBUG_CXXFLAGS="-O0"
25
26 OPTIMIZE_CFLAGS="-O2"
27 OPTIMIZE_CXXFLAGS="-O2"
28 ])
29 AS_IF([test "$INTELCC" = "yes"],[
30 AM_CPPFLAGS="-g ${AM_CPPFLAGS}"
31
32 DEBUG_CFLAGS="-O0"
33 DEBUG_CXXFLAGS="-O0"
34
35 OPTIMIZE_CFLAGS="-xHOST -O2 -no-prec-div -static"
36 OPTIMIZE_CXXFLAGS="${OPTIMIZE_CFLAGS}"
37
38 ])
39 AS_IF([test "$SUNCC" = "yes"],[
40 dnl Once we can use a modern autoconf, we can replace the -xc99=all here
41 dnl with using AC_CC_STD_C99 above
42 CC="${CC} -xc99=all"
43 CXX="${CXX} -xlang=c99"
44
45 AM_CFLAGS="-g -mt -xstrconst -Xa ${AM_CFLAGS}"
46 AM_CXXFLAGS="-mt -compat=5 -library=stlport4 -library=Crun -template=no%extdef ${AM_CXXFLAGS}"
47
48 DEBUG_CXXFLAGS="-g"
49
50 dnl TODO: Make a test for -xO4 usability here
51 OPTIMIZE_FLAGS="-xO3 -xlibmil -xdepend -xbuiltin"
52 OPTIMIZE_CFLAGS="${OPTIMIZE_FLAGS}"
53 OPTIMIZE_CXXFLAGS="-g0 ${OPTIMIZE_FLAGS}"
54
55 ])
56
57 AC_ARG_WITH([debug],
58 [AS_HELP_STRING([--with-debug],
59 [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
60 [with_debug=$withval],
61 [with_debug=no])
62 AS_IF([test "$with_debug" = "yes"],[
63 # Debugging. No optimization.
64 AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG"
65 AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG"
66 AC_DEFINE(DEBUG, [ 1 ], [Define to 1 to enable debugging code.])
67 ],[
68 # Optimized version. No debug
69 AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}"
70 AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}"
71 AC_DEFINE(DEBUG, [ 0 ], [Define to 1 to enable debugging code.])
72 ])
73 ])