# Maintainer: PktSurf <smlinux@pktsurf.in>
app=file
version=5.44
build=4sml
homepage="https://www.darwinsys.com/file/"
download="http://astron.com/pub/file/file-$version.tar.gz"
desc="Utility to determine file types"
requires="bzip2 zlib"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  #applypatch $srcdir/file.etc.file.diff
  #applypatch $srcdir/file.short.diff
}

build() {
  # linking against libseccomp causes weird "Bad system call" issues
  CFLAGS+=" --std=c99" \
  ./configure \
    --prefix= \
    --datadir=/etc \
    --enable-fsect-man5 \
    --disable-libseccomp

  make
  make install DESTDIR=$pkg

  # Install the flat files
  # We'll regenerate /etc/file/magic.mgc in the doinst.sh
  #rm $pkg/etc/file/magic.mgc
  mkdir -p $pkg/etc/file/magic
  cp -a magic/Magdir/* $pkg/etc/file/magic/
  chmod 0644 $pkg/etc/file/magic/* 

  install -Dm 755 $srcdir/recompile_magic.mgc.sh $pkg/etc/file/recompile_magic.mgc.sh

  cp COPYING $pkgdocs/

  ( cd $pkg/etc ; ln -sf file misc )

  mkfinalpkg
}

sha512sums="
aafc7bb8a84d64ec77b6e325868ce6149dea3fb3cb46868892c7c872dfeb7f56180cd231f2eecba4d256c7dd4936a6886de56b1ef3d69874ce798c1e49b91c05  file-5.44.tar.lz
"