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.

271 lines
9.2KB

  1. RACK_DIR ?= .
  2. EDITION := CE
  3. EDITION_NAME := Community Edition
  4. VERSION_MAJOR := 2
  5. VERSION := 2.dev.$(shell git rev-parse --short HEAD)
  6. # VERSION := 2.0.0
  7. FLAGS += -DVERSION=$(VERSION)
  8. FLAGS += -Iinclude -Idep/include
  9. include arch.mk
  10. SED := perl -pi -e
  11. # Sources and build flags
  12. SOURCES += dep/nanovg/src/nanovg.c
  13. SOURCES += dep/osdialog/osdialog.c
  14. SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
  15. SOURCES += $(wildcard src/*.c src/*/*.c)
  16. SOURCES += $(wildcard src/*.cpp src/*/*.cpp)
  17. STANDALONE_SOURCES += adapters/standalone.cpp
  18. FLAGS += -fPIC
  19. LDFLAGS += -shared
  20. ifdef ARCH_LIN
  21. TARGET := libRack.so
  22. SOURCES += dep/osdialog/osdialog_gtk3.c
  23. build/dep/osdialog/osdialog_gtk3.c.o: FLAGS += $(shell pkg-config --cflags gtk+-3.0)
  24. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  25. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  26. FLAGS += -fno-gnu-unique
  27. LDFLAGS += -Wl,--whole-archive
  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
  31. LDFLAGS += $(shell pkg-config --libs gtk+-3.0)
  32. STANDALONE_TARGET := Rack
  33. STANDALONE_LDFLAGS += -Wl,-rpath=.
  34. endif
  35. ifdef ARCH_MAC
  36. TARGET := libRack.dylib
  37. SOURCES += dep/osdialog/osdialog_mac.m
  38. LDFLAGS += -lpthread -ldl
  39. LDFLAGS += -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. TARGET := libRack.dll
  49. SOURCES += dep/osdialog/osdialog_win.c
  50. LDFLAGS += -municode
  51. LDFLAGS += -Wl,--export-all-symbols
  52. LDFLAGS += -Wl,--out-implib,$(TARGET).a
  53. LDFLAGS += -Wl,-Bstatic -Wl,--whole-archive
  54. LDFLAGS += dep/lib/libglew32.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/libarchive.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
  55. LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive
  56. LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp
  57. STANDALONE_TARGET := Rack.exe
  58. STANDALONE_LDFLAGS += -mwindows
  59. STANDALONE_OBJECTS += build/Rack.res
  60. endif
  61. include compile.mk
  62. # Standalone adapter
  63. ifdef ARCH_MAC
  64. STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS)
  65. endif
  66. STANDALONE_OBJECTS += $(patsubst %, build/%.o, $(STANDALONE_SOURCES))
  67. STANDALONE_DEPENDENCIES := $(patsubst %, build/%.d, $(STANDALONE_SOURCES))
  68. -include $(STANDALONE_DEPENDENCIES)
  69. $(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(TARGET)
  70. $(CXX) -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 $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist
  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
  109. DIST_NAME := Rack-$(EDITION)-"$(VERSION)"-$(ARCH)
  110. DIST_SDK_DIR := Rack-SDK
  111. DIST_SDK := Rack-SDK-$(VERSION).zip
  112. ifdef ARCH_MAC
  113. DIST_BUNDLE := VCV Rack $(EDITION) $(VERSION_MAJOR).app
  114. else
  115. DIST_DIR := Rack$(EDITION)$(VERSION_MAJOR)
  116. endif
  117. DIST_MD := $(wildcard *.md)
  118. DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
  119. # This target is 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)"/Fundamental.vcvplugin
  160. # Clean up and sign bundle
  161. xattr -cr dist/"$(DIST_BUNDLE)"
  162. # This will only work if you have the private key to my certificate
  163. codesign --verbose --sign "Developer ID Application: Andrew Belt (VRF26934X5)" --options runtime --entitlements Entitlements.plist --deep dist/"$(DIST_BUNDLE)"
  164. codesign --verify --deep --strict --verbose=2 dist/"$(DIST_BUNDLE)"
  165. # Make ZIP
  166. cd dist && zip -q -9 -r $(DIST_NAME).zip "$(DIST_BUNDLE)"
  167. endif
  168. ifdef ARCH_WIN
  169. mkdir -p dist/"$(DIST_DIR)"
  170. cp $(TARGET) dist/"$(DIST_DIR)"/
  171. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  172. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  173. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  174. # Copy resources
  175. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  176. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  177. cp /mingw64/bin/libwinpthread-1.dll dist/"$(DIST_DIR)"/
  178. cp /mingw64/bin/libstdc++-6.dll dist/"$(DIST_DIR)"/
  179. cp /mingw64/bin/libgcc_s_seh-1.dll dist/"$(DIST_DIR)"/
  180. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  181. # Make ZIP
  182. cd dist && zip -q -9 -r $(DIST_NAME).zip "$(DIST_DIR)"
  183. # Make NSIS installer
  184. # pacman -S mingw-w64-x86_64-nsis
  185. makensis -DEDITION="$(EDITION)" -DEDITION_NAME="$(EDITION_NAME)" -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  186. endif
  187. # Build Rack SDK
  188. mkdir -p dist/"$(DIST_SDK_DIR)"
  189. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  190. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  191. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  192. ifdef ARCH_WIN
  193. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  194. endif
  195. cd dist && zip -q -9 -r $(DIST_SDK) "$(DIST_SDK_DIR)"
  196. notarize:
  197. ifdef ARCH_MAC
  198. # This will only work if you have my Apple ID password in your keychain
  199. xcrun altool --notarize-app -f dist/"$(DIST_BUNDLE)"-"$(VERSION)"-$(ARCH).zip --primary-bundle-id=com.vcvrack.rack -u "andrewpbelt@gmail.com" -p @keychain:notarize --output-format xml > dist/UploadInfo.plist
  200. # Wait for Apple's servers to approve the app
  201. while true; do \
  202. echo "Waiting on Apple servers..." ; \
  203. xcrun altool --notarization-info `/usr/libexec/PlistBuddy -c "Print :notarization-upload:RequestUUID" dist/UploadInfo.plist` -u "andrewpbelt@gmail.com" -p @keychain:notarize --output-format xml > dist/RequestInfo.plist ; \
  204. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  205. break ; \
  206. fi ; \
  207. sleep 10 ; \
  208. done
  209. # Mark app as notarized, check, and re-zip
  210. xcrun stapler staple dist/"$(DIST_BUNDLE)"
  211. spctl --assess --type execute --ignore-cache --no-cache -vv dist/"$(DIST_BUNDLE)"
  212. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_BUNDLE)"
  213. endif
  214. # Plugin helpers
  215. plugins:
  216. ifdef CMD
  217. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  218. else
  219. for f in plugins/*; do $(MAKE) -C "$$f"; done
  220. endif
  221. # Includes
  222. .DEFAULT_GOAL := all
  223. .PHONY: all dep run debug clean dist upload src plugins