Browse Source

Break Rack into libRack shared library and lightweight standalone Rack executable.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
dee649db0f
3 changed files with 56 additions and 29 deletions
  1. +1
    -1
      .gitignore
  2. +55
    -28
      Makefile
  3. +0
    -0
      standalone/main.cpp

+ 1
- 1
.gitignore View File

@@ -1,7 +1,7 @@
/libRack.*
/Rack /Rack
/Rack.exe /Rack.exe
/Rack.res /Rack.res
/libRack.a
/dep /dep
/plugins /plugins
/disabledplugins /disabledplugins


+ 55
- 28
Makefile View File

@@ -17,55 +17,82 @@ SOURCES += $(wildcard dep/jpommier-pffft-*/pffft.c) $(wildcard dep/jpommier-pfff
SOURCES += $(wildcard src/*.c src/*/*.c) SOURCES += $(wildcard src/*.c src/*/*.c)
SOURCES += $(wildcard src/*.cpp src/*/*.cpp) SOURCES += $(wildcard src/*.cpp src/*/*.cpp)


STANDALONE_SOURCES += $(wildcard standalone/*.cpp)

FLAGS += -fPIC
LDFLAGS += -shared

ifdef ARCH_LIN ifdef ARCH_LIN
TARGET := libRack.so
STANDALONE_TARGET := Rack

SOURCES += dep/osdialog/osdialog_gtk2.c SOURCES += dep/osdialog/osdialog_gtk2.c
build/dep/osdialog/osdialog_gtk2.c.o: FLAGS += $(shell pkg-config --cflags gtk+-2.0) build/dep/osdialog/osdialog_gtk2.c.o: FLAGS += $(shell pkg-config --cflags gtk+-2.0)


LDFLAGS += -rdynamic \
-Wl,--whole-archive \
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 \
-Wl,--no-whole-archive \
-lpthread -lGL -ldl -lX11 -lasound -ljack \
$(shell pkg-config --libs gtk+-2.0)
TARGET := Rack
# 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,--whole-archive
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
LDFLAGS += -Wl,--no-whole-archive
LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack
LDFLAGS += $(shell pkg-config --libs gtk+-2.0)
endif endif


ifdef ARCH_MAC ifdef ARCH_MAC
TARGET := libRack.dylib
STANDALONE_TARGET := Rack

SOURCES += dep/osdialog/osdialog_mac.m SOURCES += dep/osdialog/osdialog_mac.m
LDFLAGS += -lpthread -ldl \
-framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI \
-Wl,-all_load \
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
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 # For LuaJIT
LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000 LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000
TARGET := Rack
endif endif


ifdef ARCH_WIN ifdef ARCH_WIN
TARGET := libRack.dll
STANDALONE_TARGET := Rack.exe

SOURCES += dep/osdialog/osdialog_win.c SOURCES += dep/osdialog/osdialog_win.c
LDFLAGS += -Wl,--export-all-symbols,--out-implib,libRack.a -mwindows \
-Wl,--whole-archive \
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 \
-Wl,--no-whole-archive \
-lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp
TARGET := Rack.exe
LDFLAGS += -Wl,--export-all-symbols
LDFLAGS += -Wl,--out-implib,$(TARGET).a -mwindows
LDFLAGS += -Wl,--whole-archive
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,--no-whole-archive
LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp
OBJECTS += Rack.res OBJECTS += Rack.res
endif endif


include compile.mk

# Standalone launcher

STANDALONE_LDFLAGS += -Wl,-rpath=.
STANDALONE_OBJECTS := $(patsubst %, build/%.o, $(STANDALONE_SOURCES))
STANDALONE_DEPENDENCIES := $(patsubst %, build/%.d, $(STANDALONE_SOURCES))
-include $(STANDALONE_DEPENDENCIES)

$(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(TARGET)
$(CXX) -o $@ $^ $(STANDALONE_LDFLAGS)

# Convenience targets # Convenience targets


all: $(TARGET)
all: $(TARGET) $(STANDALONE_TARGET)


dep: dep:
$(MAKE) -C dep $(MAKE) -C dep


run: $(TARGET)
run: $(STANDALONE_TARGET)
./$< -d ./$< -d


runr: $(TARGET)
runr: $(STANDALONE_TARGET)
./$< ./$<


debug: $(TARGET)
debug: $(STANDALONE_TARGET)
ifdef ARCH_MAC ifdef ARCH_MAC
lldb -- ./$< -d lldb -- ./$< -d
endif endif
@@ -76,20 +103,20 @@ ifdef ARCH_LIN
gdb --args ./$< -d gdb --args ./$< -d
endif endif


perf: $(TARGET)
perf: $(STANDALONE_TARGET)
# Requires perf # Requires perf
perf record --call-graph dwarf -o perf.data ./$< -d perf record --call-graph dwarf -o perf.data ./$< -d
# Analyze with hotspot (https://github.com/KDAB/hotspot) for example # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
hotspot perf.data hotspot perf.data
rm perf.data rm perf.data


valgrind: $(TARGET)
valgrind: $(STANDALONE_TARGET)
# --gen-suppressions=yes # --gen-suppressions=yes
# --leak-check=full # --leak-check=full
valgrind --suppressions=valgrind.supp ./$< -d valgrind --suppressions=valgrind.supp ./$< -d


clean: clean:
rm -rfv $(TARGET) libRack.a Rack.res build dist
rm -rfv $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist




# For Windows resources # For Windows resources
@@ -111,11 +138,13 @@ dist: $(TARGET)
ifdef ARCH_LIN ifdef ARCH_LIN
mkdir -p dist/Rack mkdir -p dist/Rack
cp $(TARGET) dist/Rack/ cp $(TARGET) dist/Rack/
cp $(STANDALONE_TARGET) dist/Rack/
$(STRIP) -s dist/Rack/$(TARGET) $(STRIP) -s dist/Rack/$(TARGET)
$(STRIP) -s dist/Rack/$(STANDALONE_TARGET)
cp -R $(DIST_RES) dist/Rack/ cp -R $(DIST_RES) dist/Rack/
# Manually check that no nonstandard shared libraries are linked # Manually check that no nonstandard shared libraries are linked
ldd dist/Rack/$(TARGET) ldd dist/Rack/$(TARGET)
cp Fundamental.zip dist/Rack/
# cp Fundamental.zip dist/Rack/
# Make ZIP # Make ZIP
cd dist && zip -q -9 -r $(DIST_NAME).zip Rack cd dist && zip -q -9 -r $(DIST_NAME).zip Rack
endif endif
@@ -216,7 +245,5 @@ endif


# Includes # Includes


include compile.mk

.DEFAULT_GOAL := all .DEFAULT_GOAL := all
.PHONY: all dep run debug clean dist upload src plugins .PHONY: all dep run debug clean dist upload src plugins

src/main.cpp → standalone/main.cpp View File


Loading…
Cancel
Save