Merge Monty
[awesomized/libmemcached] / m4 / pandora_optimize.m4
1 dnl Copyright (C) 2009 Sun Microsystems
2 dnl This file is free software; Sun Microsystems
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"],[
10
11 AC_DEFINE([_GNU_SOURCE],[1],[Fix problem with S_ISLNK() on Linux])
12
13 dnl The following is required for portable results of floating point
14 dnl calculations on PowerPC. The same must also be done for IA-64, but
15 dnl this options is missing in the IA-64 gcc backend.
16 case "$target_cpu" in
17 *ppc* | *powerpc*)
18 AM_CFLAGS="-mno-fused-madd ${AM_CFLAGS}"
19 AM_CXXFLAGS="-mno-fused-madd ${AM_CXXFLAGS}"
20 ;;
21 esac
22
23 dnl Once we can use a modern autoconf, we can replace the std=gnu99 here
24 dnl with using AC_CC_STD_C99 above
25 CC="${CC} -std=gnu99"
26
27 AM_CPPFLAGS="-ggdb3 ${AM_CPPFLAGS}"
28
29 DEBUG_CFLAGS="-O0"
30 DEBUG_CXXFLAGS="-O0"
31
32 OPTIMIZE_CFLAGS="-O3"
33 OPTIMIZE_CXXFLAGS="-O3"
34 ])
35 AS_IF([test "$SUNCC" = "yes"],[
36 dnl Once we can use a modern autoconf, we can replace the -xc99=all here
37 dnl with using AC_CC_STD_C99 above
38 CC="${CC} -xc99=all"
39 CXX="${CXX} -xlang=c99"
40
41 AM_CFLAGS="-g -mt -xstrconst -Xa ${AM_CFLAGS}"
42 AM_CXXFLAGS="-g -mt -compat=5 -library=stlport4 -template=no%extdef ${AM_CXXFLAGS}"
43
44 dnl TODO: Make a test for -xO4 usability here
45 OPTIMIZE_FLAGS="-xO3 -xlibmil -xdepend -xbuiltin"
46 OPTIMIZE_CFLAGS="${OPTIMIZE_FLAGS}"
47 OPTIMIZE_CXXFLAGS="${OPTIMIZE_FLAGS}"
48 ])
49
50 AC_ARG_WITH([debug],
51 [AS_HELP_STRING([--with-debug],
52 [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
53 [with_debug=$withval],
54 [with_debug=no])
55 AS_IF([test "$with_debug" = "yes"],[
56 # Debugging. No optimization.
57 AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG"
58 AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG"
59 ],[
60 # Optimized version. No debug
61 AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}"
62 AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}"
63 ])
64 ])