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.

289 lines
9.7KB

  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. # VERSION := 2.git.$(shell git rev-parse --short HEAD)
  4. VERSION := 2.1.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_zenity.c
  22. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  23. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  24. FLAGS += -fno-gnu-unique
  25. LDFLAGS += -Wl,--whole-archive
  26. LDFLAGS += -static-libstdc++ -static-libgcc
  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 -lpulse -lpulse-simple
  30. STANDALONE_TARGET := Rack
  31. STANDALONE_LDFLAGS += -static-libstdc++ -static-libgcc
  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 SystemConfiguration -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 -lcrypt32
  58. STANDALONE_TARGET := Rack.exe
  59. STANDALONE_LDFLAGS += -mwindows
  60. # 1MiB stack size to match MSVC
  61. STANDALONE_LDFLAGS += -Wl,--stack,0x100000
  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_OBJECTS += $(TARGET)
  70. -include $(STANDALONE_DEPENDENCIES)
  71. $(STANDALONE_TARGET): $(STANDALONE_SOURCES) $(STANDALONE_OBJECTS)
  72. $(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)
  73. # Convenience targets
  74. all: $(TARGET) $(STANDALONE_TARGET)
  75. dep:
  76. $(MAKE) -C dep
  77. cleandep:
  78. $(MAKE) -C dep clean
  79. run: $(STANDALONE_TARGET)
  80. ./$< -d
  81. runr: $(STANDALONE_TARGET)
  82. ./$<
  83. debug: $(STANDALONE_TARGET)
  84. ifdef ARCH_MAC
  85. lldb -- ./$< -d
  86. endif
  87. ifdef ARCH_WIN
  88. gdb --args ./$< -d
  89. endif
  90. ifdef ARCH_LIN
  91. gdb --args ./$< -d
  92. endif
  93. screenshot: $(STANDALONE_TARGET)
  94. ./$< -d -t 2
  95. perf: $(STANDALONE_TARGET)
  96. # Requires perf
  97. perf record --call-graph dwarf -o perf.data ./$< -d
  98. # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
  99. hotspot perf.data
  100. rm perf.data
  101. valgrind: $(STANDALONE_TARGET)
  102. # --gen-suppressions=yes
  103. # --leak-check=full
  104. valgrind --suppressions=valgrind.supp ./$< -d
  105. clean:
  106. rm -rfv build dist *.a Rack.res *.d $(TARGET) $(STANDALONE_TARGET)
  107. # For Windows resources
  108. build/%.res: %.rc
  109. ifdef ARCH_WIN
  110. windres $^ -O coff -o $@
  111. endif
  112. DIST_RES := res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt
  113. DIST_NAME := RackFree-"$(VERSION)"-$(ARCH_OS_NAME)
  114. DIST_SDK_DIR := Rack-SDK
  115. DIST_SDK := Rack-SDK-"$(VERSION)"-$(ARCH_OS_NAME).zip
  116. ifdef ARCH_MAC
  117. DIST_BUNDLE := VCV Rack $(VERSION_MAJOR) Free.app
  118. else
  119. DIST_DIR := Rack$(VERSION_MAJOR)Free
  120. endif
  121. DIST_MD := $(wildcard *.md)
  122. DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
  123. # Target not supported for public use
  124. dist: $(TARGET) $(STANDALONE_TARGET) $(DIST_HTML)
  125. rm -rf dist
  126. mkdir -p dist
  127. # Copy Rack to dist
  128. ifdef ARCH_LIN
  129. mkdir -p dist/"$(DIST_DIR)"
  130. cp $(TARGET) dist/"$(DIST_DIR)"/
  131. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  132. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  133. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  134. # Manually check that no nonstandard shared libraries are linked
  135. ldd dist/"$(DIST_DIR)"/$(TARGET)
  136. ldd dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  137. # Copy resources
  138. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  139. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  140. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  141. # Make ZIP
  142. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_DIR)"
  143. endif
  144. ifdef ARCH_MAC
  145. mkdir -p dist/"$(DIST_BUNDLE)"
  146. mkdir -p dist/"$(DIST_BUNDLE)"/Contents
  147. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/Resources
  148. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/MacOS
  149. cp $(TARGET) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  150. cp $(STANDALONE_TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/
  151. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  152. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  153. install_name_tool -change $(TARGET) @executable_path/../Resources/$(TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  154. # Manually check that no nonstandard shared libraries are linked
  155. otool -L dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  156. otool -L dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  157. # Copy resources
  158. cp Info.plist dist/"$(DIST_BUNDLE)"/Contents/
  159. $(SED) 's/{VERSION}/$(VERSION)/g' dist/"$(DIST_BUNDLE)"/Contents/Info.plist
  160. cp -R $(DIST_RES) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  161. cp $(DIST_HTML) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  162. cp -R icon.icns dist/"$(DIST_BUNDLE)"/Contents/Resources/
  163. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_BUNDLE)"/Contents/Resources/Fundamental.vcvplugin
  164. # Clean up and sign bundle
  165. xattr -cr dist/"$(DIST_BUNDLE)"
  166. 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)"
  167. codesign --verify --deep --strict --verbose=2 dist/"$(DIST_BUNDLE)"
  168. # Make standalone PKG
  169. mkdir -p dist/Component
  170. cp -R dist/"$(DIST_BUNDLE)" dist/Component/
  171. pkgbuild --identifier com.vcvrack.rack --component-plist Component.plist --root dist/Component --install-location /Applications dist/Component.pkg
  172. # Make PKG
  173. productbuild --distribution Distribution.xml --package-path dist dist/"$(DIST_NAME)".pkg
  174. productsign --sign "Developer ID Installer: Andrew Belt (V8SW9J626X)" dist/"$(DIST_NAME)".pkg dist/"$(DIST_NAME)"-signed.pkg
  175. mv dist/"$(DIST_NAME)"-signed.pkg dist/"$(DIST_NAME)".pkg
  176. endif
  177. ifdef ARCH_WIN
  178. mkdir -p dist/"$(DIST_DIR)"
  179. cp $(TARGET) dist/"$(DIST_DIR)"/
  180. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  181. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  182. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  183. # Copy resources
  184. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  185. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  186. cp /mingw64/bin/libwinpthread-1.dll dist/"$(DIST_DIR)"/
  187. cp /mingw64/bin/libstdc++-6.dll dist/"$(DIST_DIR)"/
  188. cp /mingw64/bin/libgcc_s_seh-1.dll dist/"$(DIST_DIR)"/
  189. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  190. # Make NSIS installer
  191. # pacman -S mingw-w64-x86_64-nsis
  192. makensis -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  193. endif
  194. # Build Rack SDK
  195. mkdir -p dist/"$(DIST_SDK_DIR)"
  196. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  197. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  198. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  199. ifdef ARCH_LIN
  200. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  201. $(STRIP) -s dist/"$(DIST_SDK_DIR)"/$(TARGET)
  202. endif
  203. ifdef ARCH_MAC
  204. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  205. $(STRIP) -S dist/"$(DIST_SDK_DIR)"/$(TARGET)
  206. endif
  207. ifdef ARCH_WIN
  208. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  209. endif
  210. cd dist && zip -q -9 -r "$(DIST_SDK)" "$(DIST_SDK_DIR)"
  211. # Target not supported for public use
  212. notarize:
  213. ifdef ARCH_MAC
  214. xcrun altool --notarize-app --primary-bundle-id "com.vcvrack.rack" --username "andrew@vcvrack.com" --password @keychain:notarize --output-format xml --file dist/"$(DIST_NAME)".pkg > dist/UploadInfo.plist
  215. # Wait for Apple's servers to approve the app
  216. while true; do \
  217. echo "Waiting on Apple servers..." ; \
  218. sleep 10 ; \
  219. 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 ; \
  220. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  221. break ; \
  222. fi ; \
  223. done
  224. # Mark app as notarized
  225. xcrun stapler staple dist/"$(DIST_NAME)".pkg
  226. # Check notarization
  227. stapler validate dist/"$(DIST_NAME)".pkg
  228. endif
  229. cleandist:
  230. rm -rfv dist
  231. # Plugin helpers
  232. plugins:
  233. ifdef CMD
  234. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  235. else
  236. for f in plugins/*; do $(MAKE) -C "$$f"; done
  237. endif
  238. # Includes
  239. .DEFAULT_GOAL := all
  240. .PHONY: all dep run debug clean dist upload src plugins