summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.lib24
-rwxr-xr-xconfigure5
-rw-r--r--src/dedicated.cpp6
-rw-r--r--src/intro_gui.cpp2
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/network/core/host.cpp9
-rw-r--r--src/network/core/os_abstraction.h6
-rw-r--r--src/stdafx.h33
8 files changed, 52 insertions, 34 deletions
diff --git a/config.lib b/config.lib
index a77001b24..2e045da9d 100644
--- a/config.lib
+++ b/config.lib
@@ -459,10 +459,10 @@ check_params() {
log 1 " PREPROCESSOR is only available for OSX"
exit 1
fi
- # OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
- if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'`" ]; then
+ # OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
+ if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'`" ]; then
log 1 "configure: error: invalid option --os=$os"
- log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
+ log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
exit 1
fi
# cpu_type can be either 32 or 64
@@ -1203,11 +1203,11 @@ make_cflags_and_ldflags() {
fi
fi
- if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
+ if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
LIBS="$LIBS -lpthread"
fi
- if [ "$os" != "CYGWIN" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
+ if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
LIBS="$LIBS -lc"
fi
if [ "$os" = "WINCE" ]; then
@@ -1247,12 +1247,12 @@ make_cflags_and_ldflags() {
fi
fi
- if [ "$os" = "BEOS" ]; then
+ if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
LIBS="$LIBS -lmidi -lbe"
fi
# Most targets act like UNIX, just with some additions
- if [ "$os" = "BEOS" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
+ if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
CFLAGS="$CFLAGS -DUNIX"
fi
# And others like Windows
@@ -1427,6 +1427,10 @@ make_cflags_and_ldflags() {
LDFLAGS="$LDFLAGS -lbind -lsocket"
fi
+ if [ "$os" = "HAIKU" ]; then
+ LDFLAGS="$LDFLAGS -lnetwork"
+ fi
+
if [ "$os" = "SUNOS" ]; then
LDFLAGS="$LDFLAGS -lnsl -lsocket"
fi
@@ -1846,6 +1850,7 @@ detect_os() {
/hp-ux/ { print "HPUX"; exit}
/morphos/ { print "MORPHOS"; exit}
/beos/ { print "BEOS"; exit}
+ /haiku/ { print "HAIKU"; exit}
/sunos/ { print "SUNOS"; exit}
/solaris/ { print "SUNOS"; exit}
/cygwin/ { print "CYGWIN"; exit}
@@ -1866,6 +1871,7 @@ detect_os() {
/hp-ux/ { print "HPUX"; exit}
/morphos/ { print "MORPHOS"; exit}
/beos/ { print "BEOS"; exit}
+ /haiku/ { print "HAIKU"; exit}
/sunos/ { print "SUNOS"; exit}
/cygwin/ { print "CYGWIN"; exit}
/mingw/ { print "MINGW"; exit}
@@ -1876,7 +1882,7 @@ detect_os() {
if [ -z "$os" ]; then
log 1 "detecting OS... none detected"
log 1 "I couldn't detect your OS. Please use --os=OS to force one"
- log 1 "Allowed values are: UNIX, OSX, FREEBSD, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP"
+ log 1 "Allowed values are: UNIX, OSX, FREEBSD, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP"
exit 1
fi
@@ -2902,7 +2908,7 @@ showhelp() {
echo " --os=OS the OS we are compiling for [DETECT]"
echo " DETECT/UNIX/OSX/FREEBSD/OPENBSD/NETBSD/"
echo " MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
- echo " DOS/WINCE/PSP"
+ echo " DOS/WINCE/PSP/HAIKU"
echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)"
echo " --revision=rXXXX overwrite the revision detection."
echo " Use with care!"
diff --git a/configure b/configure
index 5085d214f..82ea1642b 100755
--- a/configure
+++ b/configure
@@ -115,9 +115,10 @@ AWKCOMMAND='
if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
if ($0 == "DOS" && "'$os'" != "DOS") { next; }
- if ($0 == "BEOS" && "'$os'" != "BEOS") { next; }
+ if ($0 == "BEOS" && "'$os'" != "BEOS" &&
+ "'$os'" != "HAIKU") { next; }
if ($0 == "WIN32" && "'$os'" != "MINGW" &&
- "'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next; }
+ "'$os'" != "CYGWIN" && "'$os'" != "MSVC") { next; }
if ($0 == "MORPHOS" && "'$os'" != "MORPHOS") { next; }
if ($0 == "WINCE" && "'$os'" != "WINCE") { next; }
if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
diff --git a/src/dedicated.cpp b/src/dedicated.cpp
index 47d98157d..bdfbf2c54 100644
--- a/src/dedicated.cpp
+++ b/src/dedicated.cpp
@@ -19,9 +19,11 @@
#include <unistd.h>
-#if defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)
+#if (defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)) || defined(__HAIKU__)
/* Solaris has, in certain situation, pid_t defined as long, while in other
- * cases it has it defined as int... this handles all cases nicely. */
+ * cases it has it defined as int... this handles all cases nicely.
+ * Haiku has also defined pid_t as a long.
+ */
# define PRINTF_PID_T "%ld"
#else
# define PRINTF_PID_T "%d"
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index 47dbd1f11..c0b32b3f0 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -279,6 +279,8 @@ void AskExitGame()
SetDParam(0, STR_OSNAME_OSX);
#elif defined(__BEOS__)
SetDParam(0, STR_OSNAME_BEOS);
+#elif defined(__HAIKU__)
+ SetDParam(0, STR_OSNAME_HAIKU);
#elif defined(__MORPHOS__)
SetDParam(0, STR_OSNAME_MORPHOS);
#elif defined(__AMIGA__)
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 3cd7ed36e..57288994d 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1344,6 +1344,7 @@ STR_OSNAME_DOS :DOS
STR_OSNAME_UNIX :Unix
STR_OSNAME_OSX :OS X
STR_OSNAME_BEOS :BeOS
+STR_OSNAME_HAIKU :Haiku
STR_OSNAME_MORPHOS :MorphOS
STR_OSNAME_AMIGAOS :AmigaOS
STR_OSNAME_OS2 :OS/2
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index ee9fcfe8f..d622e2e8c 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -30,9 +30,9 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // PS
{
}
-#elif defined(BEOS_NET_SERVER) /* doesn't have neither getifaddrs or net/if.h */
+#elif defined(BEOS_NET_SERVER) || defined(__HAIKU__) /* doesn't have neither getifaddrs or net/if.h */
/* Based on Andrew Bachmann's netstat+.c. Big thanks to him! */
-int _netstat(int fd, char **output, int verbose);
+extern "C" int _netstat(int fd, char **output, int verbose);
int seek_past_header(char **pos, const char *header)
{
@@ -63,9 +63,9 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // BE
char **output = &output_pointer;
if (seek_past_header(output, "IP Interfaces:") == B_OK) {
for (;;) {
- uint32 n, fields, read;
+ uint32 n;
+ int fields, read;
uint8 i1, i2, i3, i4, j1, j2, j3, j4;
- struct in_addr inaddr;
uint32 ip;
uint32 netmask;
@@ -85,7 +85,6 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // BE
((sockaddr_in*)&address)->sin_addr.s_addr = htonl(ip | ~netmask);
NetworkAddress addr(address, sizeof(sockaddr));
if (!broadcast->Contains(addr)) *broadcast->Append() = addr;
- index++;
}
if (read < 0) {
break;
diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h
index d9d046139..d0d7204f9 100644
--- a/src/network/core/os_abstraction.h
+++ b/src/network/core/os_abstraction.h
@@ -155,7 +155,7 @@ static inline void OTTDfreeaddrinfo(struct addrinfo *ai)
# include <arpa/inet.h>
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
-# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__INNOTEK_LIBC__) \
+# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__INNOTEK_LIBC__) \
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
@@ -185,6 +185,10 @@ static inline void OTTDfreeaddrinfo(struct addrinfo *ai)
typedef int socklen_t;
#endif
+#ifdef __HAIKU__
+ #define IPV6_V6ONLY 27
+#endif
+
#if defined(PSP)
# include <sys/socket.h>
# include <netinet/in.h>
diff --git a/src/stdafx.h b/src/stdafx.h
index 2dab7c0ae..4cbad1854 100644
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -16,15 +16,15 @@
#include "os/macosx/osx_stdafx.h"
#endif /* __APPLE__ */
-#if defined(__NDS__)
+#if defined(__BEOS__) || defined(__HAIKU__)
+ #include <SupportDefs.h>
+ #include <unistd.h>
+ #define _GNU_SOURCE
+ #define TROUBLED_INTS
+#elif defined(__NDS__)
#include <nds/jtypes.h>
- /* NDS' types for uint32/int32 are based on longs, which causes
- * trouble all over the place in OpenTTD. */
- #define uint32 uint32_ugly_hack
- #define int32 int32_ugly_hack
- typedef unsigned int uint32_ugly_hack;
- typedef signed int int32_ugly_hack;
-#endif /* __NDS__ */
+ #define TROUBLED_INTS
+#endif
/* It seems that we need to include stdint.h before anything else
* We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC
@@ -82,10 +82,6 @@
#include <pspthreadman.h>
#endif
-#if defined(__BEOS__)
- #include <SupportDefs.h>
-#endif
-
#if defined(SUNOS) || defined(HPUX)
#include <alloca.h>
#endif
@@ -282,11 +278,18 @@
typedef unsigned char byte;
/* This is already defined in unix, but not in QNX Neutrino (6.x)*/
-#if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
+#if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
typedef unsigned int uint;
#endif
-#if !defined(__BEOS__) && !defined(__NDS__) /* Already defined on BEOS and NDS */
+#if defined(TROUBLED_INTS)
+ /* NDS'/BeOS'/Haiku's types for uint32/int32 are based on longs, which causes
+ * trouble all over the place in OpenTTD. */
+ #define uint32 uint32_ugly_hack
+ #define int32 int32_ugly_hack
+ typedef unsigned int uint32_ugly_hack;
+ typedef signed int int32_ugly_hack;
+#else
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
@@ -295,7 +298,7 @@ typedef unsigned char byte;
typedef signed int int32;
typedef unsigned __int64 uint64;
typedef signed __int64 int64;
-#endif /* !__BEOS__ && !__NDS__ */
+#endif /* !TROUBLED_INTS */
#if !defined(WITH_PERSONAL_DIR)
#define PERSONAL_DIR ""