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.

249 lines
7.2KB

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