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.

223 lines
6.7KB

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