Celestia: fix build

This commit is contained in:
Gerasim Troeglazov
2018-09-16 14:20:32 +10:00
parent 683099f64a
commit 123a7005c0
4 changed files with 449 additions and 137 deletions

View File

@@ -1,121 +0,0 @@
diff -Naur celestia-1.6.0/configure.in celestia-1.6.0-haiku/configure.in
--- celestia-1.6.0/configure.in 2009-06-22 15:52:39.019660800 +0000
+++ celestia-1.6.0-haiku/configure.in 2010-08-12 23:41:43.749469696 +0000
@@ -193,7 +193,7 @@
AM_CONDITIONAL(ENABLE_SPICE, test "$SPICELIB" != "")
-LIBS="$LIBS -lm"
+LIBS="$LIBS -lintl"
dnl Use Gtk if requested
GTK_LIBS=""
@@ -237,7 +237,7 @@
CFLAGS="$CFLAGS $CELESTIAFLAGS $CELESTIA_CFLAGS"
CXXFLAGS="$CXXFLAGS $CELESTIAFLAGS $CELESTIA_CXXFLAGS"
LIBS="$LIBS $CELESTIALIBS"
-LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lXmu -lXi -lXext -lX11 -lm -lz $X_EXTRA_LIBS"
+LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lz $X_EXTRA_LIBS"
dnl Check for zlib -- libGL requires it.
AC_CHECK_LIB(z, deflate, ,
diff -Naur celestia-1.6.0/data/Makefile.am celestia-1.6.0-haiku/data/Makefile.am
--- celestia-1.6.0/data/Makefile.am 2009-06-22 15:48:06.024903680 +0000
+++ celestia-1.6.0-haiku/data/Makefile.am 2010-08-12 23:56:00.052428800 +0000
@@ -15,8 +15,7 @@
$(wildcard *.xyz) \
$(wildcard *.xyzv) \
$(wildcard *.dsc) \
- $(wildcard *.stc) \
- stars.dat
+ $(wildcard *.stc)
EXTRA_DIST = \
$(pkgdata_DATA) \
diff -Naur celestia-1.6.0/src/celengine/astro.cpp celestia-1.6.0-haiku/src/celengine/astro.cpp
--- celestia-1.6.0/src/celengine/astro.cpp 2009-06-22 15:44:08.046137344 +0000
+++ celestia-1.6.0-haiku/src/celengine/astro.cpp 2010-08-12 19:00:33.000000000 +0000
@@ -522,7 +522,7 @@
cal_time.tm_sec = (int)seconds;
cal_time.tm_wday = wday;
cal_time.tm_gmtoff = utc_offset;
-#if defined(TARGET_OS_MAC) || defined(__FreeBSD__)
+#if defined(TARGET_OS_MAC) || defined(__FreeBSD__) || defined(__HAIKU__)
// tm_zone is a non-const string field on the Mac and FreeBSD (why?)
cal_time.tm_zone = const_cast<char*>(tzname.c_str());
#else
diff -Naur celestia-1.6.0/src/celengine/glext.cpp celestia-1.6.0-haiku/src/celengine/glext.cpp
--- celestia-1.6.0/src/celengine/glext.cpp 2009-06-22 15:44:08.049020928 +0000
+++ celestia-1.6.0-haiku/src/celengine/glext.cpp 2010-08-12 19:07:19.000000000 +0000
@@ -12,10 +12,10 @@
#ifndef _WIN32
// Assume that this is a UNIX/X11 system if it's not Windows or Mac OS X.
-#ifndef TARGET_OS_MAC
+#if !defined(TARGET_OS_MAC) && !defined(__HAIKU__)
#include "GL/glx.h"
#include <dlfcn.h>
-#endif /* ! TARGET_OS_MAC */
+#endif /* ! TARGET_OS_MAC || HAIKU */
#endif /* ! _WIN32 */
#include "glext.h"
@@ -306,7 +306,7 @@
#else
-#ifndef TARGET_OS_MAC
+#if !defined(TARGET_OS_MAC) && !defined(__HAIKU__)
#if defined(_WIN32)
#define GET_GL_PROC_ADDRESS(name) wglGetProcAddress(name)
@@ -692,9 +692,11 @@
static void InitExt_GLX_SGI_video_sync()
{
+#if defined(GET_GL_PROC_ADDRESS)
glx::glXGetVideoSyncSGI = (glx::PFNGLXGETVIDEOSYNCSGIPROC) GET_GL_PROC_ADDRESS("glXGetVideoSyncSGI");
glx::glXWaitVideoSyncSGI = (glx::PFNGLXWAITVIDEOSYNCSGIPROC) GET_GL_PROC_ADDRESS("glXWaitVideoSyncSGI");
glx::glXGetRefreshRateSGI = (glx::PFNGLXGETREFRESHRATESGIPROC) GET_GL_PROC_ADDRESS("glXGetRefreshRateSGI");
+#endif
}
diff -Naur celestia-1.6.0/src/celengine/image.cpp celestia-1.6.0-haiku/src/celengine/image.cpp
--- celestia-1.6.0/src/celengine/image.cpp 2009-06-22 15:44:08.049545216 +0000
+++ celestia-1.6.0-haiku/src/celengine/image.cpp 2010-08-12 19:09:42.000000000 +0000
@@ -737,7 +737,7 @@
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
{
- png_set_gray_1_2_4_to_8(png_ptr);
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
}
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
diff -Naur celestia-1.6.0/src/celutil/unixdirectory.cpp celestia-1.6.0-haiku/src/celutil/unixdirectory.cpp
--- celestia-1.6.0/src/celutil/unixdirectory.cpp 2009-06-22 15:44:24.030408704 +0000
+++ celestia-1.6.0-haiku/src/celutil/unixdirectory.cpp 2010-08-12 18:58:58.000000000 +0000
@@ -11,19 +11,19 @@
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
+#if !defined(__HAIKU__)
#include <wordexp.h>
+#endif
#include "directory.h"
using namespace std;
-#ifdef TARGET_OS_MAC
-#ifdef QT_CORE_LIB
+#if defined(__HAIKU__) || defined(TARGET_OS_MAC) && defined(QT_CORE_LIB)
// Crash on Mac OS X / Qt4 version when calling wordfree.
// This seems to happen only with Leopard.
#define WORDEXP_PROBLEM
#endif
-#endif
class UnixDirectory : public Directory
{

View File

@@ -0,0 +1,283 @@
From 920f812d2f38ff96c703dd24ea6779e9766e67d9 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 15 Sep 2018 22:09:15 +1000
Subject: Fix build for haiku
diff --git a/src/celengine/astro.cpp b/src/celengine/astro.cpp
index 989dead..bc2b52f 100644
--- a/src/celengine/astro.cpp
+++ b/src/celengine/astro.cpp
@@ -522,7 +522,7 @@ const char* astro::Date::toCStr(Format format) const
cal_time.tm_sec = (int)seconds;
cal_time.tm_wday = wday;
cal_time.tm_gmtoff = utc_offset;
-#if defined(TARGET_OS_MAC) || defined(__FreeBSD__)
+#if defined(TARGET_OS_MAC) || defined(__FreeBSD__) || defined(__HAIKU__)
// tm_zone is a non-const string field on the Mac and FreeBSD (why?)
cal_time.tm_zone = const_cast<char*>(tzname.c_str());
#else
diff --git a/src/celengine/glext.cpp b/src/celengine/glext.cpp
index 0f04423..5326029 100644
--- a/src/celengine/glext.cpp
+++ b/src/celengine/glext.cpp
@@ -12,10 +12,10 @@
#ifndef _WIN32
// Assume that this is a UNIX/X11 system if it's not Windows or Mac OS X.
-#ifndef TARGET_OS_MAC
+#if !defined(TARGET_OS_MAC) && !defined(__HAIKU__)
#include "GL/glx.h"
#include <dlfcn.h>
-#endif /* ! TARGET_OS_MAC */
+#endif /* ! TARGET_OS_MAC || HAIKU */
#endif /* ! _WIN32 */
#include "glext.h"
@@ -306,7 +306,7 @@ extern QGLContext* glctx;
#else
-#ifndef TARGET_OS_MAC
+#if !defined(TARGET_OS_MAC) && !defined(__HAIKU__)
#if defined(_WIN32)
#define GET_GL_PROC_ADDRESS(name) wglGetProcAddress(name)
@@ -692,9 +692,11 @@ static void InitExt_EXT_swap_control()
static void InitExt_GLX_SGI_video_sync()
{
+#if defined(GET_GL_PROC_ADDRESS)
glx::glXGetVideoSyncSGI = (glx::PFNGLXGETVIDEOSYNCSGIPROC) GET_GL_PROC_ADDRESS("glXGetVideoSyncSGI");
glx::glXWaitVideoSyncSGI = (glx::PFNGLXWAITVIDEOSYNCSGIPROC) GET_GL_PROC_ADDRESS("glXWaitVideoSyncSGI");
glx::glXGetRefreshRateSGI = (glx::PFNGLXGETREFRESHRATESGIPROC) GET_GL_PROC_ADDRESS("glXGetRefreshRateSGI");
+#endif
}
diff --git a/src/celutil/unixdirectory.cpp b/src/celutil/unixdirectory.cpp
index 9a1b054..dda19e0 100644
--- a/src/celutil/unixdirectory.cpp
+++ b/src/celutil/unixdirectory.cpp
@@ -11,19 +11,19 @@
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
+#if !defined(__HAIKU__)
#include <wordexp.h>
+#endif
#include "directory.h"
using namespace std;
-#ifdef TARGET_OS_MAC
-#ifdef QT_CORE_LIB
+#if defined(__HAIKU__) || defined(TARGET_OS_MAC) && defined(QT_CORE_LIB)
// Crash on Mac OS X / Qt4 version when calling wordfree.
// This seems to happen only with Leopard.
#define WORDEXP_PROBLEM
#endif
-#endif
class UnixDirectory : public Directory
{
--
2.19.0
From de882a7f5ff40f9367dc7c8b8f5bfb06c4b9623e Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 15 Sep 2018 22:31:57 +1000
Subject: Add missing headers
diff --git a/src/celengine/image.cpp b/src/celengine/image.cpp
index a36b9c1..3f94565 100644
--- a/src/celengine/image.cpp
+++ b/src/celengine/image.cpp
@@ -67,6 +67,10 @@ extern "C" {
#include <algorithm>
#include <cmath>
+#ifdef __HAIKU__
+#include <string.h>
+#endif
+
using namespace std;
diff --git a/src/celengine/texture.cpp b/src/celengine/texture.cpp
index 0775204..5500143 100644
--- a/src/celengine/texture.cpp
+++ b/src/celengine/texture.cpp
@@ -29,6 +29,10 @@
#include <cstdio>
#include <cassert>
+#ifdef __HAIKU__
+#include <string.h>
+#endif
+
#ifndef _WIN32
#ifndef TARGET_OS_MAC
#include <config.h>
--
2.19.0
From 7efacb288eb0d6d6f26c8225b4f66f9150be1f1c Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 15 Sep 2018 22:55:24 +1000
Subject: Add missing header
diff --git a/src/celmath/intersect.h b/src/celmath/intersect.h
index 38fb01f..44791ff 100644
--- a/src/celmath/intersect.h
+++ b/src/celmath/intersect.h
@@ -15,7 +15,7 @@
#include "ray.h"
#include "sphere.h"
#include "ellipsoid.h"
-
+#include "mathlib.h"
template<class T> bool testIntersection(const Ray3<T>& ray,
const Sphere<T>& sphere,
--
2.19.0
From ef4cc25bf26d4584a599f5c69cde50673c61e8aa Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 15 Sep 2018 23:47:31 +1000
Subject: Fix for png16
diff --git a/src/celestia/imagecapture.cpp b/src/celestia/imagecapture.cpp
index 92602da..c2c2520 100644
--- a/src/celestia/imagecapture.cpp
+++ b/src/celestia/imagecapture.cpp
@@ -181,7 +181,7 @@ bool CaptureGLBufferToPNG(const string& filename,
// png_init_io(png_ptr, out);
png_set_write_fn(png_ptr, (void*) out, PNGWriteData, NULL);
- png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
+ png_set_compression_level(png_ptr, PNG_Z_DEFAULT_COMPRESSION);
png_set_IHDR(png_ptr, info_ptr,
width, height,
8,
--
2.19.0
From ff3d1c6e61a926febd23a3ca1966d3d2242a491f Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 16 Sep 2018 13:12:37 +1000
Subject: Disable GLSL shaders. Add window size and position for Haiku.
diff --git a/src/celestia/glutmain.cpp b/src/celestia/glutmain.cpp
index 4b14167..9c1ed7f 100644
--- a/src/celestia/glutmain.cpp
+++ b/src/celestia/glutmain.cpp
@@ -24,6 +24,9 @@
#include <Carbon/Carbon.h>
#include <GLUT/glut.h>
#endif
+#ifdef __HAIKU__
+#include <Screen.h>
+#endif
#include <celengine/celestia.h>
#include <celmath/vecmath.h>
#include <celmath/quaternion.h>
@@ -432,12 +435,13 @@ static void dirFixup(char *argv0) {
int main(int argc, char* argv[])
{
+#ifndef __HAIKU__
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
-
+#endif
#ifdef MACOSX
#define BUNDLEONLY 1
#ifndef BUNDLEONLY
@@ -495,12 +499,27 @@ int main(int argc, char* argv[])
}
glutInit(&argc, argv);
+#ifdef __HAIKU__
+ BScreen screen(B_MAIN_SCREEN_ID);
+ int screenWidth = screen.Frame().Width();
+ int screenHeight = screen.Frame().Height();
+ int winWidth = screenWidth >= 1024 ? 800 : 640;
+ int winHeight = screenHeight >= 768 ? 600 : 480;
+ int winPosX = (screenWidth - winWidth ) / 2;
+ int winPosY = (screenHeight - winHeight ) / 2;
+ glutInitWindowSize(winWidth, winHeight);
+ glutInitWindowPosition(winPosX, winPosY);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ mainWindow = glutCreateWindow("Celestia");
+ Resize(winWidth, winHeight);
+#else
glutInitWindowSize(480, 360);
glutInitWindowPosition(0, 0);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
mainWindow = glutCreateWindow("Celestia");
Resize(480, 360);
+#endif
glutReshapeFunc(Resize);
glutDisplayFunc(Display);
glutIdleFunc(Idle);
@@ -517,7 +536,9 @@ int main(int argc, char* argv[])
// GL should be all set up, now initialize the renderer.
appCore->initRenderer();
-
+#ifdef __HAIKU__
+ appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_Basic);
+#endif
// Set the simulation starting time to the current system time
time_t curtime=time(NULL);
appCore->start((double) curtime / 86400.0 + (double) astro::Date(1970, 1, 1));
--
2.19.0
From 5977aaeb2572e274b0295cfe65546ecf430cf0ba Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 16 Sep 2018 13:34:04 +1000
Subject: Use system type defs
diff --git a/src/celutil/basictypes.h b/src/celutil/basictypes.h
index 560b39b..e2200c6 100644
--- a/src/celutil/basictypes.h
+++ b/src/celutil/basictypes.h
@@ -13,13 +13,16 @@
typedef unsigned int uint;
// Fixed size types
+#ifdef __HAIKU__
+#include <SupportDefs.h>
+#else
typedef int int32;
typedef unsigned int uint32;
typedef short int16;
typedef unsigned short uint16;
typedef char int8;
typedef unsigned char uint8;
-
+#endif
#ifdef _MSC_VER
// MS Visual C++ does not include stdint.h
typedef __int64 int64;
--
2.19.0