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.

269 lines
8.4KB

  1. RACK_DIR ?= .
  2. VERSION := 2.dev.$(shell git rev-parse --short HEAD)
  3. # VERSION := 2.0.0
  4. FLAGS += -DVERSION=$(VERSION)
  5. FLAGS += -Iinclude -Idep/include
  6. include arch.mk
  7. SED := perl -pi -e
  8. # Sources and build flags
  9. SOURCES += dep/nanovg/src/nanovg.c
  10. SOURCES += dep/osdialog/osdialog.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. STANDALONE_SOURCES += $(wildcard standalone/*.cpp)
  15. FLAGS += -fPIC
  16. LDFLAGS += -shared
  17. ifdef ARCH_LIN
  18. TARGET := libRack.so
  19. SOURCES += dep/osdialog/osdialog_gtk3.c
  20. build/dep/osdialog/osdialog_gtk3.c.o: FLAGS += $(shell pkg-config --cflags gtk+-3.0)
  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 += 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
  26. LDFLAGS += -Wl,--no-whole-archive
  27. LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack
  28. LDFLAGS += $(shell pkg-config --libs gtk+-3.0)
  29. STANDALONE_TARGET := Rack
  30. STANDALONE_LDFLAGS += -Wl,-rpath=.
  31. endif
  32. ifdef ARCH_MAC
  33. TARGET := libRack.dylib
  34. SOURCES += dep/osdialog/osdialog_mac.m
  35. LDFLAGS += -lpthread -ldl
  36. LDFLAGS += -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI
  37. LDFLAGS += -Wl,-all_load
  38. 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
  39. STANDALONE_TARGET := Rack
  40. STANDALONE_LDFLAGS += -stdlib=libc++
  41. # For LuaJIT to work inside plugins
  42. STANDALONE_LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000
  43. endif
  44. ifdef ARCH_WIN
  45. TARGET := libRack.dll
  46. SOURCES += dep/osdialog/osdialog_win.c
  47. LDFLAGS += -municode
  48. LDFLAGS += -Wl,--export-all-symbols
  49. LDFLAGS += -Wl,--out-implib,$(TARGET).a
  50. LDFLAGS += -Wl,-Bstatic -Wl,--whole-archive
  51. 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
  52. LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive
  53. LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp
  54. STANDALONE_TARGET := Rack.exe
  55. STANDALONE_LDFLAGS += -mwindows
  56. STANDALONE_OBJECTS += build/Rack.res
  57. endif
  58. include compile.mk
  59. # Standalone launcher
  60. ifdef ARCH_MAC
  61. STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS)
  62. endif
  63. STANDALONE_OBJECTS += $(patsubst %, build/%.o, $(STANDALONE_SOURCES))
  64. STANDALONE_DEPENDENCIES := $(patsubst %, build/%.d, $(STANDALONE_SOURCES))
  65. -include $(STANDALONE_DEPENDENCIES)
  66. $(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(TARGET)
  67. $(CXX) -o $@ $^ $(STANDALONE_LDFLAGS)
  68. # Convenience targets
  69. all: $(TARGET) $(STANDALONE_TARGET)
  70. dep:
  71. $(MAKE) -C dep
  72. run: $(STANDALONE_TARGET)
  73. ./$< -d
  74. runr: $(STANDALONE_TARGET)
  75. ./$<
  76. debug: $(STANDALONE_TARGET)
  77. ifdef ARCH_MAC
  78. lldb -- ./$< -d
  79. endif
  80. ifdef ARCH_WIN
  81. gdb --args ./$< -d
  82. endif
  83. ifdef ARCH_LIN
  84. gdb --args ./$< -d
  85. endif
  86. perf: $(STANDALONE_TARGET)
  87. # Requires perf
  88. perf record --call-graph dwarf -o perf.data ./$< -d
  89. # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
  90. hotspot perf.data
  91. rm perf.data
  92. valgrind: $(STANDALONE_TARGET)
  93. # --gen-suppressions=yes
  94. # --leak-check=full
  95. valgrind --suppressions=valgrind.supp ./$< -d
  96. clean:
  97. rm -rfv $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist
  98. # For Windows resources
  99. build/%.res: %.rc
  100. ifdef ARCH_WIN
  101. windres $^ -O coff -o $@
  102. endif
  103. DIST_RES := LICENSE* CHANGELOG.md res cacert.pem Core.json template.vcv
  104. DIST_NAME := Rack-$(VERSION)-$(ARCH)
  105. DIST_SDK := Rack-SDK-$(VERSION).zip
  106. # This target is not supported for public use
  107. dist: $(TARGET) $(STANDALONE_TARGET)
  108. rm -rf dist
  109. mkdir -p dist
  110. # Copy Rack to dist
  111. ifdef ARCH_LIN
  112. mkdir -p dist/Rack
  113. cp $(TARGET) dist/Rack/
  114. cp $(STANDALONE_TARGET) dist/Rack/
  115. $(STRIP) -s dist/Rack/$(TARGET)
  116. $(STRIP) -s dist/Rack/$(STANDALONE_TARGET)
  117. # Manually check that no nonstandard shared libraries are linked
  118. ldd dist/Rack/$(TARGET)
  119. ldd dist/Rack/$(STANDALONE_TARGET)
  120. # Copy resources
  121. cp -R $(DIST_RES) dist/Rack/
  122. cp Fundamental.vcvplugin dist/Rack/
  123. # Make ZIP
  124. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack
  125. endif
  126. ifdef ARCH_MAC
  127. mkdir -p dist/Rack.app
  128. mkdir -p dist/Rack.app/Contents
  129. cp Info.plist dist/Rack.app/Contents/
  130. $(SED) 's/{VERSION}/$(VERSION)/g' dist/Rack.app/Contents/Info.plist
  131. mkdir -p dist/Rack.app/Contents/MacOS
  132. cp $(TARGET) dist/Rack.app/Contents/MacOS/
  133. cp $(STANDALONE_TARGET) dist/Rack.app/Contents/MacOS/
  134. $(STRIP) -S dist/Rack.app/Contents/MacOS/$(TARGET)
  135. $(STRIP) -S dist/Rack.app/Contents/MacOS/$(STANDALONE_TARGET)
  136. install_name_tool -change $(TARGET) @executable_path/$(TARGET) dist/Rack.app/Contents/MacOS/$(STANDALONE_TARGET)
  137. # Manually check that no nonstandard shared libraries are linked
  138. otool -L dist/Rack.app/Contents/MacOS/$(TARGET)
  139. otool -L dist/Rack.app/Contents/MacOS/$(STANDALONE_TARGET)
  140. # Copy resources
  141. mkdir -p dist/Rack.app/Contents/Resources
  142. cp -R $(DIST_RES) dist/Rack.app/Contents/Resources/
  143. cp -R icon.icns dist/Rack.app/Contents/Resources/
  144. cp Fundamental.vcvplugin dist/Rack.app/Contents/Resources/
  145. # Clean up and sign bundle
  146. xattr -cr dist/Rack.app
  147. # This will only work if you have the private key to my certificate
  148. codesign --verbose --sign "Developer ID Application: Andrew Belt (VRF26934X5)" --options runtime --entitlements Entitlements.plist --deep dist/Rack.app
  149. codesign --verify --deep --strict --verbose=2 dist/Rack.app
  150. # Make ZIP
  151. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack.app
  152. endif
  153. ifdef ARCH_WIN
  154. mkdir -p dist/Rack
  155. cp $(TARGET) dist/Rack/
  156. cp $(STANDALONE_TARGET) dist/Rack/
  157. $(STRIP) -s dist/Rack/$(TARGET)
  158. $(STRIP) -s dist/Rack/$(STANDALONE_TARGET)
  159. # Copy resources
  160. cp -R $(DIST_RES) dist/Rack/
  161. cp /mingw64/bin/libwinpthread-1.dll dist/Rack/
  162. cp /mingw64/bin/libstdc++-6.dll dist/Rack/
  163. cp /mingw64/bin/libgcc_s_seh-1.dll dist/Rack/
  164. cp Fundamental.vcvplugin dist/Rack/
  165. # Make ZIP
  166. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack
  167. # Make NSIS installer
  168. # pacman -S mingw-w64-x86_64-nsis
  169. # makensis -DVERSION=$(VERSION) installer.nsi
  170. # mv installer.exe dist/$(DIST_NAME).exe
  171. endif
  172. # Build Rack SDK
  173. mkdir -p dist/Rack-SDK
  174. cp -R LICENSE* *.mk include helper.py dist/Rack-SDK/
  175. mkdir -p dist/Rack-SDK/dep/
  176. cp -R dep/include dist/Rack-SDK/dep/
  177. ifdef ARCH_WIN
  178. cp libRack.dll.a dist/Rack-SDK/
  179. endif
  180. cd dist && zip -q -9 -r $(DIST_SDK) Rack-SDK
  181. notarize:
  182. ifdef ARCH_MAC
  183. # This will only work if you have my Apple ID password in your keychain
  184. xcrun altool --notarize-app -f dist/Rack-$(VERSION)-$(ARCH).zip --primary-bundle-id=com.vcvrack.rack -u "andrewpbelt@gmail.com" -p @keychain:notarize --output-format xml > dist/UploadInfo.plist
  185. # Wait for Apple's servers to approve the app
  186. while true; do \
  187. echo "Waiting on Apple servers..." ; \
  188. 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 ; \
  189. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  190. break ; \
  191. fi ; \
  192. sleep 10 ; \
  193. done
  194. # Mark app as notarized, check, and re-zip
  195. xcrun stapler staple dist/Rack.app
  196. spctl --assess --type execute --ignore-cache --no-cache -vv dist/Rack.app
  197. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack.app
  198. endif
  199. UPLOAD_URL := vortico@vcvrack.com:files/
  200. upload:
  201. # This will only work if you have a private key to my server
  202. ifdef ARCH_MAC
  203. rsync dist/$(DIST_NAME).zip $(UPLOAD_URL) -zP
  204. endif
  205. ifdef ARCH_WIN
  206. rsync dist/$(DIST_NAME).zip dist/$(DIST_NAME).exe dist/$(DIST_SDK) $(UPLOAD_URL) -P
  207. endif
  208. ifdef ARCH_LIN
  209. rsync dist/$(DIST_NAME).zip $(UPLOAD_URL) -zP
  210. endif
  211. # Plugin helpers
  212. plugins:
  213. ifdef CMD
  214. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  215. else
  216. for f in plugins/*; do $(MAKE) -C "$$f"; done
  217. endif
  218. # Includes
  219. .DEFAULT_GOAL := all
  220. .PHONY: all dep run debug clean dist upload src plugins