]> git.mxchange.org Git - flightgear.git/commitdiff
Changes to get FlightGear (well, the src directory at least) to
authorandy <andy>
Fri, 30 Apr 2004 00:52:11 +0000 (00:52 +0000)
committerandy <andy>
Fri, 30 Apr 2004 00:52:11 +0000 (00:52 +0000)
configure and compile out-of-the-box on a MinGW target:

Use -lSDL instead of -lglut32 on windows builds when --enable-sdl
is set.

Link against alut.dll in addition to openal32.dll.

Replace BSD bcopy() with ANSI C memmove() in a few places.  This is
simpler than trying to abstract it out as a platform dependency in a
header file; bcopy() has never been standard.

The ENABLE_THREADS handling has changed to be set to 0 when threads
are not in use.  This breaks expressions like #ifdef ENABLE_THREADS.
Replace with a slightly more complicated expression.  It might have
been better to fix the configure.ac script, but I didn't know how and
this whole setting is likely to go away soon anyway.

The MinGW C runtime actually does include snprintf, so only MSVC
builds (and not all WIN32 ones) need _snprintf in JSBSim/FGState.cpp

Building on a platform with no glut at all exposed some spots where
plib/pu.h was being included without a toolkit setting (it defaults to
glut).  Include fg_os.hxx first.

And when still using glut, glut.h has a bizarre dependency on a
_WCHAR_T_DEFINED symbol.  It it's not defined, it tries to redefine
(!!) wchar_t to disasterous effect.

14 files changed:
configure.ac
src/ATC/tower.cxx
src/ATC/transmissionlist.cxx
src/Environment/environment_ctrl.cxx
src/Environment/environment_ctrl.hxx
src/FDM/JSBSim/FGState.cpp
src/GUI/menubar.cxx
src/GUI/new_gui.hxx
src/GUI/puList.hxx
src/Main/fg_os.cxx
src/Scenery/FGTileLoader.cxx
src/Scenery/FGTileLoader.hxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx

index 58512e87be0c9ce26ee40496605bc55b154e1475..28fabcf865a49a6ab163801fd2062410c75d2550 100644 (file)
@@ -73,7 +73,7 @@ dnl Thread related checks
 # defaults to yes
 with_threads=yes
 AC_ARG_WITH(threads, [  --with-threads          Include tile loading threads [default=yes]])
-if test "x$with_threads" = "xno"; then
+if test "x$with_threads" != "xyes"; then
     AC_DEFINE([ENABLE_THREADS], 0, [Define to enable threaded tile paging])
 else
     AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
@@ -252,8 +252,13 @@ case "${host}" in
     AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
     AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
 
-    LIBS="$LIBS -lglut32 -lglu32 -lopengl32"
-    LIBS="$LIBS -luser32 -lgdi32"
+    if test "x$enable_sdl" = "xyes"; then
+        AC_SEARCH_LIBS(SDL_Init, SDL)
+    else
+        LIBS="$LIBS -lglut32"
+    fi
+
+    LIBS="$LIBS -lglu32 -lopengl32 -luser32 -lgdi32"
 
     dnl add -lwsock32 for mingwin
     case "${host}" in
@@ -319,7 +324,7 @@ case "${host}" in
 *-*-cygwin* | *-*-mingw32*)
     dnl CygWin under Windoze.
 
-    LIBS="$LIBS -lopenal32 -lwinmm -ldsound -ldxguid -lole32"
+    LIBS="$LIBS -lalut -lopenal32 -lwinmm -ldsound -ldxguid -lole32"
     ;;
 
 *-apple-darwin*)
