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.

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