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.

225 lines
6.3KB

  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. wget -c "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.24.0.tar.xz"
  10. tar -xf crosstool-ng-1.24.0.tar.xz
  11. rm crosstool-ng-1.24.0.tar.xz
  12. cd crosstool-ng-1.24.0 && ./bootstrap
  13. cd crosstool-ng-1.24.0 && ./configure --prefix="$(LOCAL_DIR)"
  14. cd crosstool-ng-1.24.0 && make
  15. cd crosstool-ng-1.24.0 && make install
  16. rm -rf crosstool-ng-1.24.0
  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 http://deb.debian.org/debian/pool/main/i/isl/isl_0.20.orig.tar.xz && mv isl_0.20.orig.tar.xz isl-0.20.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 /home/build/src
  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 http://deb.debian.org/debian/pool/main/i/isl/isl_0.20.orig.tar.xz && mv isl_0.20.orig.tar.xz isl-0.20.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 := 10.0.1
  42. MAC_BINUTILS_VERSION := 2.35
  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 a791ad4fca685ea9fceb520b77db586881cd3f3d
  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 MacOSX10.13.sdk.tar.* osxcross/tarballs/
  54. cd osxcross && 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 := Rack-SDK
  60. rack-sdk: $(rack-sdk)
  61. $(rack-sdk):
  62. wget -c "https://vcvrack.com/downloads/Rack-SDK-1.1.6.zip"
  63. unzip Rack-SDK-1.1.6.zip
  64. rm Rack-SDK-1.1.6.zip
  65. RACK_DIR := $(PWD)/$(rack-sdk)
  66. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk
  67. toolchain-clean:
  68. rm -rf local osxcross $(rack-sdk)
  69. # Plugin build
  70. PLUGIN_BUILD_DIR := plugin-build
  71. PLUGIN_DIR ?=
  72. plugin-build-mac: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  73. plugin-build-mac: export CC := x86_64-apple-darwin17-clang
  74. plugin-build-mac: export CXX := x86_64-apple-darwin17-clang++-libc++
  75. plugin-build-mac: export STRIP := x86_64-apple-darwin17-strip
  76. plugin-build-win: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  77. plugin-build-win: export CC := x86_64-w64-mingw32-gcc
  78. plugin-build-win: export CXX := x86_64-w64-mingw32-g++
  79. plugin-build-win: export STRIP := x86_64-w64-mingw32-strip
  80. plugin-build-linux: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  81. plugin-build-linux: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  82. plugin-build-linux: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  83. plugin-build-linux: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  84. plugin-build-mac plugin-build-win plugin-build-linux: export RACK_DIR := $(RACK_DIR)
  85. # Since the compiler we're using could have a newer version than the minimum supported libstdc++ version, link it statically.
  86. # Rack v2 includes this flag in plugin.mk, so remove it after it releases.
  87. plugin-build-mac plugin-build-win plugin-build-linux: export LDFLAGS := -static-libstdc++
  88. plugin-build-mac plugin-build-win plugin-build-linux:
  89. cd $(PLUGIN_DIR) && $(MAKE) clean
  90. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  91. cd $(PLUGIN_DIR) && $(MAKE) dep
  92. cd $(PLUGIN_DIR) && $(MAKE) dist
  93. mkdir -p $(PLUGIN_BUILD_DIR)
  94. cp $(PLUGIN_DIR)/dist/*.zip $(PLUGIN_BUILD_DIR)/
  95. cd $(PLUGIN_DIR) && $(MAKE) clean
  96. plugin-build:
  97. $(MAKE) plugin-build-mac
  98. $(MAKE) plugin-build-win
  99. $(MAKE) plugin-build-linux
  100. plugin-build-clean:
  101. rm -rf $(PLUGIN_BUILD_DIR)
  102. # Docker helpers
  103. dep-ubuntu:
  104. apt-get update
  105. apt-get install -y --no-install-recommends \
  106. ca-certificates \
  107. git \
  108. build-essential \
  109. autoconf \
  110. automake \
  111. bison \
  112. flex \
  113. gawk \
  114. libtool-bin \
  115. libncurses5-dev \
  116. unzip \
  117. zip \
  118. jq \
  119. libgl-dev \
  120. libglu-dev \
  121. git \
  122. wget \
  123. curl \
  124. cmake \
  125. nasm \
  126. xz-utils \
  127. file \
  128. python3 \
  129. libxml2-dev \
  130. libssl-dev \
  131. texinfo \
  132. help2man \
  133. clang \
  134. libz-dev \
  135. rsync \
  136. xxd \
  137. perl \
  138. coreutils
  139. dep-arch-linux:
  140. # TODO Complete this list
  141. sudo pacman -S --needed \
  142. wget \
  143. help2man
  144. docker-build:
  145. docker build --tag rack-plugin-toolchain:1 .
  146. DOCKER_RUN := docker run --rm --interactive --tty \
  147. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  148. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  149. --env PLUGIN_DIR=/home/build/plugin-src \
  150. rack-plugin-toolchain:1 \
  151. /bin/bash
  152. docker-run:
  153. $(DOCKER_RUN)
  154. docker-plugin-build-mac:
  155. mkdir -p $(PLUGIN_BUILD_DIR)
  156. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac $(MFLAGS)"
  157. docker-plugin-build-win:
  158. mkdir -p $(PLUGIN_BUILD_DIR)
  159. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win $(MFLAGS)"
  160. docker-plugin-build-lin:
  161. mkdir -p $(PLUGIN_BUILD_DIR)
  162. $(DOCKER_RUN) -c "$(MAKE) plugin-build-lin $(MFLAGS)"
  163. docker-plugin-build:
  164. mkdir -p $(PLUGIN_BUILD_DIR)
  165. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  166. .NOTPARALLEL:
  167. .PHONY: all plugin-build