# Tanım: Java ile birlikte çalışabilen, statik olarak yazılmış programlama dili
# URL: https://kotlinlang.org/
# Paketçi: Cihan_Alkan 
# Gerekler: openjdk setconf
# Grup: geliştirme

isim=kotlin
surum=1.2.51
devir=1

kaynak=(https://github.com/JetBrains/kotlin/releases/download/v${surum/_/-}/kotlin-compiler-${surum/_/-}.zip)

derle() {

  cd "${isim}c/bin"

  setconf kotlin      DIR         "/usr/bin"
  setconf kotlinc-js  DIR         "/usr/bin"
  setconf kotlinc-jvm DIR         "/usr/bin"
  setconf kotlinc     KOTLIN_HOME "/usr/share/$isim"

  cd "$SRC/${isim}c"
  # executables
  install -Dm755 bin/kotlin      "$PKG/usr/bin/kotlin"
  install -Dm755 bin/kotlinc     "$PKG/usr/bin/kotlinc"
  install -Dm755 bin/kotlinc-js  "$PKG/usr/bin/kotlinc-js"
  install -Dm755 bin/kotlinc-jvm "$PKG/usr/bin/kotlinc-jvm"

  # jar files
  cd "$SRC/${isim}c/lib"
  install -d "$PKG/usr/share/$isim/lib"
  for jar in *.jar; do
    install -Dm644 "$jar" "$PKG/usr/share/$isim/lib"
  done

  # licenses
  cd "$SRC/${isim}c/license"
  install -d "$PKG/usr/share/licenses/$isim"
  install -Dm644 LICENSE.txt "$PKG/usr/share/licenses/$isim"
  install -Dm644 NOTICE.txt "$PKG/usr/share/licenses/$isim"

  cd third_party
  for txt in *.txt; do
    install -Dm644 "$txt" "$PKG/usr/share/licenses/$isim"
  done

  # build.txt must be installed for for "-version" to work
  cd "$SRC/${isim}c"
  install -Dm644 build.txt "$PKG/usr/share/$isim"
}

