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.7KB

  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 := 9
  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 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. MAC_CLANG_VERSION := 12.0.1
  52. MAC_BINUTILS_VERSION := 2.37
  53. # Binaries from ./build.sh must be available in order to run ./build_binutils.sh
  54. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  55. $(toolchain-mac):
  56. # Download osxcross
  57. #git clone "https://github.com/tpoechtrager/osxcross.git" osxcross
  58. #cd osxcross && git checkout 0f87f567dfaf98460244471ad6c0f4311d62079c
  59. # FIXME Switch to my own branch for now until clang build fix is merged into osxcross
  60. git clone "https://github.com/cschol/osxcross.git" osxcross
  61. cd osxcross && git checkout 70181533b0af841336feb7f74ca1e3a7a81c9065
  62. # Build clang
  63. cd osxcross && UNATTENDED=1 DISABLE_BOOTSTRAP=1 INSTALLPREFIX="$(LOCAL_DIR)" CLANG_VERSION=$(MAC_CLANG_VERSION) OCDEBUG=1 JOBS=$(JOBS) ./build_clang.sh
  64. cd osxcross/build/llvm-$(MAC_CLANG_VERSION).src/build && make install -j $(JOBS)
  65. # Build osxcross
  66. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  67. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  68. # Build compiler-rt
  69. cd osxcross && ENABLE_COMPILER_RT_INSTALL=1 JOBS=$(JOBS) ./build_compiler_rt.sh
  70. # Build Mac version of binutils and build LLVM gold
  71. cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  72. 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)
  73. rm -rf osxcross
  74. rack-sdk-mac-x64 := Rack-SDK-mac-x64
  75. rack-sdk-mac-x64: $(rack-sdk-mac-x64)
  76. $(rack-sdk-mac-x64):
  77. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip"
  78. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  79. mv Rack-SDK Rack-SDK-mac-x64
  80. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip
  81. RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64)
  82. rack-sdk-mac-arm64 := Rack-SDK-mac-arm64
  83. rack-sdk-mac-arm64: $(rack-sdk-mac-arm64)
  84. $(rack-sdk-mac-arm64):
  85. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip"
  86. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  87. mv Rack-SDK Rack-SDK-mac-arm64
  88. rm Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip
  89. RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64)
  90. rack-sdk-win-x64 := Rack-SDK-win-x64
  91. rack-sdk-win-x64: $(rack-sdk-win-x64)
  92. $(rack-sdk-win-x64):
  93. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip"
  94. unzip Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  95. mv Rack-SDK Rack-SDK-win-x64
  96. rm Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip
  97. RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64)
  98. rack-sdk-lin-x64 := Rack-SDK-lin-x64
  99. rack-sdk-lin-x64: $(rack-sdk-lin-x64)
  100. $(rack-sdk-lin-x64):
  101. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip"
  102. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  103. mv Rack-SDK Rack-SDK-lin-x64
  104. rm Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip
  105. RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64)
  106. rack-sdk-clean:
  107. rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  108. rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64
  109. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  110. toolchain-clean:
  111. rm -rf .build local osxcross $(rack-sdk-mac-x64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  112. # Plugin build
  113. PLUGIN_BUILD_DIR := plugin-build
  114. PLUGIN_DIR ?=
  115. plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  116. plugin-build-mac-x64: export CC := x86_64-apple-darwin20.2-clang
  117. plugin-build-mac-x64: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  118. plugin-build-mac-x64: export STRIP := x86_64-apple-darwin20.2-strip
  119. plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  120. plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin20.2-otool
  121. plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  122. plugin-build-mac-arm64: export CC := arm64-apple-darwin20.2-clang
  123. plugin-build-mac-arm64: export CXX := arm64-apple-darwin20.2-clang++-libc++
  124. plugin-build-mac-arm64: export STRIP := arm64-apple-darwin20.2-strip
  125. plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin20.2-install_name_tool
  126. plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin20.2-otool
  127. plugin-build-win-x64: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  128. plugin-build-win-x64: export CC := x86_64-w64-mingw32-gcc
  129. plugin-build-win-x64: export CXX := x86_64-w64-mingw32-g++
  130. plugin-build-win-x64: export STRIP := x86_64-w64-mingw32-strip
  131. plugin-build-lin-x64: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  132. plugin-build-lin-x64: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  133. plugin-build-lin-x64: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  134. plugin-build-lin-x64: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  135. plugin-build-mac-x64: export RACK_DIR := $(RACK_DIR_MAC_X64)
  136. plugin-build-mac-arm64: export RACK_DIR := $(RACK_DIR_MAC_ARM64)
  137. plugin-build-win-x64: export RACK_DIR := $(RACK_DIR_WIN_X64)
  138. plugin-build-lin-x64: export RACK_DIR := $(RACK_DIR_LIN_X64)
  139. plugin-build-mac-x64 plugin-build-mac-arm64 plugin-build-win-x64 plugin-build-lin-x64:
  140. cd $(PLUGIN_DIR) && $(MAKE) clean
  141. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  142. cd $(PLUGIN_DIR) && $(MAKE) dep
  143. cd $(PLUGIN_DIR) && $(MAKE) dist
  144. mkdir -p $(PLUGIN_BUILD_DIR)
  145. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  146. cd $(PLUGIN_DIR) && $(MAKE) clean
  147. plugin-build:
  148. $(MAKE) plugin-build-mac-x64
  149. $(MAKE) plugin-build-win-x64
  150. $(MAKE) plugin-build-lin-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-lin-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