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.

219 lines
6.6KB

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