APP=clang
VERSION=10.0.1
BUILD=1sml
HOMEPAGE='https://clang.llvm.org/'
DOWNLOAD=""
REQUIRES="llvm"
DESC="LLVM project-based C language family front-end"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION".src"

  tar xf $SRCDIR/$APP-$VERSION".src".tar.?z*
  cd $APP-$VERSION".src"
  fixbuilddirpermissions

  patch -p1 < $SRCDIR/10-add-musl-triples.patch
  patch -p1 < $SRCDIR/30-fix-python-shebangs.patch

  unset CFLAGS CXXFLAGS

  mkdir -p smbuild && cd smbuild
  cmake .. -G Ninja -Wno-dev \
    -DCMAKE_BUILD_TYPE=MinSizeRel \
    -DCMAKE_INSTALL_PREFIX="" \
    -DCLANG_BUILD_EXAMPLES=OFF \
    -DLLVM_LINK_LLVM_DYLIB=ON \
    -DCLANG_LINK_CLANG_DYLIB=ON \
    -DLLVM_INCLUDE_DOCS=OFF \
    -DCMAKE_VERBOSE_MAKEFILE=OFF \
    -DCLANG_INCLUDE_TESTS=ON \
    -DCLANG_PLUGIN_SUPPORT=ON \
    -DLIBCLANG_BUILD_STATIC=ON \
    -DLLVM_ENABLE_EH=ON \
    -DLLVM_ENABLE_RTTI=ON \
    -DCLANG_VENDOR=SMLinux 

  ninja clang-tblgen
  ninja $MAKEFLAGS

  DESTDIR="$PKG" ninja install

  cp ../LICENSE.TXT $PKGDOCS/

  mkfinalpkg
}

SHA512SUMS="
c6712d491ce5e166ef72724cf855d742d88da825ffc25585612d7f2eb7770343e3ae48fa78e0af3e5d5efdde3a9686a7361dac3b546a4378de22448ea6e4026c  clang-10.0.1.src.tar.xz
533558863dc7247202b2a739e1bd2d81a99a16be329370cb734d338284b5408ecd14fe78ac836aaf922e377334b7a3ebef532cf8395d91aafe346bf71eb8b7fc  10-add-musl-triples.patch
c7f34b425b0dcea9752eeb7ff3d3a33af9cc45740fd3e77d52e4d610c5fd3daaa4d59138a255b057ef886915615a77ec1e6a447f3818b4b2724129c0ba354932  30-fix-python-shebangs.patch
"
