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.

307 lines
9.3KB

  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. VERSION := $(shell jq -r .version Core.json)
  4. FLAGS += -Iinclude -Idep/include
  5. include arch.mk
  6. # Sources and build flags
  7. SOURCES += dep/nanovg/src/nanovg.c
  8. SOURCES += dep/osdialog/osdialog.c
  9. SOURCES += dep/oui-blendish/blendish.c
  10. SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
  11. SOURCES += dep/tinyexpr/tinyexpr.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. build/dep/tinyexpr/tinyexpr.c.o: FLAGS += -DTE_POW_FROM_RIGHT -DTE_NAT_LOG
  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. endif
  31. ifdef ARCH_MAC
  32. SED := sed -i ''
  33. TARGET := libRack.dylib
  34. SOURCES += $(wildcard src/*.m src/*/*.m)
  35. SOURCES += $(wildcard src/*.mm src/*/*.mm)
  36. SOURCES += dep/osdialog/osdialog_mac.m
  37. LDFLAGS += -lpthread -ldl
  38. LDFLAGS += -framework SystemConfiguration -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI -framework AVFoundation
  39. LDFLAGS += -Wl,-all_load
  40. 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 -Wl,-load_hidden,dep/lib/libarchive.a -Wl,-load_hidden,dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a -Wl,-load_hidden,dep/lib/librtmidi.a -Wl,-load_hidden,dep/lib/librtaudio.a
  41. endif
  42. ifdef ARCH_WIN
  43. SED := sed -i
  44. TARGET := libRack.dll
  45. SOURCES += dep/osdialog/osdialog_win.c
  46. LDFLAGS += -municode
  47. LDFLAGS += -Wl,--export-all-symbols
  48. LDFLAGS += -Wl,--out-implib,$(TARGET).a
  49. LDFLAGS += -Wl,-Bstatic -Wl,--whole-archive
  50. 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
  51. LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive
  52. LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp -lcrypt32
  53. endif
  54. # Some libraries aren't needed by plugins and might conflict with DAWs that load libRack, so make their symbols local to libRack instead of global (default).
  55. # --exclude-libs is unavailable on Apple ld
  56. ifndef ARCH_MAC
  57. LDFLAGS += -Wl,--exclude-libs,libzstd.a
  58. LDFLAGS += -Wl,--exclude-libs,libarchive.a
  59. LDFLAGS += -Wl,--exclude-libs,librtmidi.a
  60. LDFLAGS += -Wl,--exclude-libs,librtaudio.a
  61. endif
  62. include compile.mk
  63. # Standalone adapter
  64. STANDALONE_SOURCES += adapters/standalone.cpp
  65. ifdef ARCH_LIN
  66. STANDALONE_TARGET := Rack
  67. STANDALONE_LDFLAGS += -static-libstdc++ -static-libgcc
  68. STANDALONE_LDFLAGS += -Wl,-rpath=.
  69. endif
  70. ifdef ARCH_MAC
  71. STANDALONE_TARGET := Rack
  72. STANDALONE_LDFLAGS += -stdlib=libc++
  73. endif
  74. ifdef ARCH_WIN
  75. STANDALONE_TARGET := Rack.exe
  76. STANDALONE_LDFLAGS += -mwindows
  77. # 1MiB stack size to match MSVC
  78. STANDALONE_LDFLAGS += -Wl,--stack,0x100000
  79. STANDALONE_OBJECTS += build/Rack.res
  80. endif
  81. STANDALONE_OBJECTS += $(TARGET)
  82. $(STANDALONE_TARGET): $(STANDALONE_SOURCES) $(STANDALONE_OBJECTS)
  83. $(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)
  84. # Convenience targets
  85. all: $(TARGET) $(STANDALONE_TARGET)
  86. dep:
  87. $(MAKE) -C dep
  88. cleandep:
  89. $(MAKE) -C dep clean
  90. run: $(STANDALONE_TARGET)
  91. ./$< -d
  92. runr: $(STANDALONE_TARGET)
  93. ./$<
  94. debug: $(STANDALONE_TARGET)
  95. ifdef ARCH_MAC
  96. lldb -- ./$< -d
  97. endif
  98. ifdef ARCH_WIN
  99. gdb --args ./$< -d
  100. endif
  101. ifdef ARCH_LIN
  102. gdb --args ./$< -d
  103. endif
  104. perf: $(STANDALONE_TARGET)
  105. # Requires perf
  106. perf record --call-graph dwarf -o perf.data ./$< -d
  107. # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
  108. hotspot perf.data
  109. rm perf.data
  110. valgrind: $(STANDALONE_TARGET)
  111. # --gen-suppressions=yes
  112. # --leak-check=full
  113. valgrind --suppressions=valgrind.supp ./$< -d
  114. clean:
  115. rm -rfv build dist $(TARGET) $(STANDALONE_TARGET) *.a
  116. # Windows resources
  117. build/%.res: %.rc
  118. ifdef ARCH_WIN
  119. windres $^ -O coff -o $@
  120. endif
  121. # Plugin helper
  122. plugins:
  123. ifdef CMD
  124. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  125. else
  126. for f in plugins/*; do $(MAKE) -C "$$f"; done
  127. endif
  128. # The following targets are not supported for public use
  129. DIST_NAME := RackFree-$(VERSION)-$(ARCH_NAME)
  130. ifdef ARCH_MAC
  131. DIST_BUNDLE := VCV\ Rack\ $(VERSION_MAJOR)\ Free.app
  132. DIST_DIR := dist/$(DIST_BUNDLE)
  133. else
  134. DIST_DIR := dist/Rack$(VERSION_MAJOR)Free
  135. endif
  136. DIST_MD := $(wildcard *.md)
  137. DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
  138. DIST_RES := res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt $(DIST_HTML)
  139. DIST_SDK_DIR := dist/Rack-SDK
  140. DIST_SDK := dist/Rack-SDK-$(VERSION)-$(ARCH_NAME).zip
  141. dist: $(DIST_DIR)
  142. $(DIST_DIR): $(TARGET) $(STANDALONE_TARGET) $(DIST_HTML)
  143. mkdir -p dist
  144. ifdef ARCH_LIN
  145. mkdir -p $(DIST_DIR)
  146. cp $(TARGET) $(DIST_DIR)/
  147. cp $(STANDALONE_TARGET) $(DIST_DIR)/
  148. $(STRIP) -s $(DIST_DIR)/$(TARGET)
  149. $(STRIP) -s $(DIST_DIR)/$(STANDALONE_TARGET)
  150. # Manually check that no nonstandard shared libraries are linked
  151. ldd $(DIST_DIR)/$(TARGET)
  152. ldd $(DIST_DIR)/$(STANDALONE_TARGET)
  153. # Copy resources
  154. cp -R $(DIST_RES) $(DIST_DIR)/
  155. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin $(DIST_DIR)/
  156. endif
  157. ifdef ARCH_MAC
  158. mkdir -p $(DIST_DIR)
  159. mkdir -p $(DIST_DIR)/Contents
  160. mkdir -p $(DIST_DIR)/Contents/Resources
  161. mkdir -p $(DIST_DIR)/Contents/MacOS
  162. cp $(TARGET) $(DIST_DIR)/Contents/Resources/
  163. cp $(STANDALONE_TARGET) $(DIST_DIR)/Contents/MacOS/
  164. $(STRIP) -S $(DIST_DIR)/Contents/Resources/$(TARGET)
  165. $(STRIP) -S $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
  166. install_name_tool -change $(TARGET) @executable_path/../Resources/$(TARGET) $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
  167. # Manually check that no nonstandard shared libraries are linked
  168. otool -L $(DIST_DIR)/Contents/Resources/$(TARGET)
  169. otool -L $(DIST_DIR)/Contents/MacOS/$(STANDALONE_TARGET)
  170. # Copy resources
  171. cp Info.plist $(DIST_DIR)/Contents/
  172. $(SED) 's/{VERSION}/$(VERSION)/g' $(DIST_DIR)/Contents/Info.plist
  173. cp -R icon.icns $(DIST_DIR)/Contents/Resources/
  174. cp -R $(DIST_RES) $(DIST_DIR)/Contents/Resources/
  175. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin $(DIST_DIR)/Contents/Resources/
  176. endif
  177. ifdef ARCH_WIN
  178. mkdir -p $(DIST_DIR)
  179. cp $(TARGET) $(DIST_DIR)/
  180. cp $(STANDALONE_TARGET) $(DIST_DIR)/
  181. $(STRIP) -s $(DIST_DIR)/$(TARGET)
  182. $(STRIP) -s $(DIST_DIR)/$(STANDALONE_TARGET)
  183. # Copy resources
  184. cp -R $(DIST_RES) $(DIST_DIR)/
  185. cp /mingw64/bin/libwinpthread-1.dll $(DIST_DIR)/
  186. cp /mingw64/bin/libstdc++-6.dll $(DIST_DIR)/
  187. cp /mingw64/bin/libgcc_s_seh-1.dll $(DIST_DIR)/
  188. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin $(DIST_DIR)/
  189. endif
  190. sdk: $(DIST_SDK_DIR)
  191. $(DIST_SDK_DIR): $(DIST_HTML)
  192. mkdir -p $(DIST_SDK_DIR)
  193. cp -R include *.mk helper.py $(DIST_HTML) $(DIST_SDK_DIR)/
  194. mkdir -p $(DIST_SDK_DIR)/dep
  195. cp -R dep/include $(DIST_SDK_DIR)/dep/
  196. ifdef ARCH_LIN
  197. cp $(TARGET) $(DIST_SDK_DIR)/
  198. $(STRIP) -s $(DIST_SDK_DIR)/$(TARGET)
  199. endif
  200. ifdef ARCH_MAC
  201. cp $(TARGET) $(DIST_SDK_DIR)/
  202. $(STRIP) -S $(DIST_SDK_DIR)/$(TARGET)
  203. endif
  204. ifdef ARCH_WIN
  205. cp $(TARGET).a $(DIST_SDK_DIR)/
  206. endif
  207. package: $(DIST_DIR) $(DIST_SDK_DIR)
  208. ifdef ARCH_LIN
  209. # Make ZIP
  210. cd dist && zip -q -9 -r ../$(DIST_NAME).zip $(notdir $(DIST_DIR))
  211. endif
  212. ifdef ARCH_MAC
  213. # Clean up and sign bundle
  214. xattr -cr $(DIST_DIR)
  215. codesign --verbose --sign "Developer ID Application: Andrew Belt (V8SW9J626X)" --options runtime --entitlements Entitlements.plist --timestamp --deep $(DIST_DIR)/Contents/Resources/$(TARGET) $(DIST_DIR)
  216. codesign --verify --deep --strict --verbose=2 $(DIST_DIR)
  217. # Make standalone PKG
  218. mkdir -p dist/Component
  219. cp -R $(DIST_DIR) dist/Component/
  220. pkgbuild --identifier com.vcvrack.rack --component-plist Component.plist --root dist/Component --install-location /Applications dist/Component.pkg
  221. # Make PKG
  222. productbuild --distribution Distribution.xml --package-path dist dist/$(DIST_NAME).pkg
  223. productsign --sign "Developer ID Installer: Andrew Belt (V8SW9J626X)" dist/$(DIST_NAME).pkg dist/$(DIST_NAME)-signed.pkg
  224. mv dist/$(DIST_NAME)-signed.pkg dist/$(DIST_NAME).pkg
  225. endif
  226. ifdef ARCH_WIN
  227. # Make NSIS installer
  228. # pacman -S mingw-w64-x86_64-nsis
  229. makensis -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION=$(VERSION) "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  230. endif
  231. # SDK
  232. cd dist && zip -q -9 -r ../$(DIST_SDK) $(notdir $(DIST_SDK_DIR))
  233. notarize:
  234. ifdef ARCH_MAC
  235. # Submit installer package to Apple
  236. xcrun notarytool submit --keychain-profile "VCV" --wait dist/$(DIST_NAME).pkg
  237. # Mark app as notarized
  238. xcrun stapler staple dist/$(DIST_NAME).pkg
  239. # Check notarization
  240. stapler validate dist/$(DIST_NAME).pkg
  241. endif
  242. install: dist
  243. ifdef ARCH_MAC
  244. sudo installer -pkg dist/$(DIST_NAME).pkg -target /
  245. endif
  246. uninstall:
  247. ifdef ARCH_MAC
  248. sudo rm -rf /Applications/$(DIST_BUNDLE)
  249. endif
  250. cleandist:
  251. rm -rfv dist
  252. .DEFAULT_GOAL := all
  253. .PHONY: all dep run debug clean dist upload src plugins