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.6KB

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