Remove another chunck of Pandora.
[awesomized/libmemcached] / m4 / pandora_platform.m4
1 dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 dnl
4 dnl pandora-build: A pedantic build system
5 dnl Copyright (C) 2009 Sun Microsystems, Inc.
6 dnl This file is free software; Sun Microsystems
7 dnl gives unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
9 dnl
10 dnl From Monty Taylor
11
12 AC_DEFUN([PANDORA_PLATFORM],[
13 AC_REQUIRE([AC_CANONICAL_HOST])
14 AC_REQUIRE([AC_CANONICAL_TARGET])
15
16 dnl Canonicalize the configuration name.
17
18 AC_DEFINE_UNQUOTED([HOST_VENDOR], ["$host_vendor"],[Vendor of Build System])
19 AC_DEFINE_UNQUOTED([HOST_OS], ["$host_os"], [OS of Build System])
20 AC_DEFINE_UNQUOTED([HOST_CPU], ["$host_cpu"], [CPU of Build System])
21
22 AC_DEFINE_UNQUOTED([TARGET_VENDOR], ["$target_vendor"],[Vendor of Target System])
23 AC_DEFINE_UNQUOTED([TARGET_OS], ["$target_os"], [OS of Target System])
24 AC_DEFINE_UNQUOTED([TARGET_CPU], ["$target_cpu"], [CPU of Target System])
25
26
27 case "$host_os" in
28 *solaris*)
29 AS_IF([test "x${ac_cv_env_CPPFLAGS_set}" = "x"],[
30 CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
31 ])
32
33 AS_IF([test "x${ac_cv_env_LDFLAGS_set}" = "x"],[
34 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
35 ])
36 ;;
37 *freebsd*)
38 AS_IF([test "x${ac_cv_env_CPPFLAGS_set}" = "x"],[
39 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
40 ])
41
42 AS_IF([test "x${ac_cv_env_LDFLAGS_set}" = "x"],[
43 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
44 ])
45 ;;
46 esac
47
48 PANDORA_OPTIMIZE_BITFIELD=1
49
50 case "$target_os" in
51 *linux*)
52 TARGET_LINUX="true"
53 AC_SUBST(TARGET_LINUX)
54 AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux])
55 ;;
56 *darwin*)
57 TARGET_OSX="true"
58 AC_SUBST(TARGET_OSX)
59 AC_DEFINE([TARGET_OS_OSX], [1], [Whether we build for OSX])
60 ;;
61 *solaris*)
62 TARGET_SOLARIS="true"
63 PANDORA_OPTIMIZE_BITFIELD=0
64 AS_IF([test "x${USE_NLS}" = "xyes"],[LIBS="${LIBS} -lintl"])
65 AC_SUBST(TARGET_SOLARIS)
66 AC_DEFINE([TARGET_OS_SOLARIS], [1], [Whether we are building for Solaris])
67 ;;
68 *freebsd*)
69 TARGET_FREEBSD="true"
70 AC_SUBST(TARGET_FREEBSD)
71 AC_DEFINE([TARGET_OS_FREEBSD], [1], [Whether we are building for FreeBSD])
72 AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])
73 ;;
74 *mingw32*)
75 TARGET_WINDOWS="true"
76 AC_SUBST(TARGET_WINDOWS)
77 AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows])
78 AC_DEFINE([WINVER], [WindowsXP], [Version of Windows])
79 AC_DEFINE([_WIN32_WINNT], [0x0501], [Magical number to make things work])
80 AC_DEFINE([EAI_SYSTEM], [11], [Another magical number])
81 AH_BOTTOM([
82 #ifndef HAVE_SYS_SOCKET_H
83 # define SHUT_RD SD_RECEIVE
84 # define SHUT_WR SD_SEND
85 # define SHUT_RDWR SD_BOTH
86 #endif
87 ])
88
89 LIBS="$LIBS -lwsock32 -lws2_32"
90 AM_CFLAGS="${AM_CFLAGS} -I\${top_srcdir}/win32/mingw -I\${top_builddir}/win32/mingw -I\${top_srcdir}/win32 -I\${top_builddir}/win32"
91 ;;
92 esac
93 AM_CONDITIONAL(BUILD_WIN32, [test "x${TARGET_WINDOWS}" = "xtrue"])
94 AM_CONDITIONAL(TARGET_OSX, [test "x${TARGET_OSX}" = "xtrue"])
95 AM_CONDITIONAL(TARGET_LINUX, [test "x${TARGET_LINUX}" = "xtrue"])
96
97 AC_SUBST(PANDORA_OPTIMIZE_BITFIELD)
98
99 AC_CHECK_DECL([__clang__], [CLANG="yes"], [CLANG="no"])
100 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
101 AC_CHECK_DECL([__ICC], [INTELCC="yes"], [INTELCC="no"])
102
103 AS_IF([test "$INTELCC" = "yes"], [enable_rpath=no])
104
105 dnl By default, Sun Studio grabs special versions of limits.h and string.h
106 dnl when you use <cstring> and <climits>. By setting this define, we can
107 dnl disable that and cause those to wrap the standard headers instead.
108 dnl http://www.stlport.com/doc/configure.html
109 AS_IF([test "$SUNCC" = "yes"],[
110 AC_DEFINE([_STLP_NO_NEW_C_HEADERS],[1],
111 [Cause Sun Studio to not be quite so strict with standards conflicts])
112 ])
113
114 AS_IF([test "x$TARGET_OSX" = "xtrue"],[
115 AS_IF([test "x$ac_enable_fat_binaries" = "xyes"],[
116 AM_CFLAGS="-arch i386 -arch x86_64 -arch ppc"
117 AM_CXXFLAGS="-arch i386 -arch x86_64 -arch ppc"
118 AM_LDFLAGS="-arch i386 -arch x86_64 -arch ppc"
119 ])
120 ])
121
122 ])