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.

301 lines
9.3KB

  1. # Installation path for executables
  2. LOCAL_DIR := $(PWD)/local
  3. # Local programs should have higher path priority than system-installed programs
  4. export PATH := $(LOCAL_DIR)/bin:$(PATH)
  5. # Allow specifying the number of jobs for toolchain build for systems that need it.
  6. # Due to different build systems used in the toolchain build, just `make -j` won't work here.
  7. # Note: Plugin build uses `$(MAKE)` to inherit `-j` argument from command line.
  8. ifdef JOBS
  9. export JOBS := $(JOBS)
  10. # Define number of jobs for crosstool-ng (uses different argument format)
  11. export JOBS_CT_NG := .$(JOBS)
  12. else
  13. # If `JOBS` is not specified, default to max number of jobs.
  14. export JOBS :=
  15. export JOBS_CT_NG :=
  16. endif
  17. RACK_SDK_VERSION := 2.4.0
  18. DOCKER_IMAGE_VERSION := 10
  19. all: toolchain-all
  20. # Toolchain build
  21. crosstool-ng := $(LOCAL_DIR)/bin/ct-ng
  22. $(crosstool-ng):
  23. git clone https://github.com/crosstool-ng/crosstool-ng.git
  24. cd crosstool-ng && git checkout e63c40854c977f488bee159a8f8ebf5fc06c8666
  25. cd crosstool-ng && ./bootstrap
  26. cd crosstool-ng && ./configure --prefix="$(LOCAL_DIR)"
  27. cd crosstool-ng && make -j $(JOBS)
  28. cd crosstool-ng && make install -j $(JOBS)
  29. rm -rf crosstool-ng
  30. toolchain-lin := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu
  31. toolchain-lin: $(toolchain-lin)
  32. $(toolchain-lin): $(crosstool-ng)
  33. ct-ng x86_64-ubuntu16.04-linux-gnu
  34. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  35. rm -rf .build .config build.log
  36. # HACK Copy GL and related include dirs to toolchain sysroot
  37. chmod +w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  38. cp -r /usr/include/GL $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  39. cp -r /usr/include/KHR $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  40. cp -r /usr/include/X11 $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  41. chmod -w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  42. toolchain-win := $(LOCAL_DIR)/x86_64-w64-mingw32
  43. toolchain-win: $(toolchain-win)
  44. $(toolchain-win): $(crosstool-ng)
  45. ct-ng x86_64-w64-mingw32
  46. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  47. rm -rf .build .config build.log /home/build/src
  48. toolchain-mac := $(LOCAL_DIR)/osxcross
  49. toolchain-mac: $(toolchain-mac)
  50. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  51. $(toolchain-mac):
  52. # Download osxcross
  53. git clone "https://github.com/cschol/osxcross.git" osxcross
  54. cd osxcross && git checkout 12f179126df156fb65515cccf140f4b634967baa
  55. # Build osxcross
  56. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  57. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  58. # Download rcodesign binary to ad-hoc sign arm64 plugin builds on Linux
  59. wget --continue https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz
  60. tar xvf apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz
  61. cp ./apple-codesign-0.22.0-x86_64-unknown-linux-musl/rcodesign $(LOCAL_DIR)/osxcross/bin/
  62. rm -f apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz
  63. rm -rf osxcross
  64. rack-sdk-mac-x64 := Rack-SDK-mac-x64
  65. rack-sdk-mac-x64: $(rack-sdk-mac-x64)
  66. $(rack-sdk-mac-x64):
  67. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip"
  68. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  69. mv Rack-SDK Rack-SDK-mac-x64
  70. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  71. RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64)
  72. rack-sdk-mac-arm64 := Rack-SDK-mac-arm64
  73. rack-sdk-mac-arm64: $(rack-sdk-mac-arm64)
  74. $(rack-sdk-mac-arm64):
  75. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip"
  76. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  77. mv Rack-SDK Rack-SDK-mac-arm64
  78. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  79. RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64)
  80. rack-sdk-win-x64 := Rack-SDK-win-x64
  81. rack-sdk-win-x64: $(rack-sdk-win-x64)
  82. $(rack-sdk-win-x64):
  83. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip"
  84. unzip Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  85. mv Rack-SDK Rack-SDK-win-x64
  86. rm Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  87. RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64)
  88. rack-sdk-lin-x64 := Rack-SDK-lin-x64
  89. rack-sdk-lin-x64: $(rack-sdk-lin-x64)
  90. $(rack-sdk-lin-x64):
  91. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip"
  92. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  93. mv Rack-SDK Rack-SDK-lin-x64
  94. rm Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  95. RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64)
  96. rack-sdk-clean:
  97. rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  98. rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64
  99. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  100. toolchain-clean:
  101. rm -rf .build local osxcross $(rack-sdk-mac-x64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64) $(rack-sdk-mac-arm64)
  102. # Plugin build
  103. PLUGIN_BUILD_DIR := plugin-build
  104. PLUGIN_DIR ?=
  105. plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  106. plugin-build-mac-x64: export CC := x86_64-apple-darwin20.2-clang
  107. plugin-build-mac-x64: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  108. plugin-build-mac-x64: export STRIP := x86_64-apple-darwin20.2-strip
  109. plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  110. plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin20.2-otool
  111. plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  112. plugin-build-mac-arm64: export CC := arm64-apple-darwin20.2-clang
  113. plugin-build-mac-arm64: export CXX := arm64-apple-darwin20.2-clang++-libc++
  114. plugin-build-mac-arm64: export STRIP := arm64-apple-darwin20.2-strip
  115. plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin20.2-install_name_tool
  116. plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin20.2-otool
  117. plugin-build-mac-arm64: export CODESIGN := "rcodesign sign"
  118. plugin-build-win-x64: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  119. plugin-build-win-x64: export CC := x86_64-w64-mingw32-gcc
  120. plugin-build-win-x64: export CXX := x86_64-w64-mingw32-g++
  121. plugin-build-win-x64: export STRIP := x86_64-w64-mingw32-strip
  122. plugin-build-lin-x64: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  123. plugin-build-lin-x64: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  124. plugin-build-lin-x64: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  125. plugin-build-lin-x64: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  126. plugin-build-mac-x64: export RACK_DIR := $(RACK_DIR_MAC_X64)
  127. plugin-build-mac-arm64: export RACK_DIR := $(RACK_DIR_MAC_ARM64)
  128. plugin-build-win-x64: export RACK_DIR := $(RACK_DIR_WIN_X64)
  129. plugin-build-lin-x64: export RACK_DIR := $(RACK_DIR_LIN_X64)
  130. plugin-build-mac-x64 plugin-build-mac-arm64 plugin-build-win-x64 plugin-build-lin-x64:
  131. cd $(PLUGIN_DIR) && $(MAKE) clean
  132. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  133. cd $(PLUGIN_DIR) && $(MAKE) dep
  134. cd $(PLUGIN_DIR) && $(MAKE) dist
  135. mkdir -p $(PLUGIN_BUILD_DIR)
  136. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  137. cd $(PLUGIN_DIR) && $(MAKE) clean
  138. plugin-build:
  139. $(MAKE) plugin-build-mac-x64
  140. $(MAKE) plugin-build-mac-arm64
  141. $(MAKE) plugin-build-win-x64
  142. $(MAKE) plugin-build-lin-x64
  143. plugin-build-clean:
  144. rm -rf $(PLUGIN_BUILD_DIR)
  145. # Docker helpers
  146. dep-ubuntu:
  147. apt-get update
  148. apt-get install -y --no-install-recommends \
  149. ca-certificates \
  150. git \
  151. build-essential \
  152. autoconf \
  153. automake \
  154. bison \
  155. flex \
  156. gawk \
  157. libtool-bin \
  158. libncurses5-dev \
  159. unzip \
  160. zip \
  161. jq \
  162. libgl-dev \
  163. libglu-dev \
  164. git \
  165. wget \
  166. curl \
  167. cmake \
  168. nasm \
  169. xz-utils \
  170. file \
  171. python3 \
  172. libxml2-dev \
  173. libssl-dev \
  174. texinfo \
  175. help2man \
  176. libz-dev \
  177. rsync \
  178. xxd \
  179. perl \
  180. coreutils \
  181. zstd \
  182. markdown \
  183. libarchive-tools
  184. dep-arch-linux:
  185. pacman -S --noconfirm --needed \
  186. git \
  187. cmake \
  188. patch \
  189. clang \
  190. python3 \
  191. automake \
  192. help2man \
  193. texinfo \
  194. libtool \
  195. jq \
  196. rsync \
  197. autoconf \
  198. flex \
  199. bison \
  200. which \
  201. unzip \
  202. wget \
  203. glu \
  204. libx11 \
  205. mesa
  206. docker-build: rack-sdk-all
  207. docker build --build-arg JOBS=$(JOBS) --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) .
  208. DOCKER_RUN := docker run --rm --interactive --tty \
  209. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  210. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  211. --volume=$(PWD)/Rack-SDK-mac-x64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64 \
  212. --volume=$(PWD)/Rack-SDK-mac-arm64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64 \
  213. --volume=$(PWD)/Rack-SDK-win-x64:/home/build/rack-plugin-toolchain/Rack-SDK-win-x64 \
  214. --volume=$(PWD)/Rack-SDK-lin-x64:/home/build/rack-plugin-toolchain/Rack-SDK-lin-x64 \
  215. --env PLUGIN_DIR=/home/build/plugin-src \
  216. rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \
  217. /bin/bash
  218. docker-run:
  219. $(DOCKER_RUN)
  220. docker-plugin-build-mac-x64:
  221. mkdir -p $(PLUGIN_BUILD_DIR)
  222. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-x64 $(MFLAGS)"
  223. docker-plugin-build-mac-arm64:
  224. mkdir -p $(PLUGIN_BUILD_DIR)
  225. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-arm64 $(MFLAGS)"
  226. docker-plugin-build-win-x64:
  227. mkdir -p $(PLUGIN_BUILD_DIR)
  228. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win-x64 $(MFLAGS)"
  229. docker-plugin-build-lin-x64:
  230. mkdir -p $(PLUGIN_BUILD_DIR)
  231. $(DOCKER_RUN) -c "$(MAKE) plugin-build-lin-x64 $(MFLAGS)"
  232. docker-plugin-build:
  233. mkdir -p $(PLUGIN_BUILD_DIR)
  234. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  235. .NOTPARALLEL:
  236. .PHONY: all plugin-build