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.

300 lines
9.2KB

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