diff --git a/build/premake/extern_libs.lua b/build/premake/extern_libs.lua index 879749ec32..6a0cbc5fc8 100644 --- a/build/premake/extern_libs.lua +++ b/build/premake/extern_libs.lua @@ -108,6 +108,7 @@ extern_lib_defs = { opengl = { win_names = { "opengl32", "glu32", "gdi32" }, unix_names = { "GL", "GLU", "X11" }, + osx_frameworks = { "OpenGL" }, dbg_suffix = "", }, spidermonkey = { diff --git a/build/premake/premake.lua b/build/premake/premake.lua index f5a458f060..93bd35e41c 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -110,6 +110,9 @@ function package_set_build_flags() tinsert(package.config["Debug"].buildoptions, { "-O0", -- ICC defaults to -O2 }) + if OS == "macosx" then + tinsert(package.linkoptions, {"-multiply_defined","suppress"}) + end else tinsert(package.buildoptions, { "-Wall", @@ -135,25 +138,27 @@ function package_set_build_flags() "-fvisibility-inlines-hidden", }) - -- Include and lib paths: - -- X11 includes may be installed in one of a gaszillion of three places - -- And MacPorts uses /opt/local as its prefix - -- Famous last words: "You can't include too much! ;-)" - - package.includepaths = { - "/usr/X11R6/include/X11", - "/usr/X11R6/include", - "/usr/include/X11", - "/opt/local/include", - } - package.libpaths = { - "/opt/local/lib", - "/usr/X11R6/lib" - } + if OS == "macosx" then + -- MacPorts uses /opt/local as its prefix + package.includepaths = { "/opt/local/include" } + package.libpaths = { "/opt/local/lib" } + else + -- X11 includes may be installed in one of a gadzillion of three places + -- Famous last words: "You can't include too much! ;-)" + package.includepaths = { + "/usr/X11R6/include/X11", + "/usr/X11R6/include", + "/usr/include/X11" + } + package.libpaths = { + "/usr/X11R6/lib" + } + end if OS == "linux" and options["icc"] then tinsert(package.libpaths, "/usr/i686-pc-linux-gnu/lib") -- needed for ICC to find libbfd end + package.defines = { -- "CONFIG_USE_MMGR", } @@ -412,15 +417,18 @@ function setup_all_libs () "cryptopp", "valgrind" } - setup_static_lib_package("lowlevel", source_dirs, extern_libs, {}) sysdep_dirs = { - linux = { "lib/sysdep/unix" }, + linux = { "lib/sysdep/unix", "lib/sysdep/unix/x" }, -- note: RC file must be added to main_exe package. -- note: don't add "lib/sysdep/win/aken.cpp" because that must be compiled with the DDK. windows = { "lib/sysdep/win", "lib/sysdep/win/wposix", "lib/sysdep/win/whrt" }, macosx = { "lib/sysdep/osx", "lib/sysdep/unix" }, } - tinsert(package.files, sourcesfromdirs(source_root, sysdep_dirs[OS])); + for i,v in sysdep_dirs[OS] do + tinsert(source_dirs, v); + end + -- tinsert(source_dirs, sysdep_dirs[OS]); + setup_static_lib_package("lowlevel", source_dirs, extern_libs, {}) end @@ -521,8 +529,6 @@ function setup_main_exe () tinsert(package.links, { -- Utilities "pthread" }) - - tinsert(package.libpaths, "/usr/X11R6/lib") end end @@ -564,7 +570,7 @@ function setup_atlas_package(package_name, target_type, rel_source_dirs, rel_inc listconcat(package.links, extra_params["extra_links"]) end - else -- Non-Windows, = Unix + elseif OS == "linux" then tinsert(package.buildoptions, "-rdynamic") tinsert(package.linkoptions, "-rdynamic") @@ -757,13 +763,18 @@ function setup_collada_package(package_name, target_type, rel_source_dirs, rel_i listconcat(package.links, extra_params["extra_links"]) end - else -- Non-Windows, = Unix + elseif OS == "linux" then tinsert(package.defines, "LINUX"); tinsert(package.includepaths, "/usr/include/libxml2") tinsert(package.links, "xml2") tinsert(package.buildoptions, "-rdynamic") tinsert(package.linkoptions, "-rdynamic") + elseif OS == "macosx" then + -- define MACOS-something? + + tinsert(package.buildoptions, "`pkg-config libxml-2.0 --cflags`") + tinsert(package.linkoptions, "`pkg-config libxml-2.0 --libs`") end end diff --git a/build/premake/src/Src/gnu_cpp.c b/build/premake/src/Src/gnu_cpp.c index ec38523da5..08eeb9f5ea 100644 --- a/build/premake/src/Src/gnu_cpp.c +++ b/build/premake/src/Src/gnu_cpp.c @@ -121,11 +121,11 @@ int gnu_cpp() /* Write linker flags */ io_print(" LDFLAGS += -L$(BINDIR) -L$(LIBDIR)"); - if (prj_is_kind("dll") && (g_cc == NULL || matches(g_cc, "gcc") || matches(g_cc, "icc"))) + if (prj_is_kind("dll") && (g_cc == NULL || matches(g_cc, "gcc") || matches(g_cc, "icc")) && !os_is("macosx")) io_print(" -shared"); if (prj_has_flag("no-symbols")) io_print(" -s"); - if (os_is("macosx") && prj_has_flag("dylib")) + if (os_is("macosx") && (prj_has_flag("dylib") || prj_is_kind("dll"))) io_print(" -dynamiclib -flat_namespace"); // Use start-group and end-group to get around the problem with the // order of link arguments. @@ -249,8 +249,15 @@ int gnu_cpp() io_print("\t-%s$(CMD_MKLIBDIR)\n", prefix); io_print("\t-%s$(CMD_MKOUTDIR)\n", prefix); if (os_is("macosx") && prj_is_kind("winexe")) + { io_print("\t-%sif [ ! -d $(OUTDIR)/$(MACAPP)/MacOS ]; then mkdir -p $(OUTDIR)/$(MACAPP)/MacOS; fi\n", prefix); - io_print("\t%s$(BLDCMD)\n\n", prefix); + io_print("\t%s$(BLDCMD)\n", prefix); + io_print("\t%scp $(OUTDIR)/$(TARGET) $(OUTDIR)/$(MACAPP)/MacOS/$(TARGET)\n\n", prefix); + } + else + { + io_print("\t%s$(BLDCMD)\n\n", prefix); + } } /* @@ -268,8 +275,12 @@ int gnu_cpp() if (os_is("macosx") && prj_is_kind("winexe")) { - io_print("$(OUTDIR)/$(MACAPP)/PkgInfo:\n\n"); - io_print("$(OUTDIR)/$(MACAPP)/Info.plist:\n\n"); + io_print("$(OUTDIR)/$(MACAPP)/PkgInfo:\n" + "\t%smkdir -p $(OUTDIR)/$(MACAPP)\n" + "\t%stouch $@\n\n", prefix, prefix); + io_print("$(OUTDIR)/$(MACAPP)/Info.plist:\n" + "\t%smkdir -p $(OUTDIR)/$(MACAPP)\n" + "\t%stouch $@\n\n", prefix, prefix); } /* Write the "clean" target */ diff --git a/source/lib/glext_funcs.h b/source/lib/glext_funcs.h index e8bc82ac58..ff142c6349 100644 --- a/source/lib/glext_funcs.h +++ b/source/lib/glext_funcs.h @@ -8,7 +8,11 @@ // license: GPL; see lib/license.txt +#if OS_MACOSX +#include +#else #include +#endif #if OS_WIN # include #endif diff --git a/source/lib/sysdep/cpu.cpp b/source/lib/sysdep/cpu.cpp index d9a07ba7d2..5d04c24ba8 100644 --- a/source/lib/sysdep/cpu.cpp +++ b/source/lib/sysdep/cpu.cpp @@ -27,6 +27,9 @@ #if OS_WIN # include "lib/sysdep/win/wcpu.h" #endif +#if OS_UNIX +# include "lib/sysdep/unix/ucpu.h" +#endif ERROR_ASSOCIATE(ERR::CPU_FEATURE_MISSING, "This CPU doesn't support a required feature", -1); @@ -241,12 +244,8 @@ LibError cpu_CallByEachCPU(CpuCallback cb, void* param) { #if OS_WIN return wcpu_CallByEachCPU(cb, param); -#elif OS_LINUX - return ucpu_CallByEachCPU(cb, param); #else - UNUSED2(cb); - UNUSED2(param); - return ERR::NOT_IMPLEMENTED; + return ucpu_CallByEachCPU(cb, param); #endif } diff --git a/source/lib/sysdep/osx/osx.cpp b/source/lib/sysdep/osx/osx.cpp new file mode 100644 index 0000000000..ae4c7d092a --- /dev/null +++ b/source/lib/sysdep/osx/osx.cpp @@ -0,0 +1,52 @@ +#include "precompiled.h" + +#include "lib/lib.h" + +#include "lib/sysdep/sysdep.h" +#include "lib/sysdep/gfx.h" + +// "copy" text into the clipboard. replaces previous contents. +LibError sys_clipboard_set(const wchar_t* text) +{ + return INFO::OK; +} + +// allow "pasting" from clipboard. returns the current contents if they +// can be represented as text, otherwise 0. +// when it is no longer needed, the returned pointer must be freed via +// sys_clipboard_free. (NB: not necessary if zero, but doesn't hurt) +wchar_t* sys_clipboard_get(void) +{ + // Remember to implement sys_clipboard_free when implementing this method! + return NULL; +} + +// frees memory used by , which must have been returned by +// sys_clipboard_get. see note above. +LibError sys_clipboard_free(wchar_t* copy) +{ + // Since clipboard_get never returns allocated memory (unimplemented), we + // should only ever get called with a NULL pointer. + debug_assert(!copy); + return INFO::OK; +} + + +/** + * get current video mode. + * + * this is useful when choosing a new video mode. + * + * @param xres, yres (optional out) resolution [pixels] + * @param bpp (optional out) bits per pixel + * @param freq (optional out) vertical refresh rate [Hz] + * @return LibError; INFO::OK unless: some information was requested + * (i.e. pointer is non-NULL) but cannot be returned. + * on failure, the outputs are all left unchanged (they are + * assumed initialized to defaults) + **/ +LibError gfx_get_video_mode(int* xres, int* yres, int* bpp, int* freq) +{ + // TODO Implement + return ERR::NOT_IMPLEMENTED; +} diff --git a/source/lib/sysdep/unix/x.cpp b/source/lib/sysdep/unix/x/x.cpp similarity index 97% rename from source/lib/sysdep/unix/x.cpp rename to source/lib/sysdep/unix/x/x.cpp index b9c4bcbccf..e6a9a5b312 100644 --- a/source/lib/sysdep/unix/x.cpp +++ b/source/lib/sysdep/unix/x/x.cpp @@ -28,15 +28,6 @@ static size_t selection_size=0; // if we fail, outputs are unchanged (assumed initialized to defaults) LibError gfx_get_video_mode(int* xres, int* yres, int* bpp, int* freq) { -#if OS_MACOSX - // There might not be X. Instead, we should use Carbon. For now however, - // return some defaults. - *xres = 1024; - *yres = 768; - *bpp = 32; - *freq = 0; - return INFO::OK; -#else Display* disp = XOpenDisplay(0); if(!disp) WARN_RETURN(ERR::FAIL); @@ -64,7 +55,6 @@ LibError gfx_get_video_mode(int* xres, int* yres, int* bpp, int* freq) *freq = 0; XCloseDisplay(disp); return INFO::OK; -#endif } diff --git a/source/tools/atlas/AtlasUI/ActorViewer/ActorViewer.h b/source/tools/atlas/AtlasUI/ActorViewer/ActorViewer.h index 247245510c..be53e4de01 100644 --- a/source/tools/atlas/AtlasUI/ActorViewer/ActorViewer.h +++ b/source/tools/atlas/AtlasUI/ActorViewer/ActorViewer.h @@ -7,6 +7,7 @@ #include "wx/treectrl.h" class wxTreeCtrl; +class wxTreeEvent; class ActorViewer : public wxFrame { diff --git a/source/tools/atlas/AtlasUI/ArchiveViewer/FilePreviewer.cpp b/source/tools/atlas/AtlasUI/ArchiveViewer/FilePreviewer.cpp index 981e9a24ea..254b1b002e 100644 --- a/source/tools/atlas/AtlasUI/ArchiveViewer/FilePreviewer.cpp +++ b/source/tools/atlas/AtlasUI/ArchiveViewer/FilePreviewer.cpp @@ -217,7 +217,15 @@ void FilePreviewer::PreviewFile(const wxString& filename, SeekableInputStream& s #else static wxSound snd; snd.Stop(); + // HACK, FIXME, XXX: I'd like to call the wx people idiots for + // having different API:s on different platforms, as well as for + // having public non-API methods. +#if __APPLE__ + snd.~wxSound(); + new (&snd) wxSound((int)bufSize, (const wxByte*)buf); +#else snd.Create((int)bufSize, (const wxByte*)buf); +#endif snd.Play(); #endif stream.ReleaseBuffer(buf); diff --git a/source/tools/atlas/AtlasUI/CustomControls/DraggableListCtrl/DraggableListCtrl.h b/source/tools/atlas/AtlasUI/CustomControls/DraggableListCtrl/DraggableListCtrl.h index 5950b4e949..9872dc7bd9 100644 --- a/source/tools/atlas/AtlasUI/CustomControls/DraggableListCtrl/DraggableListCtrl.h +++ b/source/tools/atlas/AtlasUI/CustomControls/DraggableListCtrl/DraggableListCtrl.h @@ -10,6 +10,8 @@ #include "EditableListCtrl/EditableListCtrl.h" +#include "wx/listctrl.h" + class DragCommand; class DraggableListCtrl : public EditableListCtrl diff --git a/source/tools/atlas/AtlasUI/General/VideoRecorder/FFmpeg.cpp b/source/tools/atlas/AtlasUI/General/VideoRecorder/FFmpeg.cpp index d4dceab86f..d272c1cf84 100644 --- a/source/tools/atlas/AtlasUI/General/VideoRecorder/FFmpeg.cpp +++ b/source/tools/atlas/AtlasUI/General/VideoRecorder/FFmpeg.cpp @@ -26,6 +26,7 @@ Please complain if I forget to do those things. // ugly hack to make recent versions of FFmpeg work #define __STDC_CONSTANT_MACROS #undef _STDINT_H +#undef _STDINT_H_ #include #endif @@ -47,8 +48,12 @@ typedef __int32 int32_t; typedef __int64 int64_t; #endif +#define UNUSED(arg) + +extern "C" { #include "ffmpeg/avformat.h" #include "ffmpeg/swscale.h" +} // (Have to use a sufficiently recent version to get swscale - it needs the ~x86 keyword on Gentoo) struct VideoEncoderImpl @@ -269,7 +274,7 @@ struct VideoEncoderImpl frame_count++; } - void close_video(AVFormatContext *oc, AVStream *st) + void close_video(AVFormatContext *UNUSED(oc), AVStream *st) { avcodec_close(st->codec); av_free(picture->data[0]); @@ -284,7 +289,7 @@ struct VideoEncoderImpl ////////////////////////////////////////////////////////////////////////// -void log(void* v, int i, const char* format, va_list ap) +void log(void* UNUSED(v), int i, const char* format, va_list ap) { char buf[512]; vsnprintf(buf, sizeof(buf), format, ap); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp index 50ca4457dc..55032a5f62 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp @@ -15,6 +15,7 @@ #include "wx/filename.h" #include "wx/wfstream.h" #include "wx/listctrl.h" +#include "wx/imaglist.h" #include diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h index 6123dab826..f8b50ad73e 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h @@ -11,6 +11,8 @@ class TriggerBottomBar; class TriggerPage; class wxTreeItemId; class wxTreeItemData; +class wxTreeEvent; +class wxListEvent; class wxNotebook; class wxNotebookEvent; class wxTreeEvent; diff --git a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp index f928d27caf..91a95ef966 100644 --- a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp +++ b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp @@ -17,7 +17,9 @@ MessagePasserImpl::MessagePasserImpl() { CStr name = "/wfg-atlas-msgpass-" + CStr(rand(100000, 1000000)); sem_t* sem = sem_open(name, O_CREAT | O_EXCL, 0700, 0); - if (sem == SEM_FAILED) + // This cast should not be necessary, but apparently SEM_FAILED is not + // a value of a pointer type + if (sem == (sem_t*)SEM_FAILED) { int err = errno; if (err == EEXIST) diff --git a/source/tools/atlas/GameInterface/SharedTypes.h b/source/tools/atlas/GameInterface/SharedTypes.h index 105fd8e1f1..58e9f8ab20 100644 --- a/source/tools/atlas/GameInterface/SharedTypes.h +++ b/source/tools/atlas/GameInterface/SharedTypes.h @@ -3,6 +3,8 @@ #include "Shareable.h" +#include + class wxPoint; class CVector3D;