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.

263 lines
7.8KB

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