Changeset - r13095:c8ad2bbbdb3b
[Not reviewed]
master
0 8 0
rubidium - 15 years ago 2009-09-21 18:36:33
rubidium@openttd.org
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
8 files changed with 52 insertions and 34 deletions:
0 comments (0 inline, 0 general)
config.lib
Show inline comments
 
@@ -456,16 +456,16 @@ check_params() {
 
	fi
 
	if [ "$endian" = "PREPROCESSOR" ] && [ "$os" != "OSX" ]; then
 
		log 1 "configure: error: invalid option --endian=$endian"
 
		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
 
	if [ -z "`echo $cpu_type | egrep '^(32|64|DETECT)$'`" ]; then
 
		log 1 "configure: error: invalid option --cpu-type=$cpu_type"
 
		log 1 " Available options are: --cpu-type[=DETECT|32|64]"
 
@@ -1200,17 +1200,17 @@ make_cflags_and_ldflags() {
 
			if [ $cc_version -ge 44 ]; then
 
				LDFLAGS_BUILD="$LDFLAGS_BUILD -static-libgcc"
 
			fi
 
		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
 
		LIBS="$LIBS -lcoredll -lcorelibc -laygshell -lws2 -e WinMainCRTStartup"
 
	fi
 
	if [ "$os" = "PSP" ]; then
 
@@ -1244,18 +1244,18 @@ make_cflags_and_ldflags() {
 

	
 
		if [ "$cpu_type" = "64" ]; then
 
			CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
 
		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
 
	if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
 
		CFLAGS="$CFLAGS -DWIN"
 
	fi
 
@@ -1424,12 +1424,16 @@ make_cflags_and_ldflags() {
 
		CFLAGS="$CFLAGS -DENABLE_NETWORK"
 

	
 
		if [ "$os" = "BEOS" ]; then
 
			LDFLAGS="$LDFLAGS -lbind -lsocket"
 
		fi
 

	
 
		if [ "$os" = "HAIKU" ]; then
 
			LDFLAGS="$LDFLAGS -lnetwork"
 
		fi
 

	
 
		if [ "$os" = "SUNOS" ]; then
 
			LDFLAGS="$LDFLAGS -lnsl -lsocket"
 
		fi
 
	fi
 

	
 
	if [ "$enable_static" != "0" ]; then
 
@@ -1843,12 +1847,13 @@ detect_os() {
 
					/freebsd/      { print "FREEBSD"; exit}
 
					/openbsd/      { print "OPENBSD"; exit}
 
					/netbsd/       { print "NETBSD";  exit}
 
					/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}
 
					/mingw/        { print "MINGW";   exit}
 
					/os2/          { print "OS2";     exit}
 
					/dos/          { print "DOS";     exit}
 
@@ -1863,23 +1868,24 @@ detect_os() {
 
					/freebsd/      { print "FREEBSD"; exit}
 
					/openbsd/      { print "OPENBSD"; exit}
 
					/netbsd/       { print "NETBSD";  exit}
 
					/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}
 
					/os\/2/        { print "OS2";     exit}
 
			'`
 
		fi
 

	
 
		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
 

	
 
		log 1 "detecting OS... $os"
 
	else
 
		log 1 "forcing OS... $os"
 
@@ -2899,13 +2905,13 @@ showhelp() {
 
	echo "  --strip=STRIP                  the strip to use [HOST-strip]"
 
	echo "  --awk=AWK                      the awk to use in configure [awk]"
 
	echo "  --lipo=LIPO                    the lipo to use (OSX ONLY) [HOST-lipo]"
 
	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!"
 
	echo ""
 
	echo "Paths:"
 
	echo "  --prefix-dir=dir               specifies the prefix for all installed"
configure
Show inline comments
 
@@ -112,15 +112,16 @@ AWKCOMMAND='
 
		if ($0 == "OSX"         && "'$os'" != "OSX")               { next; }
 
		if ($0 == "OS2"         && "'$os'" != "OS2")               { next; }
 
		if ($0 == "PSP"         && "'$os'" != "PSP")               { next; }
 
		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; }
 
		if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0")  { next; }
 
		if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" )        { next; }
 
		if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0")       { next; }
src/dedicated.cpp
Show inline comments
 
@@ -16,15 +16,17 @@
 
#if defined(UNIX) && !defined(__MORPHOS__)
 

	
 
#include "variables.h"
 

	
 
#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"
 
#endif
 

	
 
void DedicatedFork()
src/intro_gui.cpp
Show inline comments
 
@@ -276,12 +276,14 @@ void AskExitGame()
 
#if defined(_WIN32)
 
		SetDParam(0, STR_OSNAME_WINDOWS);
 
#elif defined(__APPLE__)
 
		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__)
 
		SetDParam(0, STR_OSNAME_AMIGAOS);
 
#elif defined(__OS2__)
 
		SetDParam(0, STR_OSNAME_OS2);
src/lang/english.txt
Show inline comments
 
@@ -1341,12 +1341,13 @@ STR_QUIT_NO                             
 
# Supported OSes
 
STR_OSNAME_WINDOWS                                              :Windows
 
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
 
STR_OSNAME_SUNOS                                                :SunOS
 

	
 
# Abandon game
src/network/core/host.cpp
Show inline comments
 
@@ -27,15 +27,15 @@ static void NetworkFindBroadcastIPsInter
 

	
 
#if defined(PSP)
 
static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // PSP implementation
 
{
 
}
 

	
 
#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)
 
{
 
	char *new_pos = strstr(*pos, header);
 
	if (new_pos == 0) {
 
		return B_ERROR;
 
@@ -60,15 +60,15 @@ static void NetworkFindBroadcastIPsInter
 
		return;
 
	}
 

	
 
	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;
 

	
 
			fields = sscanf(*output, "%u: %hhu.%hhu.%hhu.%hhu, netmask %hhu.%hhu.%hhu.%hhu%n",
 
												&n, &i1, &i2, &i3, &i4, &j1, &j2, &j3, &j4, &read);
 
			read += 1;
 
@@ -82,13 +82,12 @@ static void NetworkFindBroadcastIPsInter
 
			if (ip != INADDR_LOOPBACK && ip != INADDR_ANY) {
 
				sockaddr_storage address;
 
				memset(&address, 0, sizeof(address));
 
				((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;
 
			}
 
			*output += read;
 
		}
src/network/core/os_abstraction.h
Show inline comments
 
@@ -152,13 +152,13 @@ static inline void OTTDfreeaddrinfo(stru
 
#		include <sys/socket.h>
 
#		include <netinet/in.h>
 
#		include <netinet/tcp.h>
 
#		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
 
 *   the list of IPs from the system. */
 
#			include <ifaddrs.h>
 
#			define HAVE_GETIFADDRS
 
@@ -182,12 +182,16 @@ static inline void OTTDfreeaddrinfo(stru
 
#endif /* UNIX */
 

	
 
#ifdef __BEOS__
 
	typedef int socklen_t;
 
#endif
 

	
 
#ifdef __HAIKU__
 
	#define IPV6_V6ONLY 27
 
#endif
 

	
 
#if defined(PSP)
 
#	include <sys/socket.h>
 
#	include <netinet/in.h>
 
#	include <arpa/inet.h>
 
#	include <pspnet.h>
 
#	include <pspnet_inet.h>
src/stdafx.h
Show inline comments
 
@@ -13,21 +13,21 @@
 
#define STDAFX_H
 

	
 
#if defined(__APPLE__)
 
	#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
 
 * does not have stdint.h and apparently neither does MorphOS, so define
 
 * INT64_MAX for them ourselves. */
 
#if defined(__APPLE__)
 
@@ -79,16 +79,12 @@
 
#if defined(PSP)
 
	#include <psptypes.h>
 
	#include <pspdebug.h>
 
	#include <pspthreadman.h>
 
#endif
 

	
 
#if defined(__BEOS__)
 
	#include <SupportDefs.h>
 
#endif
 

	
 
#if defined(SUNOS) || defined(HPUX)
 
	#include <alloca.h>
 
#endif
 

	
 
#if defined(__MORPHOS__)
 
	/* MorphOS defines certain Amiga defines per default, we undefine them
 
@@ -279,26 +275,33 @@
 
	#define PRINTF_SIZE "%zu"
 
#endif
 

	
 
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;
 
	typedef   signed short    int16;
 
	typedef unsigned int     uint32;
 
	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 ""
 
#endif
 

	
 
/* Compile time assertions. Prefer c++0x static_assert() */
0 comments (0 inline, 0 general)