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.

266 lines
8.1KB

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