medfall

A super great game engine
Log | Files | Refs

commit ff2c9cf69317747d3a4744ca910f31f91a5e90f2
parent d492d950af505daf334dcfbc19cc0ab080934b21
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Jun 25 15:44:22 +0300

Fix OSX build

Diffstat:
libs/glfw.lua | 21+++++++++++++++++++++
make.lua | 16+++++++++++-----
scripts/gen_makefile.lua | 8++++++++
3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/libs/glfw.lua b/libs/glfw.lua @@ -20,6 +20,27 @@ elseif OS == "linux" then } ) obj_replace_cxxflags( "libs/glfw/src/%", "-c -x c -O2 -D_GLFW_X11" ) +elseif OS == "macos" then + lib( "glfw", { + "libs/glfw/src/cocoa_init", "libs/glfw/src/cocoa_monitor", "libs/glfw/src/cocoa_window", + "libs/glfw/src/cocoa_joystick", "libs/glfw/src/cocoa_time", "libs/glfw/src/posix_tls", + "libs/glfw/src/nsgl_context", + } ) + + obj_replace_cxxflags( "libs/glfw/src/%", "-c -x c -O2 -D_GLFW_COCOA" ) + + -- build .m files properly + obj( "libs/glfw/src/cocoa_init", "libs/glfw/src/cocoa_init.m" ) + obj( "libs/glfw/src/cocoa_monitor", "libs/glfw/src/cocoa_monitor.m" ) + obj( "libs/glfw/src/cocoa_window", "libs/glfw/src/cocoa_window.m" ) + obj( "libs/glfw/src/cocoa_joystick", "libs/glfw/src/cocoa_joystick.m" ) + obj( "libs/glfw/src/nsgl_context", "libs/glfw/src/nsgl_context.m" ) + + obj_replace_cxxflags( "libs/glfw/src/cocoa_init", "-c -O2 -D_GLFW_COCOA" ) + obj_replace_cxxflags( "libs/glfw/src/cocoa_monitor", "-c -O2 -D_GLFW_COCOA -Wno-deprecated-declarations" ) + obj_replace_cxxflags( "libs/glfw/src/cocoa_window", "-c -O2 -D_GLFW_COCOA -Wno-deprecated-declarations" ) + obj_replace_cxxflags( "libs/glfw/src/cocoa_joystick", "-c -O2 -D_GLFW_COCOA" ) + obj_replace_cxxflags( "libs/glfw/src/nsgl_context", "-c -O2 -D_GLFW_COCOA -Wno-deprecated-declarations" ) else error( "don't know how to build GLFW on this platform" ) end diff --git a/make.lua b/make.lua @@ -12,13 +12,19 @@ if OS == "openbsd" then return end +local game_ldflags = "-lX11 -lXrandr -lXinerama -lXcursor" + +if OS == "macos" then + game_ldflags = "-framework Cocoa -framework CoreAudio -framework CoreVideo -framework IOKit" +end + bin( "medfall", { "main", "hm", "heightmap", "terrain_manager", "btt", "gpubtt", "skybox", "http", game_objs }, { "lz4", game_libs } ) msvc_bin_ldflags( "medfall", "opengl32.lib gdi32.lib Ws2_32.lib" ) -gcc_bin_ldflags( "medfall", "-lX11 -lXrandr -lXinerama -lXcursor" ) +gcc_bin_ldflags( "medfall", game_ldflags ) bin( "launch", { "launcher/main", "http", "sha2", "patterns", game_objs }, { "imgui", "monocypher", "whereami", game_libs } ) msvc_bin_ldflags( "launch", "opengl32.lib gdi32.lib Ws2_32.lib" ) -gcc_bin_ldflags( "launch", "-lX11 -lXrandr -lXinerama -lXcursor" ) +gcc_bin_ldflags( "launch", game_ldflags ) require( "libs/imgui" ) require( "libs/glfw" ) @@ -39,11 +45,11 @@ bin( "bsp", { "main", "bsp", "bsp_renderer", game_objs }, { game_libs } ) bin( "sm", { "main", "shadow_map", game_objs }, { game_libs } ) msvc_bin_ldflags( "bsp", "opengl32.lib gdi32.lib" ) -gcc_bin_ldflags( "bsp", "-lX11 -lXrandr -lXinerama -lXcursor" ) +gcc_bin_ldflags( "bsp", game_ldflags ) msvc_bin_ldflags( "btt", "opengl32.lib gdi32.lib" ) -gcc_bin_ldflags( "btt", "-lX11 -lXrandr -lXinerama -lXcursor" ) +gcc_bin_ldflags( "btt", game_ldflags ) msvc_bin_ldflags( "sm", "opengl32.lib gdi32.lib" ) -gcc_bin_ldflags( "sm", "-lX11 -lXrandr -lXinerama -lXcursor" ) +gcc_bin_ldflags( "sm", game_ldflags ) bin( "sound", { "audio", "mixer", "wave", "platform_audio_output", common_objs } ) msvc_bin_ldflags( "sound", "ole32.lib" ) diff --git a/scripts/gen_makefile.lua b/scripts/gen_makefile.lua @@ -64,6 +64,14 @@ local configs = { -- TODO: OSX } +configs[ "macos" ] = copy( configs( "linux" ) +configs[ "macos" ].cxx = "clang++" + +configs[ "macos-64" ] = copy( configs[ "linux-64" ] ) +configs[ "macos-debug" ] = copy( configs[ "linux-debug" ] ) +configs[ "macos-asan" ] = copy( configs[ "linux-debug" ] ) +configs[ "macos-release" ] = copy( configs[ "linux-debug" ] ) + configs[ "openbsd" ] = copy( configs[ "linux" ] ) configs[ "openbsd" ].cxx = "-eg++" configs[ "openbsd" ].ldflags = "-lm -lpthread -lexecinfo"