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.

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