From: andy Date: Fri, 30 Apr 2004 00:52:11 +0000 (+0000) Subject: Changes to get FlightGear (well, the src directory at least) to X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7ceb85d454363d5490383874c7918875871308a1;p=flightgear.git Changes to get FlightGear (well, the src directory at least) to 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. --- diff --git a/configure.ac b/configure.ac index 58512e87b..28fabcf86 100644 --- a/configure.ac +++ b/configure.ac @@ -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*) diff --git a/src/ATC/tower.cxx b/src/ATC/tower.cxx index bbfbf7b0a..05f09e0b2 100644 --- a/src/ATC/tower.cxx +++ b/src/ATC/tower.cxx @@ -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; diff --git a/src/ATC/transmissionlist.cxx b/src/ATC/transmissionlist.cxx index c8a8f5f66..ed6aa7277 100644 --- a/src/ATC/transmissionlist.cxx +++ b/src/ATC/transmissionlist.cxx @@ -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; diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index 8ba39a5ff..01b128563 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -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 /** * */ diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index 054a0a2f9..d0aabc3a1 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -27,7 +27,7 @@ #include #include -#ifdef ENABLE_THREADS +#if defined(ENABLE_THREADS) && ENABLE_THREADS # include # include #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. diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp index 5f8a4ddd8..6144d7eea 100644 --- a/src/FDM/JSBSim/FGState.cpp +++ b/src/FDM/JSBSim/FGState.cpp @@ -47,7 +47,7 @@ INCLUDES # endif #endif -#ifdef _WIN32 +#ifdef _MSC_VER #define snprintf _snprintf #endif diff --git a/src/GUI/menubar.cxx b/src/GUI/menubar.cxx index 083d3cf5c..4f6193693 100644 --- a/src/GUI/menubar.cxx +++ b/src/GUI/menubar.cxx @@ -4,7 +4,7 @@ #include #include - +#include
// To set toolkit for pu.h #include #include diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 6e96a5aa0..49d4fe94c 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -11,6 +11,7 @@ # include #endif +#include
#include #include // for SG_USING_STD diff --git a/src/GUI/puList.hxx b/src/GUI/puList.hxx index 563763a0b..64489b810 100644 --- a/src/GUI/puList.hxx +++ b/src/GUI/puList.hxx @@ -7,6 +7,7 @@ # include #endif +#include
// To set toolkit for pu.h #include diff --git a/src/Main/fg_os.cxx b/src/Main/fg_os.cxx index beaea1bee..57f5cbc4b 100644 --- a/src/Main/fg_os.cxx +++ b/src/Main/fg_os.cxx @@ -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 # include FG_GLUT_H diff --git a/src/Scenery/FGTileLoader.cxx b/src/Scenery/FGTileLoader.cxx index 391a81c1c..95bd81e3a 100644 --- a/src/Scenery/FGTileLoader.cxx +++ b/src/Scenery/FGTileLoader.cxx @@ -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 /** * */ diff --git a/src/Scenery/FGTileLoader.hxx b/src/Scenery/FGTileLoader.hxx index 74e465f84..54e8be927 100644 --- a/src/Scenery/FGTileLoader.hxx +++ b/src/Scenery/FGTileLoader.hxx @@ -27,7 +27,7 @@ #include #include -#ifdef ENABLE_THREADS +#if defined(ENABLE_THREADS) && ENABLE_THREADS # include # include #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. */ diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index c7da20b2c..371b45eaf 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -46,7 +46,7 @@ #define TEST_LAST_HIT_CACHE -#ifdef ENABLE_THREADS +#if defined(ENABLE_THREADS) && ENABLE_THREADS SGLockedQueue FGTileMgr::attach_queue; SGLockedQueue 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(); diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index b5bd427a4..e67a761bf 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -38,7 +38,7 @@ #include #include -#ifdef ENABLE_THREADS +#if defined(ENABLE_THREADS) && ENABLE_THREADS # include #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 attach_queue; static SGLockedQueue model_queue; #else