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.

256 lines
7.9KB

  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 += $(wildcard dep/jpommier-pffft-*/pffft.c) $(wildcard dep/jpommier-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_gtk2.c
  20. build/dep/osdialog/osdialog_gtk2.c.o: FLAGS += $(shell pkg-config --cflags gtk+-2.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/libzip.a dep/lib/libz.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+-2.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/libzip.a dep/lib/libz.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 += -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/libzip.a dep/lib/libz.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
  53. STANDALONE_TARGET := Rack.exe
  54. STANDALONE_LDFLAGS += -mwindows
  55. STANDALONE_OBJECTS += build/Rack.res
  56. endif
  57. include compile.mk
  58. # Standalone launcher
  59. ifdef ARCH_MAC
  60. STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS)
  61. endif
  62. STANDALONE_OBJECTS += $(patsubst %, build/%.o, $(STANDALONE_SOURCES))
  63. STANDALONE_DEPENDENCIES := $(patsubst %, build/%.d, $(STANDALONE_SOURCES))
  64. -include $(STANDALONE_DEPENDENCIES)
  65. $(STANDALONE_TARGET): $(STANDALONE_OBJECTS) $(TARGET)
  66. $(CXX) -o $@ $^ $(STANDALONE_LDFLAGS)
  67. # Convenience targets
  68. all: $(TARGET) $(STANDALONE_TARGET)
  69. dep:
  70. $(MAKE) -C dep
  71. run: $(STANDALONE_TARGET)
  72. ./$< -d
  73. runr: $(STANDALONE_TARGET)
  74. ./$<
  75. debug: $(STANDALONE_TARGET)
  76. ifdef ARCH_MAC
  77. lldb -- ./$< -d
  78. endif
  79. ifdef ARCH_WIN
  80. gdb --args ./$< -d
  81. endif
  82. ifdef ARCH_LIN
  83. gdb --args ./$< -d
  84. endif
  85. perf: $(STANDALONE_TARGET)
  86. # Requires perf
  87. perf record --call-graph dwarf -o perf.data ./$< -d
  88. # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
  89. hotspot perf.data
  90. rm perf.data
  91. valgrind: $(STANDALONE_TARGET)
  92. # --gen-suppressions=yes
  93. # --leak-check=full
  94. valgrind --suppressions=valgrind.supp ./$< -d
  95. clean:
  96. rm -rfv $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist
  97. # For Windows resources
  98. build/%.res: %.rc
  99. ifdef ARCH_WIN
  100. windres $^ -O coff -o $@
  101. endif
  102. DIST_RES := LICENSE* CHANGELOG.md res cacert.pem Core.json template.vcv
  103. DIST_NAME := Rack-$(VERSION)-$(ARCH)
  104. DIST_SDK := Rack-SDK-$(VERSION).zip
  105. # This target is not intended for public use
  106. dist: $(TARGET) $(STANDALONE_TARGET)
  107. rm -rf dist
  108. mkdir -p dist
  109. ifdef ARCH_LIN
  110. mkdir -p dist/Rack
  111. cp $(TARGET) $(STANDALONE_TARGET) dist/Rack/
  112. $(STRIP) -s dist/Rack/$(TARGET) dist/Rack/$(STANDALONE_TARGET)
  113. cp -R $(DIST_RES) dist/Rack/
  114. # Manually check that no nonstandard shared libraries are linked
  115. ldd dist/Rack/$(TARGET)
  116. # cp Fundamental.zip dist/Rack/
  117. # Make ZIP
  118. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack
  119. endif
  120. ifdef ARCH_MAC
  121. mkdir -p dist/Rack.app
  122. mkdir -p dist/Rack.app/Contents
  123. cp Info.plist dist/Rack.app/Contents/
  124. $(SED) 's/{VERSION}/$(VERSION)/g' dist/Rack.app/Contents/Info.plist
  125. mkdir -p dist/Rack.app/Contents/MacOS
  126. cp $(TARGET) dist/Rack.app/Contents/MacOS/
  127. $(STRIP) -S dist/Rack.app/Contents/MacOS/$(TARGET)
  128. mkdir -p dist/Rack.app/Contents/Resources
  129. cp -R $(DIST_RES) icon.icns dist/Rack.app/Contents/Resources/
  130. # Manually check that no nonstandard shared libraries are linked
  131. otool -L dist/Rack.app/Contents/MacOS/$(TARGET)
  132. cp Fundamental.zip dist/Rack.app/Contents/Resources/Fundamental.txt
  133. # Clean up and sign bundle
  134. xattr -cr dist/Rack.app
  135. # This will only work if you have the private key to my certificate
  136. codesign --verbose --sign "Developer ID Application: Andrew Belt (VRF26934X5)" --options runtime --entitlements Entitlements.plist --deep dist/Rack.app
  137. codesign --verify --deep --strict --verbose=2 dist/Rack.app
  138. # Make ZIP
  139. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack.app
  140. endif
  141. ifdef ARCH_WIN
  142. mkdir -p dist/Rack
  143. cp $(TARGET) $(STANDALONE_TARGET) dist/Rack/
  144. $(STRIP) -s dist/Rack/$(TARGET) dist/Rack/$(STANDALONE_TARGET)
  145. cp -R $(DIST_RES) dist/Rack/
  146. cp /mingw64/bin/libwinpthread-1.dll dist/Rack/
  147. cp /mingw64/bin/libstdc++-6.dll dist/Rack/
  148. cp /mingw64/bin/libgcc_s_seh-1.dll dist/Rack/
  149. # cp Fundamental.zip dist/Rack/
  150. # Make ZIP
  151. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack
  152. # Make NSIS installer
  153. # pacman -S mingw-w64-x86_64-nsis
  154. # makensis -DVERSION=$(VERSION) installer.nsi
  155. # mv installer.exe dist/$(DIST_NAME).exe
  156. endif
  157. # Rack SDK
  158. mkdir -p dist/Rack-SDK
  159. cp -R LICENSE* *.mk include helper.py dist/Rack-SDK/
  160. mkdir -p dist/Rack-SDK/dep/
  161. cp -R dep/include dist/Rack-SDK/dep/
  162. ifdef ARCH_WIN
  163. cp libRack.dll.a dist/Rack-SDK/
  164. endif
  165. cd dist && zip -q -9 -r $(DIST_SDK) Rack-SDK
  166. notarize:
  167. ifdef ARCH_MAC
  168. # This will only work if you have my Apple ID password in your keychain
  169. 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
  170. # Wait for Apple's servers to approve the app
  171. while true; do \
  172. echo "Waiting on Apple servers..." ; \
  173. 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 ; \
  174. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  175. break ; \
  176. fi ; \
  177. sleep 10 ; \
  178. done
  179. # Mark app as notarized, check, and re-zip
  180. xcrun stapler staple dist/Rack.app
  181. spctl --assess --type execute --ignore-cache --no-cache -vv dist/Rack.app
  182. cd dist && zip -q -9 -r $(DIST_NAME).zip Rack.app
  183. endif
  184. UPLOAD_URL := vortico@vcvrack.com:files/
  185. upload:
  186. # This will only work if you have a private key to my server
  187. ifdef ARCH_MAC
  188. rsync dist/$(DIST_NAME).zip $(UPLOAD_URL) -zP
  189. endif
  190. ifdef ARCH_WIN
  191. rsync dist/$(DIST_NAME).zip dist/$(DIST_NAME).exe dist/$(DIST_SDK) $(UPLOAD_URL) -P
  192. endif
  193. ifdef ARCH_LIN
  194. rsync dist/$(DIST_NAME).zip $(UPLOAD_URL) -zP
  195. endif
  196. # Plugin helpers
  197. plugins:
  198. ifdef CMD
  199. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  200. else
  201. for f in plugins/*; do $(MAKE) -C "$$f"; done
  202. endif
  203. # Includes
  204. .DEFAULT_GOAL := all
  205. .PHONY: all dep run debug clean dist upload src plugins