You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
9.1KB

  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. VERSION := 2.git.$(shell git rev-parse --short HEAD)
  4. # VERSION := 2.0.0
  5. FLAGS += -Iinclude -Idep/include
  6. include arch.mk
  7. # Sources and build flags
  8. SOURCES += dep/nanovg/src/nanovg.c
  9. SOURCES += dep/osdialog/osdialog.c
  10. SOURCES += dep/oui-blendish/blendish.c
  11. SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
  12. SOURCES += $(wildcard src/*.c src/*/*.c)
  13. SOURCES += $(wildcard src/*.cpp src/*/*.cpp)
  14. build/src/common.cpp.o: FLAGS += -D_APP_VERSION=$(VERSION)
  15. STANDALONE_SOURCES += adapters/standalone.cpp
  16. FLAGS += -fPIC
  17. LDFLAGS += -shared
  18. ifdef ARCH_LIN
  19. SED := sed -i
  20. TARGET := libRack.so
  21. SOURCES += dep/osdialog/osdialog_gtk3.c
  22. build/dep/osdialog/osdialog_gtk3.c.o: FLAGS += $(shell pkg-config --cflags gtk+-3.0)
  23. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  24. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  25. FLAGS += -fno-gnu-unique
  26. LDFLAGS += -Wl,--whole-archive
  27. 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
  28. LDFLAGS += -Wl,--no-whole-archive
  29. LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack
  30. LDFLAGS += $(shell pkg-config --libs gtk+-3.0)
  31. STANDALONE_TARGET := Rack
  32. STANDALONE_LDFLAGS += -Wl,-rpath=.
  33. endif
  34. ifdef ARCH_MAC
  35. SED := sed -i ''
  36. TARGET := libRack.dylib
  37. SOURCES += dep/osdialog/osdialog_mac.m
  38. LDFLAGS += -lpthread -ldl
  39. LDFLAGS += -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI
  40. LDFLAGS += -Wl,-all_load
  41. 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
  42. STANDALONE_TARGET := Rack
  43. STANDALONE_LDFLAGS += -stdlib=libc++
  44. # For LuaJIT to work inside plugins
  45. STANDALONE_LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000
  46. endif
  47. ifdef ARCH_WIN
  48. SED := sed -i
  49. TARGET := libRack.dll
  50. SOURCES += dep/osdialog/osdialog_win.c
  51. LDFLAGS += -municode
  52. LDFLAGS += -Wl,--export-all-symbols
  53. LDFLAGS += -Wl,--out-implib,$(TARGET).a
  54. LDFLAGS += -Wl,-Bstatic -Wl,--whole-archive
  55. 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
  56. LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive
  57. LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp
  58. STANDALONE_TARGET := Rack.exe
  59. STANDALONE_LDFLAGS += -mwindows
  60. STANDALONE_OBJECTS += build/Rack.res
  61. endif
  62. include compile.mk
  63. # Standalone adapter
  64. ifdef ARCH_MAC
  65. STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS)
  66. endif
  67. STANDALONE_OBJECTS += $(TARGET)
  68. -include $(STANDALONE_DEPENDENCIES)
  69. $(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(STANDALONE_SOURCES)
  70. $(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)
  71. # Convenience targets
  72. all: $(TARGET) $(STANDALONE_TARGET)
  73. dep:
  74. $(MAKE) -C dep
  75. run: $(STANDALONE_TARGET)
  76. ./$< -d
  77. runr: $(STANDALONE_TARGET)
  78. ./$<
  79. debug: $(STANDALONE_TARGET)
  80. ifdef ARCH_MAC
  81. lldb -- ./$< -d
  82. endif
  83. ifdef ARCH_WIN
  84. gdb --args ./$< -d
  85. endif
  86. ifdef ARCH_LIN
  87. gdb --args ./$< -d
  88. endif
  89. screenshot: $(STANDALONE_TARGET)
  90. ./$< -d -t 2
  91. perf: $(STANDALONE_TARGET)
  92. # Requires perf
  93. perf record --call-graph dwarf -o perf.data ./$< -d
  94. # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
  95. hotspot perf.data
  96. rm perf.data
  97. valgrind: $(STANDALONE_TARGET)
  98. # --gen-suppressions=yes
  99. # --leak-check=full
  100. valgrind --suppressions=valgrind.supp ./$< -d
  101. clean:
  102. rm -rfv build dist *.a Rack.res *.d $(TARGET) $(STANDALONE_TARGET)
  103. # For Windows resources
  104. build/%.res: %.rc
  105. ifdef ARCH_WIN
  106. windres $^ -O coff -o $@
  107. endif
  108. DIST_RES := res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt
  109. DIST_NAME := Rack-"$(VERSION)"-$(ARCH_OS_NAME)
  110. DIST_SDK_DIR := Rack-SDK
  111. DIST_SDK := Rack-SDK-$(VERSION).zip
  112. ifdef ARCH_MAC
  113. DIST_BUNDLE := VCV Rack $(VERSION_MAJOR).app
  114. else
  115. DIST_DIR := Rack$(VERSION_MAJOR)
  116. endif
  117. DIST_MD := $(wildcard *.md)
  118. DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
  119. # Target not supported for public use
  120. dist: $(TARGET) $(STANDALONE_TARGET) $(DIST_HTML)
  121. mkdir -p dist
  122. # Copy Rack to dist
  123. ifdef ARCH_LIN
  124. mkdir -p dist/"$(DIST_DIR)"
  125. cp $(TARGET) dist/"$(DIST_DIR)"/
  126. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  127. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  128. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  129. # Manually check that no nonstandard shared libraries are linked
  130. ldd dist/"$(DIST_DIR)"/$(TARGET)
  131. ldd dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  132. # Copy resources
  133. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  134. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  135. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  136. # Make ZIP
  137. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_DIR)"
  138. endif
  139. ifdef ARCH_MAC
  140. mkdir -p dist/"$(DIST_BUNDLE)"
  141. mkdir -p dist/"$(DIST_BUNDLE)"/Contents
  142. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/Resources
  143. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/MacOS
  144. cp $(TARGET) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  145. cp $(STANDALONE_TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/
  146. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  147. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  148. install_name_tool -change $(TARGET) @executable_path/../Resources/$(TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  149. # Manually check that no nonstandard shared libraries are linked
  150. otool -L dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  151. otool -L dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  152. # Copy resources
  153. cp Info.plist dist/"$(DIST_BUNDLE)"/Contents/
  154. $(SED) 's/{VERSION}/$(VERSION)/g' dist/"$(DIST_BUNDLE)"/Contents/Info.plist
  155. cp -R $(DIST_RES) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  156. cp $(DIST_HTML) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  157. cp -R icon.icns dist/"$(DIST_BUNDLE)"/Contents/Resources/
  158. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_BUNDLE)"/Contents/Resources/Fundamental.vcvplugin
  159. # Clean up and sign bundle
  160. xattr -cr dist/"$(DIST_BUNDLE)"
  161. codesign --verbose --sign "Developer ID Application: Andrew Belt (VRF26934X5)" --options runtime --entitlements Entitlements.plist --timestamp --deep dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET) dist/"$(DIST_BUNDLE)"
  162. codesign --verify --deep --strict --verbose=2 dist/"$(DIST_BUNDLE)"
  163. # Make ZIP
  164. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_BUNDLE)"
  165. endif
  166. ifdef ARCH_WIN
  167. mkdir -p dist/"$(DIST_DIR)"
  168. cp $(TARGET) dist/"$(DIST_DIR)"/
  169. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  170. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  171. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  172. # Copy resources
  173. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  174. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  175. cp /mingw64/bin/libwinpthread-1.dll dist/"$(DIST_DIR)"/
  176. cp /mingw64/bin/libstdc++-6.dll dist/"$(DIST_DIR)"/
  177. cp /mingw64/bin/libgcc_s_seh-1.dll dist/"$(DIST_DIR)"/
  178. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  179. # Make ZIP
  180. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_DIR)"
  181. # Make NSIS installer
  182. # pacman -S mingw-w64-x86_64-nsis
  183. makensis -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  184. endif
  185. # Build Rack SDK
  186. mkdir -p dist/"$(DIST_SDK_DIR)"
  187. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  188. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  189. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  190. ifdef ARCH_WIN
  191. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  192. endif
  193. cd dist && zip -q -9 -r "$(DIST_SDK)" "$(DIST_SDK_DIR)"
  194. # Target not supported for public use
  195. notarize:
  196. ifdef ARCH_MAC
  197. xcrun altool --notarize-app --primary-bundle-id=com.vcvrack.rack --username "andrew@vcvrack.com" --password "@keychain:notarize" --output-format xml --file dist/"$(DIST_NAME)".zip > dist/UploadInfo.plist
  198. # Wait for Apple's servers to approve the app
  199. while true; do \
  200. echo "Waiting on Apple servers..." ; \
  201. sleep 10 ; \
  202. xcrun altool --notarization-info `/usr/libexec/PlistBuddy -c "Print :notarization-upload:RequestUUID" dist/UploadInfo.plist` -u "andrew@vcvrack.com" -p @keychain:notarize --output-format xml > dist/RequestInfo.plist ; \
  203. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  204. break ; \
  205. fi ; \
  206. done
  207. # Mark app as notarized, check, and re-zip
  208. xcrun stapler staple dist/"$(DIST_BUNDLE)"
  209. spctl --assess --type execute --ignore-cache --no-cache -vv dist/"$(DIST_BUNDLE)"
  210. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_BUNDLE)"
  211. endif
  212. cleandist:
  213. rm -rfv dist
  214. # Plugin helpers
  215. plugins:
  216. ifdef CMD
  217. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  218. else
  219. for f in plugins/*; do $(MAKE) -C "$$f"; done
  220. endif
  221. # Includes
  222. .DEFAULT_GOAL := all
  223. .PHONY: all dep run debug clean dist upload src plugins