• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ===========================================================================
2#       http://
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_PLATFORM
8#
9# DESCRIPTION
10#
11#   Provide target and host defines.
12#
13# LICENSE
14#
15#   Copyright (c) 2012 Brian Aker <brian@tangent.org>
16#   Copyleft  (ↄ) 2013 Jacob Appelbaum <jacob@appelbaum.net>
17#
18#   Copying and distribution of this file, with or without modification, are
19#   permitted in any medium without royalty provided the copyright notice
20#   and this notice are preserved. This file is offered as-is, without any
21#   warranty.
22
23#serial 1
24  AC_DEFUN([AX_PLATFORM],
25      [AC_REQUIRE([AC_CANONICAL_HOST])
26      AC_REQUIRE([AC_CANONICAL_TARGET])
27
28      AC_DEFINE_UNQUOTED([HOST_VENDOR],["$host_vendor"],[Vendor of Build System])
29      AC_DEFINE_UNQUOTED([HOST_OS],["$host_os"], [OS of Build System])
30      AC_DEFINE_UNQUOTED([HOST_CPU],["$host_cpu"], [CPU of Build System])
31
32      AC_DEFINE_UNQUOTED([TARGET_VENDOR],["$target_vendor"],[Vendor of Target System])
33      AC_DEFINE_UNQUOTED([TARGET_OS],["$target_os"], [OS of Target System])
34      AC_DEFINE_UNQUOTED([TARGET_CPU],["$target_cpu"], [CPU of Target System])
35
36      AS_CASE([$target_os],
37        [*mingw32*],
38        [TARGET_OS_WINDOWS="true"
39        AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows])
40        AC_DEFINE([WINVER], [WindowsXP], [Version of Windows])
41        AC_DEFINE([_WIN32_WINNT], [0x0501], [Magical number to make things work])
42        AC_DEFINE([EAI_SYSTEM], [11], [Another magical number])
43        AH_BOTTOM([
44#ifndef HAVE_SYS_SOCKET_H
45# define SHUT_RD SD_RECEIVE
46# define SHUT_WR SD_SEND
47# define SHUT_RDWR SD_BOTH
48#endif
49          ])],
50        [*mingw*],
51        [TARGET_OS_MINGW="true"
52        AC_DEFINE([TARGET_OS_MINGW],[1],[Whether we build for MinGW])],
53        [*cygwin*],
54        [TARGET_OS_CYGWIN="true"
55        AC_DEFINE([TARGET_OS_CYGWIN],[1],[Whether we build for Cygwin])],
56        [*haiku*],
57        [TARGET_OS_HAIKU="true"
58        AC_DEFINE([TARGET_OS_HAIKU],[1],[Whether we build for Haiku])],
59        [*freebsd*],
60        [TARGET_OS_FREEBSD="true"
61        AC_DEFINE([TARGET_OS_FREEBSD],[1],[Whether we are building for FreeBSD])],
62        [*kfreebsd*-gnu],
63        [TARGET_OS_GNUKFREEBSD="true"
64        TARGET_OS_FREEBSD="true"
65        AC_DEFINE([TARGET_OS_FREEBSD],[1],[Whether we are building for FreeBSD])
66        AC_DEFINE([TARGET_OS_GNUKFREEBSD],[1],[Whether we are building for GNU/kFreeBSD])],
67        [*netbsd*],
68        [TARGET_OS_NETBSD="true"
69        AC_DEFINE([TARGET_OS_NETBSD],[1],[Whether we are building for NetBSD])],
70        [*openbsd*],
71        [TARGET_OS_OPENBSD="true"
72        AC_DEFINE([TARGET_OS_OPENBSD],[1],[Whether we are building for OpenBSD])],
73        [*dragonfly*],
74        [TARGET_OS_DRAGONFLYBSD="true"
75        AC_DEFINE([TARGET_OS_DRAGONFLYBSD],[1],[Whether we are building for DragonFly BSD])],
76        [*bsd*],
77        [TARGET_OS_BSD="true"
78        AC_DEFINE([TARGET_OS_BSD],[1],[Whether we are building for some other *BSD])],
79        [*solaris*],[AC_DEFINE([TARGET_OS_SOLARIS],[1],[Whether we are building for Solaris])],
80        [*darwin*],
81        [TARGET_OS_OSX="true"
82        AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])],
83        [*linux*],
84        [TARGET_OS_LINUX="true"
85        AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])],
86        [*gnu*],
87        [TARGET_OS_GNUHURD="true"
88        AC_DEFINE([TARGET_OS_GNUHURD],[1],[Whether we build for GNU/Hurd])])
89
90  AM_CONDITIONAL([TARGET_WIN32],[test "x${TARGET_OS_WINDOWS}" = "xtrue"])
91  AM_CONDITIONAL([TARGET_MINGW],[test "x${TARGET_OS_MINGW}" = "xtrue"])
92  AM_CONDITIONAL([TARGET_CYGWIN],[test "x${TARGET_OS_CYGWIN}" = "xtrue"])
93  AM_CONDITIONAL([TARGET_HAIKU],[test "x${TARGET_OS_HAIKU}" = "xtrue"])
94  AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OS_OSX}" = "xtrue"])
95  AM_CONDITIONAL([TARGET_GNUHURD],[test "x${TARGET_OS_GNUHURD}" = "xtrue"])
96  AM_CONDITIONAL([TARGET_LINUX],[test "x${TARGET_OS_LINUX}" = "xtrue"])
97  AM_CONDITIONAL([TARGET_FREEBSD],[test "x${TARGET_OS_FREEBSD}" = "xtrue"])
98  AM_CONDITIONAL([TARGET_GNUKFREEBSD],[test "x${TARGET_OS_GNUKFREEBSD}" = "xtrue"])
99  AM_CONDITIONAL([TARGET_NETBSD],[test "x${TARGET_OS_NETBSD}" = "xtrue"])
100  AM_CONDITIONAL([TARGET_OPENBSD],[test "x${TARGET_OS_OPENBSD}" = "xtrue"])
101  AM_CONDITIONAL([TARGET_DRAGONFLYBSD],[test "x${TARGET_OS_DRAGONFLYBSD}" = "xtrue"])
102  AM_CONDITIONAL([TARGET_BSD],[test "x${TARGET_OS_BSD}" = "xtrue"])
103  ])
104