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.

338 lines
11KB

  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.1
  18. DOCKER_IMAGE_VERSION := 12
  19. all: toolchain-all rack-sdk-all
  20. # Toolchain build
  21. toolchain-all: toolchain-lin toolchain-win toolchain-mac
  22. crosstool-ng := $(LOCAL_DIR)/bin/ct-ng
  23. $(crosstool-ng):
  24. git clone https://github.com/crosstool-ng/crosstool-ng.git
  25. cd crosstool-ng && git checkout e63c40854c977f488bee159a8f8ebf5fc06c8666
  26. cd crosstool-ng && ./bootstrap
  27. cd crosstool-ng && ./configure --prefix="$(LOCAL_DIR)"
  28. cd crosstool-ng && make -j $(JOBS)
  29. cd crosstool-ng && make install -j $(JOBS)
  30. rm -rf crosstool-ng
  31. toolchain-lin := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu
  32. toolchain-lin: $(toolchain-lin)
  33. $(toolchain-lin): $(crosstool-ng)
  34. ct-ng x86_64-ubuntu16.04-linux-gnu
  35. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  36. rm -rf .build .config build.log
  37. # HACK Copy GL and related include dirs to toolchain sysroot
  38. chmod +w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  39. cp -r /usr/include/GL $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  40. cp -r /usr/include/KHR $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  41. cp -r /usr/include/X11 $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  42. chmod -w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  43. toolchain-win := $(LOCAL_DIR)/x86_64-w64-mingw32
  44. toolchain-win: $(toolchain-win)
  45. $(toolchain-win): $(crosstool-ng)
  46. ct-ng x86_64-w64-mingw32
  47. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  48. rm -rf .build .config build.log /home/build/src
  49. OSXCROSS_CLANG_VERSION := 15.0.7
  50. OSXCROSS_BINUTILS_VERSION := 2.37
  51. toolchain-mac := $(LOCAL_DIR)/osxcross
  52. toolchain-mac: $(toolchain-mac)
  53. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  54. $(toolchain-mac):
  55. # Obtain osxcross sources.
  56. # FIXME Use official osxcross version when workaround from our fork are not required anymore.
  57. git clone "https://github.com/cschol/osxcross.git" osxcross
  58. cd osxcross && git checkout ae54314c24a959cd90ebb1f3aff3507677d36591
  59. # Build a custom clang compiler using the system's gcc compiler.
  60. # This enables us to have custom compiler environment needed for cross-compilation.
  61. cd osxcross && UNATTENDED=1 INSTALLPREFIX="$(LOCAL_DIR)" GITPROJECT=llvm CLANG_VERSION=$(OSXCROSS_CLANG_VERSION) OCDEBUG=1 ENABLE_CLANG_INSTALL=1 JOBS=$(JOBS) ./build_clang.sh
  62. ## Build osxcross.
  63. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  64. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  65. ## Build compiler-rt.
  66. cd osxcross && ENABLE_COMPILER_RT_INSTALL=1 JOBS=$(JOBS) ./build_compiler_rt.sh
  67. ## Build MacOS binutils and build LLVM gold.
  68. cd osxcross && BINUTILS_VERSION=$(OSXCROSS_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  69. cd osxcross/build/build_stage && cmake . -DLLVM_BINUTILS_INCDIR=$(PWD)/osxcross/build/binutils-$(OSXCROSS_BINUTILS_VERSION)/include && make install -j $(JOBS)
  70. # Fix library paths (for Arch Linux and Ubuntu arm64).
  71. export PLATFORM_ID=$$($(LOCAL_DIR)/bin/clang -dumpmachine) ; \
  72. echo "Platform ID: $$PLATFORM_ID" ; \
  73. if [ ! -z "$$PLATFORM_ID" ] && [ -e "$(LOCAL_DIR)/lib/$$PLATFORM_ID/" ]; then \
  74. echo "Copying lib files..." ; \
  75. cp -Pv $(LOCAL_DIR)/lib/$$PLATFORM_ID/* $(LOCAL_DIR)/lib/ ; \
  76. echo "done" ; \
  77. fi
  78. ## Download rcodesign binary to ad-hoc sign arm64 plugin builds in a cross-compilation environment.
  79. 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"
  80. tar -xvf apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz
  81. rm apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz
  82. cp ./apple-codesign-0.22.0-x86_64-unknown-linux-musl/rcodesign $(LOCAL_DIR)/osxcross/bin/
  83. rm -r apple-codesign-0.22.0-x86_64-unknown-linux-musl
  84. rm -rf osxcross
  85. toolchain-clean:
  86. rm -rf local osxcross .build build.log .config
  87. # Rack SDK
  88. rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64
  89. rack-sdk-mac-x64 := Rack-SDK-mac-x64
  90. rack-sdk-mac-x64: $(rack-sdk-mac-x64)
  91. $(rack-sdk-mac-x64):
  92. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip"
  93. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  94. mv Rack-SDK Rack-SDK-mac-x64
  95. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  96. RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64)
  97. rack-sdk-mac-arm64 := Rack-SDK-mac-arm64
  98. rack-sdk-mac-arm64: $(rack-sdk-mac-arm64)
  99. $(rack-sdk-mac-arm64):
  100. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip"
  101. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  102. mv Rack-SDK Rack-SDK-mac-arm64
  103. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  104. RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64)
  105. rack-sdk-win-x64 := Rack-SDK-win-x64
  106. rack-sdk-win-x64: $(rack-sdk-win-x64)
  107. $(rack-sdk-win-x64):
  108. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip"
  109. unzip Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  110. mv Rack-SDK Rack-SDK-win-x64
  111. rm Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  112. RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64)
  113. rack-sdk-lin-x64 := Rack-SDK-lin-x64
  114. rack-sdk-lin-x64: $(rack-sdk-lin-x64)
  115. $(rack-sdk-lin-x64):
  116. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip"
  117. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  118. mv Rack-SDK Rack-SDK-lin-x64
  119. rm Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  120. RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64)
  121. rack-sdk-clean:
  122. rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  123. # Plugin build
  124. PLUGIN_BUILD_DIR := plugin-build
  125. PLUGIN_DIR ?=
  126. plugin-build:
  127. $(MAKE) plugin-build-mac-x64
  128. $(MAKE) plugin-build-mac-arm64
  129. $(MAKE) plugin-build-win-x64
  130. $(MAKE) plugin-build-lin-x64
  131. plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  132. plugin-build-mac-x64: export CC := x86_64-apple-darwin20.2-clang
  133. plugin-build-mac-x64: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  134. plugin-build-mac-x64: export STRIP := x86_64-apple-darwin20.2-strip
  135. plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  136. plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin20.2-otool
  137. plugin-build-mac-x64: export CODESIGN := rcodesign sign
  138. plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  139. plugin-build-mac-arm64: export CC := arm64-apple-darwin20.2-clang
  140. plugin-build-mac-arm64: export CXX := arm64-apple-darwin20.2-clang++-libc++
  141. plugin-build-mac-arm64: export STRIP := arm64-apple-darwin20.2-strip
  142. plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin20.2-install_name_tool
  143. plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin20.2-otool
  144. plugin-build-mac-arm64: export CODESIGN := rcodesign sign
  145. plugin-build-win-x64: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  146. plugin-build-win-x64: export CC := x86_64-w64-mingw32-gcc
  147. plugin-build-win-x64: export CXX := x86_64-w64-mingw32-g++
  148. plugin-build-win-x64: export STRIP := x86_64-w64-mingw32-strip
  149. plugin-build-lin-x64: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  150. plugin-build-lin-x64: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  151. plugin-build-lin-x64: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  152. plugin-build-lin-x64: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  153. plugin-build-mac-x64: export RACK_DIR := $(RACK_DIR_MAC_X64)
  154. plugin-build-mac-arm64: export RACK_DIR := $(RACK_DIR_MAC_ARM64)
  155. plugin-build-win-x64: export RACK_DIR := $(RACK_DIR_WIN_X64)
  156. plugin-build-lin-x64: export RACK_DIR := $(RACK_DIR_LIN_X64)
  157. plugin-build-mac-x64 plugin-build-mac-arm64 plugin-build-win-x64 plugin-build-lin-x64:
  158. cd $(PLUGIN_DIR) && $(MAKE) clean
  159. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  160. cd $(PLUGIN_DIR) && $(MAKE) dep
  161. cd $(PLUGIN_DIR) && $(MAKE) dist
  162. mkdir -p $(PLUGIN_BUILD_DIR)
  163. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  164. cd $(PLUGIN_DIR) && $(MAKE) clean
  165. plugin-build-clean:
  166. rm -rf $(PLUGIN_BUILD_DIR)
  167. # Docker helpers
  168. dep-ubuntu:
  169. apt-get update
  170. apt-get install -y --no-install-recommends \
  171. ca-certificates \
  172. git \
  173. build-essential \
  174. autoconf \
  175. automake \
  176. bison \
  177. flex \
  178. gawk \
  179. libtool-bin \
  180. libncurses5-dev \
  181. unzip \
  182. zip \
  183. jq \
  184. libgl-dev \
  185. libglu-dev \
  186. git \
  187. wget \
  188. curl \
  189. cmake \
  190. nasm \
  191. xz-utils \
  192. file \
  193. python3 \
  194. libxml2-dev \
  195. libssl-dev \
  196. texinfo \
  197. help2man \
  198. libz-dev \
  199. rsync \
  200. xxd \
  201. perl \
  202. coreutils \
  203. zstd \
  204. markdown \
  205. libarchive-tools
  206. dep-arch-linux:
  207. pacman -Suyy --noconfirm && pacman -S --noconfirm --needed \
  208. gcc \
  209. git \
  210. cmake \
  211. patch \
  212. python3 \
  213. automake \
  214. help2man \
  215. texinfo \
  216. libtool \
  217. jq \
  218. rsync \
  219. autoconf \
  220. flex \
  221. bison \
  222. which \
  223. unzip \
  224. wget \
  225. glu \
  226. libx11 \
  227. mesa
  228. docker-build: rack-sdk-all
  229. docker build --build-arg JOBS=$(JOBS) --no-cache --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) . --progress=plain 2>&1 | tee docker-build.log
  230. DOCKER_RUN := docker run --rm --interactive --tty \
  231. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  232. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  233. --volume=$(PWD)/Rack-SDK-mac-x64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64 \
  234. --volume=$(PWD)/Rack-SDK-mac-arm64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64 \
  235. --volume=$(PWD)/Rack-SDK-win-x64:/home/build/rack-plugin-toolchain/Rack-SDK-win-x64 \
  236. --volume=$(PWD)/Rack-SDK-lin-x64:/home/build/rack-plugin-toolchain/Rack-SDK-lin-x64 \
  237. --env PLUGIN_DIR=/home/build/plugin-src \
  238. rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \
  239. /bin/bash
  240. docker-run:
  241. $(DOCKER_RUN)
  242. docker-plugin-build:
  243. mkdir -p $(PLUGIN_BUILD_DIR)
  244. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  245. docker-plugin-build-mac-x64:
  246. mkdir -p $(PLUGIN_BUILD_DIR)
  247. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-x64 $(MFLAGS)"
  248. docker-plugin-build-mac-arm64:
  249. mkdir -p $(PLUGIN_BUILD_DIR)
  250. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-arm64 $(MFLAGS)"
  251. docker-plugin-build-win-x64:
  252. mkdir -p $(PLUGIN_BUILD_DIR)
  253. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win-x64 $(MFLAGS)"
  254. docker-plugin-build-lin-x64:
  255. mkdir -p $(PLUGIN_BUILD_DIR)
  256. $(DOCKER_RUN) -c "$(MAKE) plugin-build-lin-x64 $(MFLAGS)"
  257. .NOTPARALLEL:
  258. .PHONY: all plugin-build