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.

302 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.3.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. # FIXME Use development version until fix for hanging build is merged to crosstool-ng repository.
  24. git clone https://github.com/cpackham/crosstool-ng.git
  25. cd crosstool-ng && git checkout a7835a0251e5acdb38d7cbf301457058266bcbca
  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. toolchain-mac := $(LOCAL_DIR)/osxcross
  50. toolchain-mac: $(toolchain-mac)
  51. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  52. $(toolchain-mac):
  53. # Download osxcross
  54. git clone "https://github.com/cschol/osxcross.git" osxcross
  55. cd osxcross && git checkout 12f179126df156fb65515cccf140f4b634967baa
  56. # Build osxcross
  57. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  58. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  59. # Build compiler-rt
  60. #cd osxcross && ENABLE_COMPILER_RT_INSTALL=1 JOBS=$(JOBS) ./build_compiler_rt.sh
  61. # Build Mac version of binutils and build LLVM gold
  62. #cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  63. #cd osxcross/build/build_stage && cmake . -DLLVM_BINUTILS_INCDIR=$(PWD)/osxcross/build/binutils-$(MAC_BINUTILS_VERSION)/include && make install -j $(JOBS)
  64. rm -rf osxcross
  65. rack-sdk-mac-x64 := Rack-SDK-mac-x64
  66. rack-sdk-mac-x64: $(rack-sdk-mac-x64)
  67. $(rack-sdk-mac-x64):
  68. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip"
  69. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  70. mv Rack-SDK Rack-SDK-mac-x64
  71. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  72. RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64)
  73. rack-sdk-mac-arm64 := Rack-SDK-mac-arm64
  74. rack-sdk-mac-arm64: $(rack-sdk-mac-arm64)
  75. $(rack-sdk-mac-arm64):
  76. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip"
  77. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  78. mv Rack-SDK Rack-SDK-mac-arm64
  79. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  80. RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64)
  81. rack-sdk-win-x64 := Rack-SDK-win-x64
  82. rack-sdk-win-x64: $(rack-sdk-win-x64)
  83. $(rack-sdk-win-x64):
  84. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip"
  85. unzip Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  86. mv Rack-SDK Rack-SDK-win-x64
  87. rm Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  88. RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64)
  89. rack-sdk-lin-x64 := Rack-SDK-lin-x64
  90. rack-sdk-lin-x64: $(rack-sdk-lin-x64)
  91. $(rack-sdk-lin-x64):
  92. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip"
  93. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  94. mv Rack-SDK Rack-SDK-lin-x64
  95. rm Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  96. RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64)
  97. rack-sdk-clean:
  98. rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  99. rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64
  100. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  101. toolchain-clean:
  102. rm -rf .build local osxcross $(rack-sdk-mac-x64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  103. # Plugin build
  104. PLUGIN_BUILD_DIR := plugin-build
  105. PLUGIN_DIR ?=
  106. plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  107. plugin-build-mac-x64: export CC := x86_64-apple-darwin20.2-clang
  108. plugin-build-mac-x64: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  109. plugin-build-mac-x64: export STRIP := x86_64-apple-darwin20.2-strip
  110. plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  111. plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin20.2-otool
  112. plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  113. plugin-build-mac-arm64: export CC := arm64-apple-darwin20.2-clang
  114. plugin-build-mac-arm64: export CXX := arm64-apple-darwin20.2-clang++-libc++
  115. plugin-build-mac-arm64: export STRIP := arm64-apple-darwin20.2-strip
  116. plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin20.2-install_name_tool
  117. plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin20.2-otool
  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