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.

260 lines
7.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.1.2
  18. DOCKER_IMAGE_VERSION := 4
  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. cd crosstool-ng && git checkout crosstool-ng-1.25.0
  25. cd crosstool-ng && ./bootstrap
  26. cd crosstool-ng && ./configure --prefix="$(LOCAL_DIR)"
  27. cd crosstool-ng && make -j $(JOBS)
  28. cd crosstool-ng && make install -j $(JOBS)
  29. rm -rf crosstool-ng
  30. toolchain-lin := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu
  31. toolchain-lin: $(toolchain-lin)
  32. $(toolchain-lin): $(crosstool-ng)
  33. ct-ng x86_64-ubuntu16.04-linux-gnu
  34. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  35. rm -rf .build .config build.log
  36. # HACK Copy GL include dir to toolchain sysroot
  37. chmod +w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  38. cp -r /usr/include/GL $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  39. chmod -w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  40. toolchain-win := $(LOCAL_DIR)/x86_64-w64-mingw32
  41. toolchain-win: $(toolchain-win)
  42. $(toolchain-win): $(crosstool-ng)
  43. ct-ng x86_64-w64-mingw32
  44. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  45. rm -rf .build .config build.log /home/build/src
  46. toolchain-mac := $(LOCAL_DIR)/osxcross
  47. toolchain-mac: $(toolchain-mac)
  48. MAC_CLANG_VERSION := 12.0.1
  49. MAC_BINUTILS_VERSION := 2.37
  50. # Binaries from ./build.sh must be available in order to run ./build_binutils.sh
  51. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  52. $(toolchain-mac):
  53. # Download osxcross
  54. git clone "https://github.com/tpoechtrager/osxcross.git" osxcross
  55. cd osxcross && git checkout 0f87f567dfaf98460244471ad6c0f4311d62079c
  56. # Build clang
  57. cd osxcross && UNATTENDED=1 DISABLE_BOOTSTRAP=1 INSTALLPREFIX="$(LOCAL_DIR)" CLANG_VERSION=$(MAC_CLANG_VERSION) OCDEBUG=1 JOBS=$(JOBS) ./build_clang.sh
  58. cd osxcross/build/llvm-$(MAC_CLANG_VERSION).src/build && make install -j $(JOBS)
  59. # Build osxcross
  60. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  61. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  62. # Build Mac version of binutils and build LLVM gold
  63. cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  64. 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)
  65. rm -rf osxcross
  66. rack-sdk-mac := Rack-SDK-mac
  67. rack-sdk-mac: $(rack-sdk-mac)
  68. $(rack-sdk-mac):
  69. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac.zip"
  70. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac.zip
  71. mv Rack-SDK Rack-SDK-mac
  72. rm Rack-SDK-$(RACK_SDK_VERSION)-mac.zip
  73. RACK_DIR_MAC := $(PWD)/$(rack-sdk-mac)
  74. rack-sdk-win := Rack-SDK-win
  75. rack-sdk-win: $(rack-sdk-win)
  76. $(rack-sdk-win):
  77. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win.zip"
  78. unzip Rack-SDK-$(RACK_SDK_VERSION)-win.zip
  79. mv Rack-SDK Rack-SDK-win
  80. rm Rack-SDK-$(RACK_SDK_VERSION)-win.zip
  81. RACK_DIR_WIN := $(PWD)/$(rack-sdk-win)
  82. rack-sdk-lin := Rack-SDK-lin
  83. rack-sdk-lin: $(rack-sdk-lin)
  84. $(rack-sdk-lin):
  85. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin.zip"
  86. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin.zip
  87. mv Rack-SDK Rack-SDK-lin
  88. rm Rack-SDK-$(RACK_SDK_VERSION)-lin.zip
  89. RACK_DIR_LIN := $(PWD)/$(rack-sdk-lin)
  90. rack-sdk-clean:
  91. rm -rf Rack-SDK-mac Rack-SDK-win Rack-SDK-lin
  92. rack-sdk-all: rack-sdk-mac rack-sdk-win rack-sdk-lin
  93. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  94. toolchain-clean:
  95. rm -rf local osxcross $(rack-sdk-mac) $(rack-sdk-win) $(rack-sdk-lin)
  96. # Plugin build
  97. PLUGIN_BUILD_DIR := plugin-build
  98. PLUGIN_DIR ?=
  99. plugin-build-mac: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  100. plugin-build-mac: export CC := x86_64-apple-darwin20.2-clang
  101. plugin-build-mac: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  102. plugin-build-mac: export STRIP := x86_64-apple-darwin20.2-strip
  103. plugin-build-mac: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  104. plugin-build-mac: export OTOOL := x86_64-apple-darwin20.2-otool
  105. plugin-build-win: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  106. plugin-build-win: export CC := x86_64-w64-mingw32-gcc
  107. plugin-build-win: export CXX := x86_64-w64-mingw32-g++
  108. plugin-build-win: export STRIP := x86_64-w64-mingw32-strip
  109. plugin-build-linux: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  110. plugin-build-linux: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  111. plugin-build-linux: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  112. plugin-build-linux: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  113. plugin-build-mac: export RACK_DIR := $(RACK_DIR_MAC)
  114. plugin-build-win: export RACK_DIR := $(RACK_DIR_WIN)
  115. plugin-build-linux: export RACK_DIR := $(RACK_DIR_LIN)
  116. plugin-build-mac plugin-build-win plugin-build-linux:
  117. cd $(PLUGIN_DIR) && $(MAKE) clean
  118. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  119. cd $(PLUGIN_DIR) && $(MAKE) dep
  120. cd $(PLUGIN_DIR) && $(MAKE) dist
  121. mkdir -p $(PLUGIN_BUILD_DIR)
  122. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  123. cd $(PLUGIN_DIR) && $(MAKE) clean
  124. plugin-build:
  125. $(MAKE) plugin-build-mac
  126. $(MAKE) plugin-build-win
  127. $(MAKE) plugin-build-linux
  128. plugin-build-clean:
  129. rm -rf $(PLUGIN_BUILD_DIR)
  130. # Docker helpers
  131. dep-ubuntu:
  132. apt-get update
  133. apt-get install -y --no-install-recommends \
  134. ca-certificates \
  135. git \
  136. build-essential \
  137. autoconf \
  138. automake \
  139. bison \
  140. flex \
  141. gawk \
  142. libtool-bin \
  143. libncurses5-dev \
  144. unzip \
  145. zip \
  146. jq \
  147. libgl-dev \
  148. libglu-dev \
  149. git \
  150. wget \
  151. curl \
  152. cmake \
  153. nasm \
  154. xz-utils \
  155. file \
  156. python3 \
  157. libxml2-dev \
  158. libssl-dev \
  159. texinfo \
  160. help2man \
  161. libz-dev \
  162. rsync \
  163. xxd \
  164. perl \
  165. coreutils \
  166. zstd \
  167. markdown
  168. dep-arch-linux:
  169. # TODO Complete this list
  170. sudo pacman -S --needed \
  171. wget \
  172. help2man
  173. docker-build: rack-sdk-all
  174. docker build --build-arg JOBS=$(JOBS) --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) .
  175. DOCKER_RUN := docker run --rm --interactive --tty \
  176. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  177. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  178. --volume=$(PWD)/Rack-SDK-mac:/home/build/rack-plugin-toolchain/Rack-SDK-mac \
  179. --volume=$(PWD)/Rack-SDK-win:/home/build/rack-plugin-toolchain/Rack-SDK-win \
  180. --volume=$(PWD)/Rack-SDK-lin:/home/build/rack-plugin-toolchain/Rack-SDK-lin \
  181. --env PLUGIN_DIR=/home/build/plugin-src \
  182. rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \
  183. /bin/bash
  184. docker-run:
  185. $(DOCKER_RUN)
  186. docker-plugin-build-mac:
  187. mkdir -p $(PLUGIN_BUILD_DIR)
  188. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac $(MFLAGS)"
  189. docker-plugin-build-win:
  190. mkdir -p $(PLUGIN_BUILD_DIR)
  191. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win $(MFLAGS)"
  192. docker-plugin-build-lin:
  193. mkdir -p $(PLUGIN_BUILD_DIR)
  194. $(DOCKER_RUN) -c "$(MAKE) plugin-build-linux $(MFLAGS)"
  195. docker-plugin-build:
  196. mkdir -p $(PLUGIN_BUILD_DIR)
  197. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  198. .NOTPARALLEL:
  199. .PHONY: all plugin-build