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.

273 lines
9.2KB

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