index bbfbf7b0ae1e9db7744d20cf2fabd638f43872ca..05f09e0b20dea9a835ea0a244086de43313eb37b 100644 (file)
@@ -2272,7 +2272,7 @@ string FGTower::GenText(const string& m, int c) {
                        int check = 0;  // If mes gets overflowed the while loop can go infinite
                        while ( strchr(&mes[0], crej) != NULL  ) {      // ie. loop until no more occurances of crej ('@') found
                                pos = strchr( &mes[0], crej );
-                               bcopy(pos, &tag[0], 3);
+                               memmove(&tag[0], pos, 3);
                                tag[3] = '\0';
                                int i;
                                len = 0;
index c8a8f5f66cfb16301c1ec815589fb83940641be0..ed6aa72776a1fa91ab05cce6dfd05870d2f7508f 100644 (file)
@@ -174,7 +174,7 @@ string FGTransmissionList::gen_text(const atc_type &station, const TransCode cod
                        int check = 0;  // If mes gets overflowed the while loop can go infinite
                        while ( strchr(&mes[0], crej) != NULL  ) {      // ie. loop until no more occurances of crej ('@') found
                                pos = strchr( &mes[0], crej );
-                               bcopy(pos, &tag[0], 3);
+                               memmove(&tag[0], pos, 3);
                                tag[3] = '\0';
                                int i;
                                len = 0;
index 8ba39a5ff3b56f35cd589d1cd66c8d80bf4c9ada..01b1285632ec8fec88f74ffc8c2713638ac929e4 100644 (file)
@@ -325,7 +325,7 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
       proxy_port( fgGetNode("/sim/presets/proxy/port", true) ),
       proxy_auth( fgGetNode("/sim/presets/proxy/authentication", true) )
 {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     thread = new MetarThread(this);
     thread->start();
 #endif // ENABLE_THREADS
@@ -333,7 +333,7 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
 
 FGMetarEnvironmentCtrl::~FGMetarEnvironmentCtrl ()
 {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
    thread->cancel();
    thread->join();
 #endif // ENABLE_THREADS
@@ -461,7 +461,7 @@ FGMetarEnvironmentCtrl::update(double delta_time_sec)
         }
     }
 
-#ifndef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // No loader thread running so manually fetch the data
     string id = "";
     while ( !request_queue.empty() ) {
@@ -643,7 +643,7 @@ FGMetarEnvironmentCtrl::update_metar_properties( SGMetar *m )
 }
 
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 /**
  *
  */
index 054a0a2f9ec3577d35c12183adb04713f6e0a6ae..d0aabc3a16f09b9474c40e0bb2ff5e9dd5d3024c 100644 (file)
@@ -27,7 +27,7 @@
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/environment/metar.hxx>
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 # include <simgear/threads/SGThread.hxx>
 # include <simgear/threads/SGQueue.hxx>
 #endif
@@ -183,7 +183,7 @@ private:
 
 private:
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     /**
      * FIFO queue which holds a pointer to the fetched metar data.
      */
@@ -205,7 +205,7 @@ private:
     queue < FGMetarResult > result_queue;
 #endif
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     /**
      * This class represents the thread of execution responsible for
      * fetching the metar data.
index 5f8a4ddd8af070aa15f27a12644bae5c922c6fed..6144d7eea61cc31932ab34e6dd2650cee6c99a0c 100644 (file)
@@ -47,7 +47,7 @@ INCLUDES
 #  endif
 #endif
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 #define snprintf _snprintf
 #endif
 
index 083d3cf5c3b25daab0c0fd68a2a2edffcfe26a66..4f6193693a3df9baf30fca2d0750e9869d7767ac 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <string.h>
 #include <iostream>
-
+#include <Main/fg_os.hxx> // To set toolkit for pu.h
 #include <plib/pu.h>
 #include <simgear/debug/logstream.hxx>
 
index 6e96a5aa060778a16902cbf9b205aef63219254c..49d4fe94c6b7f017ad3e95dd2fe15e8c49a4bee6 100644 (file)
@@ -11,6 +11,7 @@
 #  include <config.h>
 #endif
 
+#include <Main/fg_os.hxx>
 #include <plib/pu.h>
 
 #include <simgear/compiler.h>  // for SG_USING_STD
index 563763a0b0eaf0fc79a6f0a238e4071dd875da36..64489b8106717fe0eaf7eda29635bc34afd59836 100644 (file)
@@ -7,6 +7,7 @@
 #  include <config.h>
 #endif
 
+#include <Main/fg_os.hxx> // To set toolkit for pu.h
 #include <plib/pu.h>
 
 
index beaea1bee11a925e86549d44c7be17c5614b557f..57f5cbc4b069963d60edf26bc6b3f33c9cd5e62c 100644 (file)
@@ -1,5 +1,7 @@
 // The mac puts this in a weird location (GLUT/glut.h), so the
 // configure script detects the location and defines it as a macro.
+#define _WCHAR_T_DEFINED 1 // Glut needs this, or else it tries to
+                           // redefine it
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #  include FG_GLUT_H
index 391a81c1cea0a26ecd48f4c86f3369b251e1c25b..95bd81e3a9ea572c41f6558b4e6fdd064867c784 100644 (file)
@@ -40,7 +40,7 @@ extern ssgBranch *ground;
  */
 FGTileLoader::FGTileLoader()
 {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // Create and start the loader threads.
     for (int i = 0; i < MAX_THREADS; ++i)
     {
@@ -55,7 +55,7 @@ FGTileLoader::FGTileLoader()
  */
 FGTileLoader::~FGTileLoader()
 {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // Wake up its time to die.
     // queue_cond.broadcast();
 
@@ -125,7 +125,7 @@ void
 FGTileLoader::update()
 {
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // send a signal to the pager thread that it is allowed to load
     // another tile
     mutex.lock();
@@ -159,7 +159,7 @@ FGTileLoader::update()
 }
 
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 /**
  * 
  */
index 74e465f84b3c6dd0525d827ac9c6110b04868365..54e8be927e5f2ecd4be743f9981a7f0254cd7ec1 100644 (file)
@@ -27,7 +27,7 @@
 #include <simgear/bucket/newbucket.hxx>
 #include <simgear/misc/sg_path.hxx>
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 #  include <simgear/threads/SGThread.hxx>
 #  include <simgear/threads/SGQueue.hxx>
 #else
@@ -97,7 +97,7 @@ private:
 
 private:
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     /**
      * FIFO queue of tiles to load from data files.
      */
@@ -113,7 +113,7 @@ private:
      */
     string tile_path;
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     /**
      * Maximum number of threads to create for loading tiles.
      */
index c7da20b2c45430a01c03e253aa14ff895d2b2619..371b45eafac559bb72fc1859b86c6c3cc9f83af1 100644 (file)
@@ -46,7 +46,7 @@
 
 #define TEST_LAST_HIT_CACHE
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 SGLockedQueue<FGTileEntry *> FGTileMgr::attach_queue;
 SGLockedQueue<FGDeferredModel *> FGTileMgr::model_queue;
 #else
@@ -90,7 +90,7 @@ int FGTileMgr::init() {
     }
 
     while ( ! model_queue.empty() ) {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
         FGDeferredModel* dm = model_queue.pop();
 #else
         FGDeferredModel* dm = model_queue.front();
@@ -275,7 +275,7 @@ void FGTileMgr::update_queues()
     if ( !model_queue.empty() ) {
         // cout << "loading next model ..." << endl;
         // load the next tile in the queue
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
         FGDeferredModel* dm = model_queue.pop();
 #else
         FGDeferredModel* dm = model_queue.front();
@@ -314,7 +314,7 @@ void FGTileMgr::update_queues()
     }
 
     if ( !attach_queue.empty() ) {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
         FGTileEntry* e = attach_queue.pop();
 #else
         FGTileEntry* e = attach_queue.front();
index b5bd427a41cffb7afba2c332b2762a2c2c3f2c8b..e67a761bfabc128503a87f04f3afc5ba77b16375 100644 (file)
@@ -38,7 +38,7 @@
 #include <plib/ssg.h>
 
 #include <simgear/bucket/newbucket.hxx>
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 #  include <simgear/threads/SGQueue.hxx>
 #endif // ENABLE_THREADS
 
@@ -119,7 +119,7 @@ private:
      * model_queue is the set of models that need to be loaded by the
      * primary render thread.
      */
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     static SGLockedQueue<FGTileEntry *> attach_queue;
     static SGLockedQueue<FGDeferredModel *> model_queue;
 #else