NAME="unzip"
DESC="contains ZIP extraction utilities"
VERSION="6.0"

FILES=(
  "https://downloads.sourceforge.net/infozip/unzip${VERSION/./}.tar.gz"
  "unzip-${VERSION}-consolidated_fixes-1.patch"
)
HASHES=(
	"62b490407489521db863b523a7f86375"
	"02cfd942875ca492c8fd27dff773e633a4f0b9bb47af2c3ad2697e8df8aa79f8"
)

DEPENDS=("bash" "bzip2")
BUILD=()

PACKAGE() {
  tar xf "${NAME}${VERSION/./}.tar.gz"
  cd "${NAME}${VERSION/./}"

  patch -Np1 -i "../unzip-${VERSION}-consolidated_fixes-1.patch"

  DEFINES='-DACORN_FTYPE_NFS -DWILD_STOP_AT_DIR -DLARGE_FILE_SUPPORT \
		-DUNICODE_SUPPORT -DUNICODE_WCHAR -DUTF8_MAYBE_NATIVE -DNO_LCHMOD \
		-DDATE_FORMAT=DF_YMD -DUSE_BZIP2 -DNOMEMCPY -DNO_WORKING_ISPRINT'

	make -f unix/Makefile prefix=/usr \
		D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 \
		LF2="${LDFLAGS}" CF="${CFLAGS} ${CPPFLAGS} -I. ${DEFINES}" \
		unzips

  make -f unix/Makefile prefix="${ROOTDIR}/usr" \
    MANDIR="${ROOTDIR}/usr/share/man/man1"      \
    install

  cd .. && rm -rf "${NAME}${VERSIO/./}"
}
