From 83902caafafc505441af2d94b637835248190980 Mon Sep 17 00:00:00 2001 Date: Fri, 12 Aug 2016 21:42:06 +0200 Subject: [PATCH] FIX: Compiling on Mac OS X (clang llvm 7.3.0) --- Makefile | 15 ++++++++++++--- OSX/getversion.cc | 2 +- OSX/plistgen.sh | 0 boden/grund.cc | 8 ++++---- freight_list_sorter.cc | 4 +++- gui/banner.cc | 2 +- gui/simwin.cc | 2 +- music/core-audio_midi.mm | 2 +- simsys_opengl.cc | 28 +++++++++++++++++++++++++--- 9 files changed, 48 insertions(+), 15 deletions(-) mode change 100644 => 100755 OSX/plistgen.sh diff --git a/Makefile b/Makefile index 6ad8e25..83b73dd 100755 --- a/Makefile +++ b/Makefile @@ -65,6 +65,11 @@ else SOURCES += clipboard_internal.cc endif +ifeq ($(OSTYPE),mac) + CFLAGS += -std=c++11 -stdlib=libstdc++ + LDFLAGS += -stdlib=libstdc++ +endif + LIBS += -lbz2 -lz ALLEGRO_CONFIG ?= allegro-config @@ -564,11 +569,15 @@ ifeq ($(BACKEND),opengl) SDL_LDFLAGS := $(shell $(SDL_CONFIG) --libs) endif CFLAGS += $(SDL_CFLAGS) - LIBS += $(SDL_LDFLAGS) -lglew32 + LIBS += $(SDL_LDFLAGS) ifeq ($(OSTYPE),mingw) - LIBS += -lopengl32 + LIBS += -lglew32 -lopengl32 else - LIBS += -lGL + ifeq ($(OSTYPE),mac) + LIBS += -framework OpenGL + else + LIBS += -lglew32 -lGL + endif endif endif diff --git a/OSX/getversion.cc b/OSX/getversion.cc index cecc34f..c58a6f4 100644 --- a/OSX/getversion.cc +++ b/OSX/getversion.cc @@ -1,7 +1,7 @@ #include #include "../simversion.h" -main() +int main() { printf("%s\n", VERSION_NUMBER); } diff --git a/OSX/plistgen.sh b/OSX/plistgen.sh old mode 100644 new mode 100755 diff --git a/boden/grund.cc b/boden/grund.cc index cea323f..3ff1717 100644 --- a/boden/grund.cc +++ b/boden/grund.cc @@ -798,9 +798,9 @@ void grund_t::calc_back_bild(const sint8 hgt, const hang_t::typ slope_this) // store corner heights sw, nw, ne scaled to screen dimensions const sint16 scale_z_step = tile_raster_scale_y(TILE_HEIGHT_STEP,64); const sint16 scale_y_step = 64/2; - sint16 corners[3] = {scale_z_step*(hgt + corner1(slope_this)), - scale_z_step*(hgt + corner4(slope_this)), - scale_z_step*(hgt + corner3(slope_this))}; + sint16 corners[3] = {static_cast(scale_z_step*(hgt + corner1(slope_this))), + static_cast(scale_z_step*(hgt + corner4(slope_this))), + static_cast(scale_z_step*(hgt + corner3(slope_this)))}; sint16 corners_add[3] = {0,0,0}; // extra height of possible back-image // now calculate back image @@ -895,7 +895,7 @@ void grund_t::calc_back_bild(const sint8 hgt, const hang_t::typ slope_this) const koord testdir[3] = { koord(-1,0), koord(-1,-1), koord(0,-1) }; for(int step = 0; step<5 && !get_flag(draw_as_obj); step ++) { - sint16 test[3] = {corners[0]+1, corners[1]+1, corners[2]+1}; + sint16 test[3] = {static_cast(corners[0]+1), static_cast(corners[1]+1), static_cast(corners[2]+1)}; for(int i=0; i<=2; i++) { if( const grund_t *gr=welt->lookup_kartenboden(k + testdir[i] - koord(1,1)*step) ) { sint16 h = gr->get_disp_height()*scale_z_step; diff --git a/freight_list_sorter.cc b/freight_list_sorter.cc index b649187..f5772b7 100644 --- a/freight_list_sorter.cc +++ b/freight_list_sorter.cc @@ -16,7 +16,9 @@ #include "utils/cbuffer_t.h" // Necessary for MinGW -#include "malloc.h" +#ifndef __APPLE__ + #include "malloc.h" +#endif karte_ptr_t freight_list_sorter_t::welt; freight_list_sorter_t::sort_mode_t freight_list_sorter_t::sortby=by_name; diff --git a/gui/banner.cc b/gui/banner.cc index 5e2d6e6..6c64189 100644 --- a/gui/banner.cc +++ b/gui/banner.cc @@ -181,7 +181,7 @@ void banner_t::draw(scr_coord pos, scr_size size ) cursor.y += LINESPACE+2; display_shadow_proportional( cursor.x+24, cursor.y, SYSCOL_TEXT_HIGHLIGHT, SYSCOL_TEXT_SHADOW, "under the Artistic Licence; forked", true ); cursor.y += LINESPACE+2; - display_shadow_proportional( cursor.x+24, cursor.y, SYSCOL_TEXT_HIGHLIGHT, SYSCOL_TEXT_SHADOW, "from Simutrans-Standard "QUOTEME(SIM_VERSION_MAJOR) "." QUOTEME(SIM_VERSION_MINOR), true ); + display_shadow_proportional( cursor.x+24, cursor.y, SYSCOL_TEXT_HIGHLIGHT, SYSCOL_TEXT_SHADOW, "from Simutrans-Standard " QUOTEME(SIM_VERSION_MAJOR) "." QUOTEME(SIM_VERSION_MINOR), true ); cursor.y += LINESPACE+7; display_shadow_proportional( cursor.x+24, cursor.y, COL_LIGHT_ORANGE, SYSCOL_TEXT_SHADOW, "Selling this software is forbidden.", true ); diff --git a/gui/simwin.cc b/gui/simwin.cc index ed0920f..b0be175 100644 --- a/gui/simwin.cc +++ b/gui/simwin.cc @@ -498,7 +498,7 @@ void rdwr_all_win(loadsave_t *file) switch(id) { // end of dialogues - case magic_none: return; + case (uint32)magic_none: return; // actual dialogues to restore case magic_convoi_info: w = new convoi_info_t(); break; diff --git a/music/core-audio_midi.mm b/music/core-audio_midi.mm index a73999a..b2d6757 100755 --- a/music/core-audio_midi.mm +++ b/music/core-audio_midi.mm @@ -57,7 +57,7 @@ void dr_stop_midi() } -long dr_midi_pos() +sint32 dr_midi_pos() { if (nowPlaying == -1) { return -1; diff --git a/simsys_opengl.cc b/simsys_opengl.cc index deac317..d4befa2 100644 --- a/simsys_opengl.cc +++ b/simsys_opengl.cc @@ -16,8 +16,13 @@ #include -#include -#include +#ifdef __APPLE__ + // GLEW is not needed on Apple + #include +#else + #include + #include +#endif #include #include @@ -216,6 +221,8 @@ static void update_tex_dims(){ */ static void check_for_extensions(){ +#ifndef __APPLE__ + // Initialize GLEW GLenum err = glewInit(); if (GLEW_OK != err){ @@ -245,6 +252,9 @@ static void check_for_extensions(){ fprintf(stderr, "Renderer is not PBO able.\n"); DBG_MESSAGE("check_for_extensions(OpenGL)", "Renderer does NOT support PBO extension"); } + +#endif + } @@ -1138,7 +1148,7 @@ void ex_ord_update_mx_my() } -unsigned long dr_time() +uint32 dr_time() { return SDL_GetTicks(); } @@ -1149,6 +1159,18 @@ void dr_sleep(uint32 usec) SDL_Delay(usec); } +void dr_start_textinput() +{ +} + +void dr_stop_textinput() +{ +} + +void dr_notify_input_pos(int, int) +{ +} + #ifdef _WIN32 int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) --