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

3 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. # VERSION := 2.git.$(shell git rev-parse --short HEAD)
  4. VERSION := 2.0.4
  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_zenity.c
  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 += -static-libstdc++ -static-libgcc
  27. 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
  28. LDFLAGS += -Wl,--no-whole-archive
  29. LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack -lpulse -lpulse-simple
  30. STANDALONE_TARGET := Rack
  31. STANDALONE_LDFLAGS += -static-libstdc++ -static-libgcc
  32. STANDALONE_LDFLAGS += -Wl,-rpath=.
  33. endif
  34. ifdef ARCH_MAC
  35. SED := sed -i ''
  36. TARGET := libRack.dylib
  37. SOURCES += dep/osdialog/osdialog_mac.m
  38. LDFLAGS += -lpthread -ldl
  39. LDFLAGS += -framework SystemConfiguration -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI
  40. LDFLAGS += -Wl,-all_load
  41. 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
  42. STANDALONE_TARGET := Rack
  43. STANDALONE_LDFLAGS += -stdlib=libc++
  44. # For LuaJIT to work inside plugins
  45. STANDALONE_LDFLAGS += -Wl,-pagezero_size,10000 -Wl,-image_base,100000000
  46. endif
  47. ifdef ARCH_WIN
  48. SED := sed -i
  49. TARGET := libRack.dll
  50. SOURCES += dep/osdialog/osdialog_win.c
  51. LDFLAGS += -municode
  52. LDFLAGS += -Wl,--export-all-symbols
  53. LDFLAGS += -Wl,--out-implib,$(TARGET).a
  54. LDFLAGS += -Wl,-Bstatic -Wl,--whole-archive
  55. 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
  56. LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive
  57. LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp -lcrypt32
  58. STANDALONE_TARGET := Rack.exe
  59. STANDALONE_LDFLAGS += -mwindows
  60. STANDALONE_OBJECTS += build/Rack.res
  61. endif
  62. include compile.mk
  63. # Standalone adapter
  64. ifdef ARCH_MAC
  65. STANDALONE_LDFLAGS += $(MAC_SDK_FLAGS)
  66. endif
  67. STANDALONE_OBJECTS += $(TARGET)
  68. -include $(STANDALONE_DEPENDENCIES)
  69. $(STANDALONE_TARGET): $(STANDALONE_SOURCES) $(STANDALONE_OBJECTS)
  70. $(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)
  71. # Convenience targets
  72. all: $(TARGET) $(STANDALONE_TARGET)
  73. dep:
  74. $(MAKE) -C dep
  75. cleandep:
  76. $(MAKE) -C dep clean
  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 := RackFree-"$(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 NSIS installer
  189. # pacman -S mingw-w64-x86_64-nsis
  190. makensis -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  191. endif
  192. # Build Rack SDK
  193. mkdir -p dist/"$(DIST_SDK_DIR)"
  194. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  195. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  196. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  197. ifdef ARCH_LIN
  198. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  199. $(STRIP) -s dist/"$(DIST_SDK_DIR)"/$(TARGET)
  200. endif
  201. ifdef ARCH_MAC
  202. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  203. $(STRIP) -S dist/"$(DIST_SDK_DIR)"/$(TARGET)
  204. endif
  205. ifdef ARCH_WIN
  206. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  207. endif
  208. cd dist && zip -q -9 -r "$(DIST_SDK)" "$(DIST_SDK_DIR)"
  209. # Target not supported for public use
  210. notarize:
  211. ifdef ARCH_MAC
  212. 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
  213. # Wait for Apple's servers to approve the app
  214. while true; do \
  215. echo "Waiting on Apple servers..." ; \
  216. sleep 10 ; \
  217. 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 ; \
  218. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  219. break ; \
  220. fi ; \
  221. done
  222. # Mark app as notarized
  223. xcrun stapler staple dist/"$(DIST_NAME)".pkg
  224. # Check notarization
  225. stapler validate --verbose dist/"$(DIST_NAME)".pkg
  226. spctl --assess --type execute --ignore-cache --no-cache -vv dist/"$(DIST_BUNDLE)"
  227. endif
  228. cleandist:
  229. rm -rfv dist
  230. # Plugin helpers
  231. plugins:
  232. ifdef CMD
  233. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  234. else
  235. for f in plugins/*; do $(MAKE) -C "$$f"; done
  236. endif
  237. # Includes
  238. .DEFAULT_GOAL := all
  239. .PHONY: all dep run debug clean dist upload src plugins