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.

285 lines
9.7KB

  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. # VERSION := 2.git.$(shell git rev-parse --short HEAD)
  4. VERSION := 2.0.4
  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. 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_SOURCES) $(STANDALONE_OBJECTS)
  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 := RackFree-"$(VERSION)"-$(ARCH_OS_NAME)
  110. DIST_SDK_DIR := Rack-SDK
  111. DIST_SDK := Rack-SDK-"$(VERSION)"-$(ARCH_OS_NAME).zip
  112. ifdef ARCH_MAC
  113. DIST_BUNDLE := VCV Rack $(VERSION_MAJOR) Free.app
  114. else
  115. DIST_DIR := Rack$(VERSION_MAJOR)Free
  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. rm -rf dist
  122. mkdir -p dist
  123. # Copy Rack to dist
  124. ifdef ARCH_LIN
  125. mkdir -p dist/"$(DIST_DIR)"
  126. cp $(TARGET) dist/"$(DIST_DIR)"/
  127. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  128. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  129. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  130. # Manually check that no nonstandard shared libraries are linked
  131. ldd dist/"$(DIST_DIR)"/$(TARGET)
  132. ldd dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  133. # Copy resources
  134. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  135. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  136. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  137. # Make ZIP
  138. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_DIR)"
  139. endif
  140. ifdef ARCH_MAC
  141. mkdir -p dist/"$(DIST_BUNDLE)"
  142. mkdir -p dist/"$(DIST_BUNDLE)"/Contents
  143. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/Resources
  144. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/MacOS
  145. cp $(TARGET) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  146. cp $(STANDALONE_TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/
  147. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  148. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  149. install_name_tool -change $(TARGET) @executable_path/../Resources/$(TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  150. # Manually check that no nonstandard shared libraries are linked
  151. otool -L dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  152. otool -L dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  153. # Copy resources
  154. cp Info.plist dist/"$(DIST_BUNDLE)"/Contents/
  155. $(SED) 's/{VERSION}/$(VERSION)/g' dist/"$(DIST_BUNDLE)"/Contents/Info.plist
  156. cp -R $(DIST_RES) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  157. cp $(DIST_HTML) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  158. cp -R icon.icns dist/"$(DIST_BUNDLE)"/Contents/Resources/
  159. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_BUNDLE)"/Contents/Resources/Fundamental.vcvplugin
  160. # Clean up and sign bundle
  161. xattr -cr dist/"$(DIST_BUNDLE)"
  162. 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)"
  163. codesign --verify --deep --strict --verbose=2 dist/"$(DIST_BUNDLE)"
  164. # Make standalone PKG
  165. mkdir -p dist/Component
  166. cp -R dist/"$(DIST_BUNDLE)" dist/Component/
  167. pkgbuild --identifier com.vcvrack.rack --component-plist Component.plist --root dist/Component --install-location /Applications dist/Component.pkg
  168. # Make PKG
  169. productbuild --distribution Distribution.xml --package-path dist dist/"$(DIST_NAME)".pkg
  170. productsign --sign "Developer ID Installer: Andrew Belt (V8SW9J626X)" dist/"$(DIST_NAME)".pkg dist/"$(DIST_NAME)"-signed.pkg
  171. mv dist/"$(DIST_NAME)"-signed.pkg dist/"$(DIST_NAME)".pkg
  172. endif
  173. ifdef ARCH_WIN
  174. mkdir -p dist/"$(DIST_DIR)"
  175. cp $(TARGET) dist/"$(DIST_DIR)"/
  176. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  177. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  178. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  179. # Copy resources
  180. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  181. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  182. cp /mingw64/bin/libwinpthread-1.dll dist/"$(DIST_DIR)"/
  183. cp /mingw64/bin/libstdc++-6.dll dist/"$(DIST_DIR)"/
  184. cp /mingw64/bin/libgcc_s_seh-1.dll dist/"$(DIST_DIR)"/
  185. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  186. # Make NSIS installer
  187. # pacman -S mingw-w64-x86_64-nsis
  188. makensis -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  189. endif
  190. # Build Rack SDK
  191. mkdir -p dist/"$(DIST_SDK_DIR)"
  192. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  193. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  194. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  195. ifdef ARCH_LIN
  196. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  197. $(STRIP) -s dist/"$(DIST_SDK_DIR)"/$(TARGET)
  198. endif
  199. ifdef ARCH_MAC
  200. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  201. $(STRIP) -S dist/"$(DIST_SDK_DIR)"/$(TARGET)
  202. endif
  203. ifdef ARCH_WIN
  204. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  205. endif
  206. cd dist && zip -q -9 -r "$(DIST_SDK)" "$(DIST_SDK_DIR)"
  207. # Target not supported for public use
  208. notarize:
  209. ifdef ARCH_MAC
  210. 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
  211. # Wait for Apple's servers to approve the app
  212. while true; do \
  213. echo "Waiting on Apple servers..." ; \
  214. sleep 10 ; \
  215. 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 ; \
  216. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  217. break ; \
  218. fi ; \
  219. done
  220. # Mark app as notarized
  221. xcrun stapler staple dist/"$(DIST_NAME)".pkg
  222. # Check notarization
  223. stapler validate --verbose dist/"$(DIST_NAME)".pkg
  224. spctl --assess --type execute --ignore-cache --no-cache -vv dist/"$(DIST_BUNDLE)"
  225. endif
  226. cleandist:
  227. rm -rfv dist
  228. # Plugin helpers
  229. plugins:
  230. ifdef CMD
  231. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  232. else
  233. for f in plugins/*; do $(MAKE) -C "$$f"; done
  234. endif
  235. # Includes
  236. .DEFAULT_GOAL := all
  237. .PHONY: all dep run debug clean dist upload src plugins