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.

264 lines
7.9KB

  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 := 5
  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 Mac version of binutils and build LLVM gold
  67. cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  68. 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)
  69. rm -rf osxcross
  70. rack-sdk-mac := Rack-SDK-mac
  71. rack-sdk-mac: $(rack-sdk-mac)
  72. $(rack-sdk-mac):
  73. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac.zip"
  74. unzip Rack-SDK-$(RACK_SDK_VERSION)-mac.zip
  75. mv Rack-SDK Rack-SDK-mac
  76. rm Rack-SDK-$(RACK_SDK_VERSION)-mac.zip
  77. RACK_DIR_MAC := $(PWD)/$(rack-sdk-mac)
  78. rack-sdk-win := Rack-SDK-win
  79. rack-sdk-win: $(rack-sdk-win)
  80. $(rack-sdk-win):
  81. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win.zip"
  82. unzip Rack-SDK-$(RACK_SDK_VERSION)-win.zip
  83. mv Rack-SDK Rack-SDK-win
  84. rm Rack-SDK-$(RACK_SDK_VERSION)-win.zip
  85. RACK_DIR_WIN := $(PWD)/$(rack-sdk-win)
  86. rack-sdk-lin := Rack-SDK-lin
  87. rack-sdk-lin: $(rack-sdk-lin)
  88. $(rack-sdk-lin):
  89. wget -c "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin.zip"
  90. unzip Rack-SDK-$(RACK_SDK_VERSION)-lin.zip
  91. mv Rack-SDK Rack-SDK-lin
  92. rm Rack-SDK-$(RACK_SDK_VERSION)-lin.zip
  93. RACK_DIR_LIN := $(PWD)/$(rack-sdk-lin)
  94. rack-sdk-clean:
  95. rm -rf Rack-SDK-mac Rack-SDK-win Rack-SDK-lin
  96. rack-sdk-all: rack-sdk-mac rack-sdk-win rack-sdk-lin
  97. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  98. toolchain-clean:
  99. rm -rf .build local osxcross $(rack-sdk-mac) $(rack-sdk-win) $(rack-sdk-lin)
  100. # Plugin build
  101. PLUGIN_BUILD_DIR := plugin-build
  102. PLUGIN_DIR ?=
  103. plugin-build-mac: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  104. plugin-build-mac: export CC := x86_64-apple-darwin20.2-clang
  105. plugin-build-mac: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  106. plugin-build-mac: export STRIP := x86_64-apple-darwin20.2-strip
  107. plugin-build-mac: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  108. plugin-build-mac: export OTOOL := x86_64-apple-darwin20.2-otool
  109. plugin-build-win: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  110. plugin-build-win: export CC := x86_64-w64-mingw32-gcc
  111. plugin-build-win: export CXX := x86_64-w64-mingw32-g++
  112. plugin-build-win: export STRIP := x86_64-w64-mingw32-strip
  113. plugin-build-linux: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  114. plugin-build-linux: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  115. plugin-build-linux: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  116. plugin-build-linux: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  117. plugin-build-mac: export RACK_DIR := $(RACK_DIR_MAC)
  118. plugin-build-win: export RACK_DIR := $(RACK_DIR_WIN)
  119. plugin-build-linux: export RACK_DIR := $(RACK_DIR_LIN)
  120. plugin-build-mac plugin-build-win plugin-build-linux:
  121. cd $(PLUGIN_DIR) && $(MAKE) clean
  122. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  123. cd $(PLUGIN_DIR) && $(MAKE) dep
  124. cd $(PLUGIN_DIR) && $(MAKE) dist
  125. mkdir -p $(PLUGIN_BUILD_DIR)
  126. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  127. cd $(PLUGIN_DIR) && $(MAKE) clean
  128. plugin-build:
  129. $(MAKE) plugin-build-mac
  130. $(MAKE) plugin-build-win
  131. $(MAKE) plugin-build-linux
  132. plugin-build-clean:
  133. rm -rf $(PLUGIN_BUILD_DIR)
  134. # Docker helpers
  135. dep-ubuntu:
  136. apt-get update
  137. apt-get install -y --no-install-recommends \
  138. ca-certificates \
  139. git \
  140. build-essential \
  141. autoconf \
  142. automake \
  143. bison \
  144. flex \
  145. gawk \
  146. libtool-bin \
  147. libncurses5-dev \
  148. unzip \
  149. zip \
  150. jq \
  151. libgl-dev \
  152. libglu-dev \
  153. git \
  154. wget \
  155. curl \
  156. cmake \
  157. nasm \
  158. xz-utils \
  159. file \
  160. python3 \
  161. libxml2-dev \
  162. libssl-dev \
  163. texinfo \
  164. help2man \
  165. libz-dev \
  166. rsync \
  167. xxd \
  168. perl \
  169. coreutils \
  170. zstd \
  171. markdown
  172. dep-arch-linux:
  173. # TODO Complete this list
  174. sudo pacman -S --needed \
  175. wget \
  176. help2man
  177. docker-build: rack-sdk-all
  178. docker build --build-arg JOBS=$(JOBS) --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) .
  179. DOCKER_RUN := docker run --rm --interactive --tty \
  180. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  181. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  182. --volume=$(PWD)/Rack-SDK-mac:/home/build/rack-plugin-toolchain/Rack-SDK-mac \
  183. --volume=$(PWD)/Rack-SDK-win:/home/build/rack-plugin-toolchain/Rack-SDK-win \
  184. --volume=$(PWD)/Rack-SDK-lin:/home/build/rack-plugin-toolchain/Rack-SDK-lin \
  185. --env PLUGIN_DIR=/home/build/plugin-src \
  186. rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \
  187. /bin/bash
  188. docker-run:
  189. $(DOCKER_RUN)
  190. docker-plugin-build-mac:
  191. mkdir -p $(PLUGIN_BUILD_DIR)
  192. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac $(MFLAGS)"
  193. docker-plugin-build-win:
  194. mkdir -p $(PLUGIN_BUILD_DIR)
  195. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win $(MFLAGS)"
  196. docker-plugin-build-lin:
  197. mkdir -p $(PLUGIN_BUILD_DIR)
  198. $(DOCKER_RUN) -c "$(MAKE) plugin-build-linux $(MFLAGS)"
  199. docker-plugin-build:
  200. mkdir -p $(PLUGIN_BUILD_DIR)
  201. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  202. .NOTPARALLEL:
  203. .PHONY: all plugin-build