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.

Makefile 9.2KB

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