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.

290 lines
9.8KB

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