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.

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