|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- RACK_DIR ?= .
- VERSION_MAJOR := 2
- VERSION := $(shell jq -r .version Core.json)
-
- FLAGS += -Iinclude -Idep/include
-
- include arch.mk
-
- # Sources and build flags
-
- SOURCES += dep/nanovg/src/nanovg.c
- SOURCES += dep/osdialog/osdialog.c
- SOURCES += dep/oui-blendish/blendish.c
- SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
- SOURCES += dep/tinyexpr/tinyexpr.c
- SOURCES += $(wildcard src/*.c src/*/*.c)
- SOURCES += $(wildcard src/*.cpp src/*/*.cpp)
-
- build/src/common.cpp.o: FLAGS += -D_APP_VERSION=$(VERSION)
- build/dep/tinyexpr/tinyexpr.c.o: FLAGS += -DTE_POW_FROM_RIGHT -DTE_NAT_LOG
-
- FLAGS += -fPIC
- LDFLAGS += -shared
-
- ifdef ARCH_LIN
- SED := sed -i
- TARGET := libRack.so
-
- SOURCES += dep/osdialog/osdialog_zenity.c
-
- # 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 += -static-libstdc++ -static-libgcc
- 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/libarchive.a dep/lib/libzstd.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 -lpulse -lpulse-simple
- endif
-
- ifdef ARCH_MAC
- SED := sed -i ''
- TARGET := libRack.dylib
-
- SOURCES += $(wildcard src/*.m src/*/*.m)
- SOURCES += $(wildcard src/*.mm src/*/*.mm)
- SOURCES += dep/osdialog/osdialog_mac.m
- LDFLAGS += -lpthread -ldl
- LDFLAGS += -framework SystemConfiguration -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI -framework AVFoundation
- 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 -Wl,-load_hidden,dep/lib/libarchive.a -Wl,-load_hidden,dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a -Wl,-load_hidden,dep/lib/librtmidi.a -Wl,-load_hidden,dep/lib/librtaudio.a
- endif
-
- ifdef ARCH_WIN
- SED := sed -i
- TARGET := libRack.dll
-
- SOURCES += dep/osdialog/osdialog_win.c
- LDFLAGS += -municode
- LDFLAGS += -Wl,--export-all-symbols
- LDFLAGS += -Wl,--out-implib,$(TARGET).a
- LDFLAGS += -Wl,-Bstatic -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/libarchive_static.a dep/lib/libzstd.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 -lcrypt32
- endif
-
- # Some libraries aren't needed by plugins and might conflict with DAWs that load libRack, so make their symbols local to libRack instead of global (default).
- # --exclude-libs is unavailable on Apple ld
- ifndef ARCH_MAC
- LDFLAGS += -Wl,--exclude-libs,libzstd.a
- LDFLAGS += -Wl,--exclude-libs,libarchive.a
- LDFLAGS += -Wl,--exclude-libs,librtmidi.a
- LDFLAGS += -Wl,--exclude-libs,librtaudio.a
- endif
-
- include compile.mk
-
- # Standalone adapter
-
- STANDALONE_SOURCES += adapters/standalone.cpp
-
- ifdef ARCH_LIN
- STANDALONE_TARGET := Rack
- STANDALONE_LDFLAGS += -static-libstdc++ -static-libgcc
- STANDALONE_LDFLAGS += -Wl,-rpath=.
- endif
- ifdef ARCH_MAC
- STANDALONE_TARGET := Rack
- STANDALONE_LDFLAGS += -stdlib=libc++
- endif
- ifdef ARCH_WIN
- STANDALONE_TARGET := Rack.exe
- STANDALONE_LDFLAGS += -mwindows
- # 1MiB stack size to match MSVC
- STANDALONE_LDFLAGS += -Wl,--stack,0x100000
- STANDALONE_OBJECTS += build/Rack.res
- endif
-
- STANDALONE_OBJECTS += $(TARGET)
-
- $(STANDALONE_TARGET): $(STANDALONE_SOURCES) $(STANDALONE_OBJECTS)
- $(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)
-
- # Convenience targets
-
- all: $(TARGET) $(STANDALONE_TARGET)
-
- dep:
- $(MAKE) -C dep
-
- cleandep:
- $(MAKE) -C dep clean
-
- run: $(STANDALONE_TARGET)
- ./$< -d
-
- runr: $(STANDALONE_TARGET)
- ./$<
-
- debug: $(STANDALONE_TARGET)
- ifdef ARCH_MAC
- lldb -- ./$< -d
- endif
- ifdef ARCH_WIN
- gdb --args ./$< -d
- endif
- ifdef ARCH_LIN
- gdb --args ./$< -d
- endif
-
- perf: $(STANDALONE_TARGET)
- # Requires perf
- perf record --call-graph dwarf -o perf.data ./$< -d
- # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
- hotspot perf.data
- rm perf.data
-
- valgrind: $(STANDALONE_TARGET)
- # --gen-suppressions=yes
- # --leak-check=full
- valgrind --suppressions=valgrind.supp ./$< -d
-
- clean:
- rm -rfv build dist $(TARGET) $(STANDALONE_TARGET) *.a
-
- # Windows resources
- build/%.res: %.rc
- ifdef ARCH_WIN
- windres $^ -O coff -o $@
- endif
-
-
- # Plugin helper
- plugins:
- ifdef CMD
- for f in plugins/*; do (cd "$$f" && $(CMD)); done
- else
- for f in plugins/*; do $(MAKE) -C "$$f"; done
- endif
-
-
- # The following targets are not supported for public use
-
- DIST_NAME = RackFree-$(VERSION)-$(ARCH_NAME)
- ifdef ARCH_MAC
- DIST_BUNDLE := VCV\ Rack\ $(VERSION_MAJOR)\ Free.app
- DIST_DIR := dist/$(DIST_BUNDLE)
- else
- DIST_DIR := dist/Rack$(VERSION_MAJOR)Free
- endif
- DIST_MD := $(wildcard *.md)
- DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
- DIST_RES := res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt $(DIST_HTML)
- DIST_SDK_DIR := dist/Rack-SDK
- DIST_SDK = dist/Rack-SDK-$(VERSION)-$(ARCH_NAME).zip
-
-
- dist: $(DIST_DIR)
- $(DIST_DIR): $(TARGET) $(STANDALONE_TARGET) $(DIST_HTML)
- mkdir -p dist
- ifdef ARCH_LIN
- mkdir -p $(DIST_DIR)
- cp $(TARGET) $(DIST_DIR)/
- cp $(STANDALONE_TARGET) $(DIST_DIR)/
- $(STRIP) -s $(DIST_DIR)/$(TARGET)
- $(STRIP) -s $(DIST_DIR)/$(STANDALONE_TARGET)
- # Manually check that no nonstandard shared libraries are linked
- ldd $(DIST_DIR)/$(TARGET)
- ldd $(DIST_DIR)/$(STANDALONE_TARGET)
- # Copy resources
- cp -R $(DIST_RES) $(DIST_DIR)/
- cp plugins/Fundamental/dist/Fundamental-*.vcvplugin $(DIST_DIR)/
- endif
- ifdef ARCH_MAC
- mkdir -p $(DIST_DIR)
- mkdir -p $(DIST_DIR)/Contents
- mkdir -p $(DIST_DIR)/Contents/Resources
- mkdir -p $(DIST_DIR)/Contents/MacOS
- cp $(TARGET) $(DIST_DIR)/Contents/Resources/
- cp $(STANDALONE_TARGET) $(DIST_DIR)/Contents/MacOS/
- $(STRIP) -S $(DIST_DIR)/Contents/Resources/$(TARGET)
- $(STRIP) -S $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
- install_name_tool -change $(TARGET) @executable_path/../Resources/$(TARGET) $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
- # Manually check that no nonstandard shared libraries are linked
- otool -L $(DIST_DIR)/Contents/Resources/$(TARGET)
- otool -L $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
- # Copy resources
- cp Info.plist $(DIST_DIR)/Contents/
- $(SED) 's/{VERSION}/$(VERSION)/g' $(DIST_DIR)/Contents/Info.plist
- cp -R icon.icns $(DIST_DIR)/Contents/Resources/
- cp -R $(DIST_RES) $(DIST_DIR)/Contents/Resources/
- cp plugins/Fundamental/dist/Fundamental-*.vcvplugin $(DIST_DIR)/Contents/Resources/
- endif
- ifdef ARCH_WIN
- mkdir -p $(DIST_DIR)
- cp $(TARGET) $(DIST_DIR)/
- cp $(STANDALONE_TARGET) $(DIST_DIR)/
- $(STRIP) -s $(DIST_DIR)/$(TARGET)
- $(STRIP) -s $(DIST_DIR)/$(STANDALONE_TARGET)
- # Copy resources
- cp -R $(DIST_RES) $(DIST_DIR)/
- cp /mingw64/bin/libwinpthread-1.dll $(DIST_DIR)/
- cp /mingw64/bin/libstdc++-6.dll $(DIST_DIR)/
- cp /mingw64/bin/libgcc_s_seh-1.dll $(DIST_DIR)/
- cp plugins/Fundamental/dist/Fundamental-*.vcvplugin $(DIST_DIR)/
- endif
-
-
- sdk: $(DIST_SDK_DIR)
- $(DIST_SDK_DIR): $(DIST_HTML)
- mkdir -p $(DIST_SDK_DIR)
- cp -R include *.mk helper.py $(DIST_HTML) $(DIST_SDK_DIR)/
- mkdir -p $(DIST_SDK_DIR)/dep
- cp -R dep/include $(DIST_SDK_DIR)/dep/
- ifdef ARCH_LIN
- cp $(TARGET) $(DIST_SDK_DIR)/
- $(STRIP) -s $(DIST_SDK_DIR)/$(TARGET)
- endif
- ifdef ARCH_MAC
- cp $(TARGET) $(DIST_SDK_DIR)/
- $(STRIP) -S $(DIST_SDK_DIR)/$(TARGET)
- endif
- ifdef ARCH_WIN
- cp $(TARGET).a $(DIST_SDK_DIR)/
- endif
-
-
- package: $(DIST_DIR) $(DIST_SDK_DIR)
- ifdef ARCH_LIN
- # Make ZIP
- cd dist && zip -q -9 -r ../$(DIST_NAME).zip $(notdir $(DIST_DIR))
- endif
- ifdef ARCH_MAC
- # Clean up and sign bundle
- xattr -cr $(DIST_DIR)
- codesign --verbose --sign "Developer ID Application: Andrew Belt (V8SW9J626X)" --options runtime --entitlements Entitlements.plist --timestamp --deep $(DIST_DIR)/Contents/Resources/$(TARGET) $(DIST_DIR)
- codesign --verify --deep --strict --verbose=2 $(DIST_DIR)
- # Make standalone PKG
- mkdir -p dist/Component
- cp -R $(DIST_DIR) dist/Component/
- pkgbuild --identifier com.vcvrack.rack --component-plist Component.plist --root dist/Component --install-location /Applications dist/Component.pkg
- # Make PKG
- productbuild --distribution Distribution.xml --package-path dist dist/$(DIST_NAME).pkg
- productsign --sign "Developer ID Installer: Andrew Belt (V8SW9J626X)" dist/$(DIST_NAME).pkg dist/$(DIST_NAME)-signed.pkg
- mv dist/$(DIST_NAME)-signed.pkg dist/$(DIST_NAME).pkg
- endif
- ifdef ARCH_WIN
- # Make NSIS installer
- # pacman -S mingw-w64-x86_64-nsis
- makensis -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION=$(VERSION) "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
- endif
- # SDK
- cd dist && zip -q -9 -r ../$(DIST_SDK) $(notdir $(DIST_SDK_DIR))
-
-
- lipo: $(DIST_DIR) $(DIST_SDK_DIR)
- ifndef OTHER_RACK_DIR
- $(error OTHER_RACK_DIR not defined)
- endif
- ifdef ARCH_MAC
- lipo -create -output $(DIST_DIR)/Contents/Resources/$(TARGET) $(DIST_DIR)/Contents/Resources/$(TARGET) $(OTHER_RACK_DIR)/$(DIST_DIR)/Contents/Resources/$(TARGET)
- lipo -create -output $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET) $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET) $(OTHER_RACK_DIR)/$(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
- lipo -create -output $(DIST_SDK_DIR)/$(TARGET) $(DIST_SDK_DIR)/$(TARGET) $(OTHER_RACK_DIR)/$(DIST_SDK_DIR)/$(TARGET)
- cp $(OTHER_RACK_DIR)/$(DIST_DIR)/Contents/Resources/Fundamental-*.vcvplugin $(DIST_DIR)/Contents/Resources/
- endif
-
-
- notarize:
- ifdef ARCH_MAC
- # Submit installer package to Apple
- xcrun notarytool submit --keychain-profile "VCV" --wait dist/$(DIST_NAME).pkg
- # Mark app as notarized
- xcrun stapler staple dist/$(DIST_NAME).pkg
- # Check notarization
- stapler validate dist/$(DIST_NAME).pkg
- endif
-
-
- install: dist
- ifdef ARCH_MAC
- sudo installer -pkg dist/$(DIST_NAME).pkg -target /
- endif
-
-
- uninstall:
- ifdef ARCH_MAC
- sudo rm -rf /Applications/$(DIST_BUNDLE)
- endif
-
-
- cleandist:
- rm -rfv dist
-
-
- .DEFAULT_GOAL := all
- .PHONY: all dep run debug clean dist upload src plugins
|