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.

300 lines
9.1KB

  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. DOCKER_IMAGE_VERSION := 10
  18. all: toolchain-all
  19. # Toolchain build
  20. crosstool-ng := $(LOCAL_DIR)/bin/ct-ng
  21. $(crosstool-ng):
  22. git clone https://github.com/crosstool-ng/crosstool-ng.git
  23. cd crosstool-ng && git checkout e63c40854c977f488bee159a8f8ebf5fc06c8666
  24. cd crosstool-ng && ./bootstrap
  25. cd crosstool-ng && ./configure --prefix="$(LOCAL_DIR)"
  26. cd crosstool-ng && make -j $(JOBS)
  27. cd crosstool-ng && make install -j $(JOBS)
  28. rm -rf crosstool-ng
  29. toolchain-lin := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu
  30. toolchain-lin: $(toolchain-lin)
  31. $(toolchain-lin): $(crosstool-ng)
  32. ct-ng x86_64-ubuntu16.04-linux-gnu
  33. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  34. rm -rf .build .config build.log
  35. # HACK Copy GL and related include dirs to toolchain sysroot
  36. chmod +w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  37. cp -r /usr/include/GL $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  38. cp -r /usr/include/KHR $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  39. cp -r /usr/include/X11 $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
  40. chmod -w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
  41. toolchain-win := $(LOCAL_DIR)/x86_64-w64-mingw32
  42. toolchain-win: $(toolchain-win)
  43. $(toolchain-win): $(crosstool-ng)
  44. ct-ng x86_64-w64-mingw32
  45. CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG)
  46. rm -rf .build .config build.log /home/build/src
  47. toolchain-mac := $(LOCAL_DIR)/osxcross
  48. toolchain-mac: $(toolchain-mac)
  49. $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  50. $(toolchain-mac):
  51. # Download osxcross
  52. git clone "https://github.com/cschol/osxcross.git" osxcross
  53. cd osxcross && git checkout 12f179126df156fb65515cccf140f4b634967baa
  54. # Build osxcross
  55. cp MacOSX11.1.sdk.tar.* osxcross/tarballs/
  56. cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh
  57. # Build compiler-rt
  58. #cd osxcross && ENABLE_COMPILER_RT_INSTALL=1 JOBS=$(JOBS) ./build_compiler_rt.sh
  59. # Build Mac version of binutils and build LLVM gold
  60. #cd osxcross && BINUTILS_VERSION=$(MAC_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh
  61. #cd osxcross/build/build_stage && cmake . -DLLVM_BINUTILS_INCDIR=$(PWD)/osxcross/build/binutils-$(MAC_BINUTILS_VERSION)/include && make install -j $(JOBS)
  62. rm -rf osxcross
  63. rack-sdk-mac-x64 := Rack-SDK-mac-x64
  64. rack-sdk-mac-x64: $(rack-sdk-mac-x64)
  65. $(rack-sdk-mac-x64):
  66. wget --continue --content-disposition "https://vcvrack.com/downloads/Rack-SDK-latest-mac-x64.zip"
  67. unzip Rack-SDK-*-mac-x64.zip
  68. mv Rack-SDK Rack-SDK-mac-x64
  69. rm Rack-SDK-*-mac-x64.zip
  70. RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64)
  71. rack-sdk-mac-arm64 := Rack-SDK-mac-arm64
  72. rack-sdk-mac-arm64: $(rack-sdk-mac-arm64)
  73. $(rack-sdk-mac-arm64):
  74. wget --continue --content-disposition "https://vcvrack.com/downloads/Rack-SDK-latest-mac-arm64.zip"
  75. unzip Rack-SDK-*-mac-arm64.zip
  76. mv Rack-SDK Rack-SDK-mac-arm64
  77. rm Rack-SDK-*-mac-arm64.zip
  78. RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64)
  79. rack-sdk-win-x64 := Rack-SDK-win-x64
  80. rack-sdk-win-x64: $(rack-sdk-win-x64)
  81. $(rack-sdk-win-x64):
  82. wget --continue --content-disposition "https://vcvrack.com/downloads/Rack-SDK-latest-win-x64.zip"
  83. unzip Rack-SDK-*-win-x64.zip
  84. mv Rack-SDK Rack-SDK-win-x64
  85. rm Rack-SDK-*-win-x64.zip
  86. RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64)
  87. rack-sdk-lin-x64 := Rack-SDK-lin-x64
  88. rack-sdk-lin-x64: $(rack-sdk-lin-x64)
  89. $(rack-sdk-lin-x64):
  90. wget --continue --content-disposition "https://vcvrack.com/downloads/Rack-SDK-latest-lin-x64.zip"
  91. unzip Rack-SDK-*-lin-x64.zip
  92. mv Rack-SDK Rack-SDK-lin-x64
  93. rm Rack-SDK-*-lin-x64.zip
  94. RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64)
  95. rack-sdk-clean:
  96. rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64)
  97. rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64
  98. toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk-all
  99. toolchain-clean:
  100. rm -rf .build local osxcross $(rack-sdk-mac-x64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64) $(rack-sdk-mac-arm64)
  101. # Plugin build
  102. PLUGIN_BUILD_DIR := plugin-build
  103. PLUGIN_DIR ?=
  104. plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  105. plugin-build-mac-x64: export CC := x86_64-apple-darwin20.2-clang
  106. plugin-build-mac-x64: export CXX := x86_64-apple-darwin20.2-clang++-libc++
  107. plugin-build-mac-x64: export STRIP := x86_64-apple-darwin20.2-strip
  108. plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin20.2-install_name_tool
  109. plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin20.2-otool
  110. plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH)
  111. plugin-build-mac-arm64: export CC := arm64-apple-darwin20.2-clang
  112. plugin-build-mac-arm64: export CXX := arm64-apple-darwin20.2-clang++-libc++
  113. plugin-build-mac-arm64: export STRIP := arm64-apple-darwin20.2-strip
  114. plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin20.2-install_name_tool
  115. plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin20.2-otool
  116. plugin-build-win-x64: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
  117. plugin-build-win-x64: export CC := x86_64-w64-mingw32-gcc
  118. plugin-build-win-x64: export CXX := x86_64-w64-mingw32-g++
  119. plugin-build-win-x64: export STRIP := x86_64-w64-mingw32-strip
  120. plugin-build-lin-x64: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
  121. plugin-build-lin-x64: export CC := x86_64-ubuntu16.04-linux-gnu-gcc
  122. plugin-build-lin-x64: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
  123. plugin-build-lin-x64: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip
  124. plugin-build-mac-x64: export RACK_DIR := $(RACK_DIR_MAC_X64)
  125. plugin-build-mac-arm64: export RACK_DIR := $(RACK_DIR_MAC_ARM64)
  126. plugin-build-win-x64: export RACK_DIR := $(RACK_DIR_WIN_X64)
  127. plugin-build-lin-x64: export RACK_DIR := $(RACK_DIR_LIN_X64)
  128. plugin-build-mac-x64 plugin-build-mac-arm64 plugin-build-win-x64 plugin-build-lin-x64:
  129. cd $(PLUGIN_DIR) && $(MAKE) clean
  130. cd $(PLUGIN_DIR) && $(MAKE) cleandep
  131. cd $(PLUGIN_DIR) && $(MAKE) dep
  132. cd $(PLUGIN_DIR) && $(MAKE) dist
  133. mkdir -p $(PLUGIN_BUILD_DIR)
  134. cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/
  135. cd $(PLUGIN_DIR) && $(MAKE) clean
  136. plugin-build:
  137. $(MAKE) plugin-build-mac-x64
  138. $(MAKE) plugin-build-mac-arm64
  139. $(MAKE) plugin-build-win-x64
  140. $(MAKE) plugin-build-lin-x64
  141. plugin-build-clean:
  142. rm -rf $(PLUGIN_BUILD_DIR)
  143. # Docker helpers
  144. dep-ubuntu:
  145. apt-get update
  146. apt-get install -y --no-install-recommends \
  147. ca-certificates \
  148. git \
  149. build-essential \
  150. autoconf \
  151. automake \
  152. bison \
  153. flex \
  154. gawk \
  155. libtool-bin \
  156. libncurses5-dev \
  157. unzip \
  158. zip \
  159. jq \
  160. libgl-dev \
  161. libglu-dev \
  162. git \
  163. wget \
  164. curl \
  165. cmake \
  166. nasm \
  167. xz-utils \
  168. file \
  169. python3 \
  170. libxml2-dev \
  171. libssl-dev \
  172. texinfo \
  173. help2man \
  174. libz-dev \
  175. rsync \
  176. xxd \
  177. perl \
  178. coreutils \
  179. zstd \
  180. markdown \
  181. libarchive-tools
  182. dep-arch-linux:
  183. pacman -S --noconfirm --needed \
  184. git \
  185. cmake \
  186. patch \
  187. clang \
  188. python3 \
  189. automake \
  190. help2man \
  191. texinfo \
  192. libtool \
  193. jq \
  194. rsync \
  195. autoconf \
  196. flex \
  197. bison \
  198. which \
  199. unzip \
  200. wget \
  201. glu \
  202. libx11 \
  203. mesa
  204. docker-build: rack-sdk-all
  205. docker build --build-arg JOBS=$(JOBS) --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) .
  206. DOCKER_RUN := docker run --rm --interactive --tty \
  207. --volume=$(PLUGIN_DIR):/home/build/plugin-src \
  208. --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \
  209. --volume=$(PWD)/Rack-SDK-mac-x64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64 \
  210. --volume=$(PWD)/Rack-SDK-mac-arm64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64 \
  211. --volume=$(PWD)/Rack-SDK-win-x64:/home/build/rack-plugin-toolchain/Rack-SDK-win-x64 \
  212. --volume=$(PWD)/Rack-SDK-lin-x64:/home/build/rack-plugin-toolchain/Rack-SDK-lin-x64 \
  213. --env PLUGIN_DIR=/home/build/plugin-src \
  214. rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \
  215. /bin/bash
  216. docker-run:
  217. $(DOCKER_RUN)
  218. docker-plugin-build-mac-x64:
  219. mkdir -p $(PLUGIN_BUILD_DIR)
  220. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-x64 $(MFLAGS)"
  221. docker-plugin-build-mac-arm64:
  222. mkdir -p $(PLUGIN_BUILD_DIR)
  223. $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-arm64 $(MFLAGS)"
  224. docker-plugin-build-win-x64:
  225. mkdir -p $(PLUGIN_BUILD_DIR)
  226. $(DOCKER_RUN) -c "$(MAKE) plugin-build-win-x64 $(MFLAGS)"
  227. docker-plugin-build-lin-x64:
  228. mkdir -p $(PLUGIN_BUILD_DIR)
  229. $(DOCKER_RUN) -c "$(MAKE) plugin-build-lin-x64 $(MFLAGS)"
  230. docker-plugin-build:
  231. mkdir -p $(PLUGIN_BUILD_DIR)
  232. $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)"
  233. .NOTPARALLEL:
  234. .PHONY: all plugin-build