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.

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