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.9KB

3 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. # VERSION := 2.git.$(shell git rev-parse --short HEAD)
  4. VERSION := 2.beta.1
  5. FLAGS += -Iinclude -Idep/include
  6. include arch.mk
  7. # Sources and build flags
  8. SOURCES += dep/nanovg/src/nanovg.c
  9. SOURCES += dep/osdialog/osdialog.c
  10. SOURCES += dep/oui-blendish/blendish.c
  11. SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
  12. SOURCES += $(wildcard src/*.c src/*/*.c)
  13. SOURCES += $(wildcard src/*.cpp src/*/*.cpp)
  14. build/src/common.cpp.o: FLAGS += -D_APP_VERSION=$(VERSION)
  15. STANDALONE_SOURCES += adapters/standalone.cpp
  16. FLAGS += -fPIC
  17. LDFLAGS += -shared
  18. ifdef ARCH_LIN
  19. SED := sed -i
  20. TARGET := libRack.so
  21. SOURCES += dep/osdialog/osdialog_gtk3.c
  22. build/dep/osdialog/osdialog_gtk3.c.o: FLAGS += $(shell pkg-config --cflags gtk+-3.0)
  23. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  24. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  25. FLAGS += -fno-gnu-unique
  26. LDFLAGS += -Wl,--whole-archive
  27. LDFLAGS += -static-libstdc++ -static-libgcc
  28. 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
  29. LDFLAGS += -Wl,--no-whole-archive
  30. LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack -lpulse -lpulse-simple
  31. LDFLAGS += $(shell pkg-config --libs gtk+-3.0)
  32. STANDALONE_TARGET := Rack
  33. STANDALONE_LDFLAGS += -static-libstdc++ -static-libgcc
  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 SystemConfiguration -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_static.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 -lcrypt32
  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_SOURCES) $(STANDALONE_OBJECTS)
  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-"$(VERSION)"-$(ARCH_OS_NAME)
  112. DIST_SDK_DIR := Rack-SDK
  113. DIST_SDK := Rack-SDK-"$(VERSION)"-$(ARCH_OS_NAME).zip
  114. ifdef ARCH_MAC
  115. DIST_BUNDLE := VCV Rack $(VERSION_MAJOR) Free.app
  116. else
  117. DIST_DIR := Rack$(VERSION_MAJOR)Free
  118. endif
  119. DIST_MD := $(wildcard *.md)
  120. DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
  121. # Target 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)"/Contents/Resources/Fundamental.vcvplugin
  162. # Clean up and sign bundle
  163. xattr -cr dist/"$(DIST_BUNDLE)"
  164. codesign --verbose --sign "Developer ID Application: Andrew Belt (VRF26934X5)" --options runtime --entitlements Entitlements.plist --timestamp --deep dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET) dist/"$(DIST_BUNDLE)"
  165. codesign --verify --deep --strict --verbose=2 dist/"$(DIST_BUNDLE)"
  166. # Make standalone PKG
  167. mkdir -p dist/Component
  168. cp -R dist/"$(DIST_BUNDLE)" dist/Component/
  169. pkgbuild --identifier com.vcvrack.rack --component-plist Component.plist --root dist/Component --install-location /Applications dist/Component.pkg
  170. # Make PKG
  171. productbuild --distribution Distribution.xml --package-path dist dist/"$(DIST_NAME)".pkg
  172. productsign --sign "Developer ID Installer: Andrew Belt (V8SW9J626X)" dist/"$(DIST_NAME)".pkg dist/"$(DIST_NAME)"-signed.pkg
  173. mv dist/"$(DIST_NAME)"-signed.pkg dist/"$(DIST_NAME)".pkg
  174. endif
  175. ifdef ARCH_WIN
  176. mkdir -p dist/"$(DIST_DIR)"
  177. cp $(TARGET) dist/"$(DIST_DIR)"/
  178. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  179. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  180. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  181. # Copy resources
  182. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  183. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  184. cp /mingw64/bin/libwinpthread-1.dll dist/"$(DIST_DIR)"/
  185. cp /mingw64/bin/libstdc++-6.dll dist/"$(DIST_DIR)"/
  186. cp /mingw64/bin/libgcc_s_seh-1.dll dist/"$(DIST_DIR)"/
  187. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  188. # Make ZIP
  189. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_DIR)"
  190. # Make NSIS installer
  191. # pacman -S mingw-w64-x86_64-nsis
  192. makensis -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  193. endif
  194. # Build Rack SDK
  195. mkdir -p dist/"$(DIST_SDK_DIR)"
  196. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  197. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  198. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  199. ifdef ARCH_LIN
  200. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  201. $(STRIP) -s dist/"$(DIST_SDK_DIR)"/$(TARGET)
  202. endif
  203. ifdef ARCH_MAC
  204. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  205. $(STRIP) -S dist/"$(DIST_SDK_DIR)"/$(TARGET)
  206. endif
  207. ifdef ARCH_WIN
  208. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  209. endif
  210. cd dist && zip -q -9 -r "$(DIST_SDK)" "$(DIST_SDK_DIR)"
  211. # Target not supported for public use
  212. notarize:
  213. ifdef ARCH_MAC
  214. xcrun altool --notarize-app --primary-bundle-id "com.vcvrack.rack" --username "andrew@vcvrack.com" --password @keychain:notarize --output-format xml --file dist/"$(DIST_NAME)".pkg > dist/UploadInfo.plist
  215. # Wait for Apple's servers to approve the app
  216. while true; do \
  217. echo "Waiting on Apple servers..." ; \
  218. sleep 10 ; \
  219. xcrun altool --notarization-info `/usr/libexec/PlistBuddy -c "Print :notarization-upload:RequestUUID" dist/UploadInfo.plist` -u "andrew@vcvrack.com" -p @keychain:notarize --output-format xml > dist/RequestInfo.plist ; \
  220. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  221. break ; \
  222. fi ; \
  223. done
  224. # Mark app as notarized
  225. xcrun stapler staple dist/"$(DIST_NAME)".pkg
  226. # Check notarization
  227. stapler validate --verbose dist/"$(DIST_NAME)".pkg
  228. spctl --assess --type execute --ignore-cache --no-cache -vv dist/"$(DIST_BUNDLE)"
  229. endif
  230. cleandist:
  231. rm -rfv dist
  232. # Plugin helpers
  233. plugins:
  234. ifdef CMD
  235. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  236. else
  237. for f in plugins/*; do $(MAKE) -C "$$f"; done
  238. endif
  239. # Includes
  240. .DEFAULT_GOAL := all
  241. .PHONY: all dep run debug clean dist upload src plugins