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