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.

292 lines
9.6KB

  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.2.0
  18. DOCKER_IMAGE_VERSION := 6
  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. # Use development version to avoid zlib issue until proper release is available
  25. cd crosstool-ng && git checkout 82346dd7dfe7ed20dc8ec71e193c2d3b1930e22d
  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 include dir 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. 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. MAC_CLANG_VERSION := 12.0.1
  50. MAC_BINUTILS_VERSION := 2.37
  51. # Binaries from ./build.sh must be available in order to run ./build_binutils.sh
  52. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  53. $(toolchain-mac):
  54. # Download osxcross
  55. #git clone "https://github.com/tpoechtrager/osxcross.git" osxcross
  56. #cd osxcross && git checkout 0f87f567dfaf98460244471ad6c0f4311d62079c
  57. # FIXME Switch to my own branch for now until clang build fix is merged into osxcross
  58. git clone "https://github.com/cschol/osxcross.git" osxcross
  59. cd osxcross && git checkout 70181533b0af841336feb7f74ca1e3a7a81c9065
  60. # Build clang
  61. cd osxcross && UNATTENDED=1 DISABLE_BOOTSTRAP=1 INSTALLPREFIX="$(LOCAL_DIR)" CLANG_VERSION=$(MAC_CLANG_VERSION) OCDEBUG=1 JOBS=$(JOBS) ./build_clang.sh
  62. cd osxcross/build/llvm-$(MAC_CLANG_VERSION).src/build && make install -j $(JOBS)
  63. # Build osxcross
  64. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  65. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  66. # Build compiler-rt
  67. cd osxcross && ENABLE_COMPILER_RT_INSTALL=1 JOBS=$(JOBS) ./build_compiler_rt.sh
  68. # Build Mac version of binutils and build LLVM gold
  69. cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  70. cd osxcross/build/llvm-$(MAC_CLANG_VERSION).src/build && cmake .. -DLLVM_BINUTILS_INCDIR=$(PWD)/osxcross/build/binutils-$(MAC_BINUTILS_VERSION)/include && make install -j $(JOBS)
  71. rm -rf osxcross
  72. rack-sdk-mac-x64 := Rack-SDK-mac-x64
  73. rack-sdk-mac-x64: $(rack-sdk-mac-x64)
  74. $(rack-sdk-mac-x64):
  75. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip"
  76. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  77. mv Rack-SDK Rack-SDK-mac-x64
  78. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  79. RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64)
  80. rack-sdk-mac-arm64 := Rack-SDK-mac-arm64
  81. rack-sdk-mac-arm64: $(rack-sdk-mac-arm64)
  82. $(rack-sdk-mac-arm64):
  83. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip"
  84. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  85. mv Rack-SDK Rack-SDK-mac-arm64
  86. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  87. RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64)
  88. rack-sdk-win-x64 := Rack-SDK-win-x64
  89. rack-sdk-win-x64: $(rack-sdk-win-x64)
  90. $(rack-sdk-win-x64):
  91. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip"
  92. unzip Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  93. mv Rack-SDK Rack-SDK-win-x64
  94. rm Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  95. RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64)
  96. rack-sdk-lin-x64 := Rack-SDK-lin-x64
  97. rack-sdk-lin-x64: $(rack-sdk-lin-x64)
  98. $(rack-sdk-lin-x64):
  99. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip"
  100. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  101. mv Rack-SDK Rack-SDK-lin-x64
  102. rm Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  103. RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64)
  104. rack-sdk-clean:
  105. rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  106. rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64
  107. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  108. toolchain-clean:
  109. rm -rf .build local osxcross $(rack-sdk-mac-x64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  110. # Plugin build
  111. PLUGIN_BUILD_DIR := plugin-build
  112. PLUGIN_DIR ?=
  113. plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  114. plugin-build-mac-x64: export CC := x86_64-apple-darwin20.2-clang
  115. plugin-build-mac-x64: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  116. plugin-build-mac-x64: export STRIP := x86_64-apple-darwin20.2-strip
  117. plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  118. plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin20.2-otool
  119. plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  120. plugin-build-mac-arm64: export CC := arm64-apple-darwin20.2-clang
  121. plugin-build-mac-arm64: export CXX := arm64-apple-darwin20.2-clang++-libc++
  122. plugin-build-mac-arm64: export STRIP := arm64-apple-darwin20.2-strip
  123. plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin20.2-install_name_tool
  124. plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin20.2-otool
  125. plugin-build-win-x64: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  126. plugin-build-win-x64: export CC := x86_64-w64-mingw32-gcc
  127. plugin-build-win-x64: export CXX := x86_64-w64-mingw32-g++
  128. plugin-build-win-x64: export STRIP := x86_64-w64-mingw32-strip
  129. plugin-build-linux-x64: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  130. plugin-build-linux-x64: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  131. plugin-build-linux-x64: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  132. plugin-build-linux-x64: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  133. plugin-build-mac-x64: export RACK_DIR := $(RACK_DIR_MAC_X64)
  134. plugin-build-mac-arm64: export RACK_DIR := $(RACK_DIR_MAC_ARM64)
  135. plugin-build-win-x64: export RACK_DIR := $(RACK_DIR_WIN_X64)
  136. plugin-build-linux-x64: export RACK_DIR := $(RACK_DIR_LIN_X64)
  137. plugin-build-mac-x64 plugin-build-mac-arm64 plugin-build-win-x64 plugin-build-linux-x64:
  138. cd $(PLUGIN_DIR) && $(MAKE) clean
  139. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  140. cd $(PLUGIN_DIR) && $(MAKE) dep
  141. cd $(PLUGIN_DIR) && $(MAKE) dist
  142. mkdir -p $(PLUGIN_BUILD_DIR)
  143. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  144. cd $(PLUGIN_DIR) && $(MAKE) clean
  145. plugin-build:
  146. $(MAKE) plugin-build-mac-x64
  147. # FIXME Disabled until Rack SDK is updated.
  148. # $(MAKE) plugin-build-mac-arm64
  149. $(MAKE) plugin-build-win-x64
  150. $(MAKE) plugin-build-linux-x64
  151. plugin-build-clean:
  152. rm -rf $(PLUGIN_BUILD_DIR)
  153. # Docker helpers
  154. dep-ubuntu:
  155. apt-get update
  156. apt-get install -y --no-install-recommends \
  157. ca-certificates \
  158. git \
  159. build-essential \
  160. autoconf \
  161. automake \
  162. bison \
  163. flex \
  164. gawk \
  165. libtool-bin \
  166. libncurses5-dev \
  167. unzip \
  168. zip \
  169. jq \
  170. libgl-dev \
  171. libglu-dev \
  172. git \
  173. wget \
  174. curl \
  175. cmake \
  176. nasm \
  177. xz-utils \
  178. file \
  179. python3 \
  180. libxml2-dev \
  181. libssl-dev \
  182. texinfo \
  183. help2man \
  184. libz-dev \
  185. rsync \
  186. xxd \
  187. perl \
  188. coreutils \
  189. zstd \
  190. markdown
  191. dep-arch-linux:
  192. # TODO Complete this list
  193. sudo pacman -S --needed \
  194. wget \
  195. help2man
  196. docker-build: rack-sdk-all
  197. docker build --build-arg JOBS=$(JOBS) --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) .
  198. DOCKER_RUN := docker run --rm --interactive --tty \
  199. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  200. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  201. --volume=$(PWD)/Rack-SDK-mac-x64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64 \
  202. --volume=$(PWD)/Rack-SDK-mac-arm64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64 \
  203. --volume=$(PWD)/Rack-SDK-win-x64:/home/build/rack-plugin-toolchain/Rack-SDK-win-x64 \
  204. --volume=$(PWD)/Rack-SDK-lin-x64:/home/build/rack-plugin-toolchain/Rack-SDK-lin-x64 \
  205. --env PLUGIN_DIR=/home/build/plugin-src \
  206. rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \
  207. /bin/bash
  208. docker-run:
  209. $(DOCKER_RUN)
  210. docker-plugin-build-mac-x64:
  211. mkdir -p $(PLUGIN_BUILD_DIR)
  212. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-x64 $(MFLAGS)"
  213. docker-plugin-build-mac-arm64:
  214. mkdir -p $(PLUGIN_BUILD_DIR)
  215. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-arm64 $(MFLAGS)"
  216. docker-plugin-build-win-x64:
  217. mkdir -p $(PLUGIN_BUILD_DIR)
  218. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win-x64 $(MFLAGS)"
  219. docker-plugin-build-lin-x64:
  220. mkdir -p $(PLUGIN_BUILD_DIR)
  221. $(DOCKER_RUN) -c "$(MAKE) plugin-build-linux-x64 $(MFLAGS)"
  222. docker-plugin-build:
  223. mkdir -p $(PLUGIN_BUILD_DIR)
  224. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  225. .NOTPARALLEL:
  226. .PHONY: all plugin-build