NAME="zip"
DESC="ZIP file utilities"
VERSION="3.0"

FILES=(
  "https://downloads.sourceforge.net/infozip/zip${VERSION/./}.tar.gz"
  "zip-${VERSION}-exec-stack.patch"
  "zip-${VERSION}-format-security.patch"
  "zip-${VERSION}-no-crypt.patch"
  "zip-${VERSION}-pic.patch"
  "zip-${VERSION}-zipnote-freeze.patch"
  "zip-${VERSION}-build.patch"
)
HASHES=(
  "f0e8bb1f9b7eb0b01285495a2699df3a4b766784c1765a8f1aeedf63c0806369"
  "5e46b247107c71f34e00c93d27d9f5cf0812d1c8ffc171fc71addee715308ff5"
  "62618a8af67488508598f8d562e3aff43f18d311b642758ea5ab3c80c8284373"
  "32d263c492dbc2b37b71d0aa80e566283422e8e6493d91f8aa12946d6d587a4a"
  "afca923887828f6ccdcb98bcb1130f138d014614ca49c2a2526bd0fdc91dda6e"
  "c4eac1c60d8c71dd5242999255a30beda3925b628ff17a658bf1bfb2ef11cd3e"
  "a66386c3a48019d8063a48c3610a28862412926f04a3b8f44662c6a87bb250f5"
)

DEPENDS=("bzip2")
BUILD=()

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

  #sed -e "/^CFLAGS_NOOPT =/s/\$/ $CPPFLAGS $CFLAGS/" -i unix/Makefile
	#sed -e "s/^LFLAGS1=''/LFLAGS1=$LDFLAGS/" -i unix/configure

  export CFLAGS="${CFLAGS} -std=gnu89"
  export CPPLAGS="${CPPLAGS} -std=gnu89"

	patch -p1 -i "../zip-${VERSION}-no-crypt.patch"
	patch -p1 -i "../zip-${VERSION}-pic.patch"
	patch -p1 -i "../zip-${VERSION}-exec-stack.patch"
	patch -p1 -i "../zip-${VERSION}-build.patch"
	patch -p1 -i "../zip-${VERSION}-zipnote-freeze.patch"
	patch -p1 -i "../zip-${VERSION}-format-security.patch"

  sh ./unix/configure "-I. -DUNIX ${CFLAGS} ${CPPFLAGS}"

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

  cd .. && rm -r "zip${VERSION/./}"
}
