From 94b5ad8b32242400fe9540ec47da00c44b494be6 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 28 Jan 2020 20:05:22 -0500 Subject: [PATCH] Fix build on Mac. --- .gitignore | 2 ++ Makefile | 19 +++++++++++++------ compile.mk | 2 -- include/context.hpp | 5 +++-- plugin.mk | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 5fa2267f..a0f10d96 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ /Rack.exe /Rack.res /dep +/Rack.d +/Rack.dSYM /plugins /disabledplugins /build diff --git a/Makefile b/Makefile index 8324a3f3..525fde1c 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ LDFLAGS += -shared ifdef ARCH_LIN TARGET := libRack.so - STANDALONE_TARGET := Rack SOURCES += dep/osdialog/osdialog_gtk2.c build/dep/osdialog/osdialog_gtk2.c.o: FLAGS += $(shell pkg-config --cflags gtk+-2.0) @@ -38,24 +37,28 @@ build/dep/osdialog/osdialog_gtk2.c.o: FLAGS += $(shell pkg-config --cflags gtk+- LDFLAGS += -Wl,--no-whole-archive LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack LDFLAGS += $(shell pkg-config --libs gtk+-2.0) + + STANDALONE_TARGET := Rack + STANDALONE_LDFLAGS += -Wl,-rpath=. endif ifdef ARCH_MAC TARGET := libRack.dylib - STANDALONE_TARGET := Rack SOURCES += dep/osdialog/osdialog_mac.m LDFLAGS += -lpthread -ldl LDFLAGS += -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI LDFLAGS += -Wl,-all_load LDFLAGS += dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/libzip.a dep/lib/libz.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/librtmidi.a dep/lib/librtaudio.a - # For LuaJIT - LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000 + + STANDALONE_TARGET := Rack + STANDALONE_LDFLAGS += -stdlib=libc++ + # For LuaJIT to work inside plugins + STANDALONE_LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000 endif ifdef ARCH_WIN TARGET := libRack.dll - STANDALONE_TARGET := Rack.exe SOURCES += dep/osdialog/osdialog_win.c LDFLAGS += -Wl,--export-all-symbols @@ -64,6 +67,8 @@ ifdef ARCH_WIN LDFLAGS += dep/lib/libglew32.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/libzip.a dep/lib/libz.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/librtaudio.a dep/lib/librtmidi.a LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp + + STANDALONE_TARGET := Rack.exe STANDALONE_LDFLAGS += -mwindows STANDALONE_OBJECTS += build/Rack.res endif @@ -72,7 +77,9 @@ include compile.mk # Standalone launcher -STANDALONE_LDFLAGS += -Wl,-rpath=. +ifdef ARCH_MAC + STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS) +endif STANDALONE_OBJECTS += $(patsubst %, build/%.o, $(STANDALONE_SOURCES)) STANDALONE_DEPENDENCIES := $(patsubst %, build/%.d, $(STANDALONE_SOURCES)) -include $(STANDALONE_DEPENDENCIES) diff --git a/compile.mk b/compile.mk index 8c3e4d7d..b3f208d0 100644 --- a/compile.mk +++ b/compile.mk @@ -26,10 +26,8 @@ endif ifdef ARCH_MAC FLAGS += -DARCH_MAC CXXFLAGS += -stdlib=libc++ - LDFLAGS += -stdlib=libc++ MAC_SDK_FLAGS = -mmacosx-version-min=10.7 FLAGS += $(MAC_SDK_FLAGS) - LDFLAGS += $(MAC_SDK_FLAGS) endif ifdef ARCH_WIN FLAGS += -DARCH_WIN diff --git a/include/context.hpp b/include/context.hpp index e737cc51..85d15a55 100644 --- a/include/context.hpp +++ b/include/context.hpp @@ -38,6 +38,7 @@ struct Context { history::State* history = NULL; PatchManager* patch = NULL; + /** Call this after setting the context for this thread, because initialization of application state accesses APP. */ void init(); ~Context(); }; @@ -46,11 +47,11 @@ struct Context { /** Returns the global Context pointer */ Context* contextGet(); /** Sets the context for this thread. -You must call this every thread if you want to use the APP macro in that thread. +You must set the context when preparing each thread if the code uses the APP macro in that thread. */ void contextSet(Context* context); -/** Accesses the global Context pointer */ +/** Accesses the global Context pointer. Just an alias for contextGet(). */ #define APP rack::contextGet() diff --git a/plugin.mk b/plugin.mk index 5e4c1206..13ebee87 100644 --- a/plugin.mk +++ b/plugin.mk @@ -18,7 +18,6 @@ FLAGS += -fPIC FLAGS += -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include LDFLAGS += -shared -LDFLAGS += -Wl,-rpath=. LDFLAGS += -L$(RACK_DIR) -lRack include $(RACK_DIR)/arch.mk @@ -28,6 +27,7 @@ ifdef ARCH_LIN # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose(). # I don't really understand the side effects (see GCC manual), but so far tests are positive. FLAGS += -fno-gnu-unique + LDFLAGS += -Wl,-rpath=. RACK_USER_DIR ?= $(HOME)/.Rack endif