#!/bin/sh set -eu version_llvm="$1" dir_download="$PWD/download" dir_files="$PWD/files" mkdir -p build; cd build dir_install="$PWD/install-llvm-$version_llvm" case "$version_llvm" in 7.*|8.*) tarball="llvm-$version_llvm.src" dir_source="$tarball" ;; 9.*|10.*) tarball="llvm-project-$version_llvm" dir_source="$tarball/llvm" ;; *) tarball="llvm-project-$version_llvm.src" dir_source="$tarball/llvm" ;; esac # Prepare source tar xf "$dir_download/$tarball.tar.xz" cd "$dir_source" case "$version_llvm" in 10.*) patch -p2 -i "$dir_files/llvm-10.0.1-fix-includes.patch" ;; 13.*) patch -p2 -i "$dir_files/llvm-10.0.1-fix-includes.patch" ;; esac mkdir -p build; cd build # Configure source cmake .. \ -DCMAKE_INSTALL_PREFIX="$dir_install" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_TARGETS_TO_BUILD=X86 \ -DLLVM_INSTALL_UTILS=ON \ -DLLVM_INCLUDE_TESTS=OFF \ -DLLVM_INCLUDE_BENCHMARKS=OFF # Build and install cmake --build . $MAKEFLAGS cmake --install .