# Template file for 'unzip'
pkgname=unzip
version=6.0
wrksrc=unzip60
distfiles="${SOURCEFORGE_SITE}/infozip/${pkgname}60.tar.gz"
build_style=custom-install
short_desc="List, test and extract compressed files in a ZIP archive"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=036d96991646d0449ed0aa952e4fbe21b476ce994abc276e49d30e686708bd37
long_desc="
 Unzip will list, test, or extract files from a ZIP archive, commonly
 found on MS-DOS systems.  The default behavior (with no options) is to
 extract into the current directory (and subdirectories below it) all
 files from the specified ZIP archive. Unzip is compatible with
 archives created by PKWARE's PKZIP, but in many cases the program
 options or default behaviors differ.

 Zipinfo lists technical information about files in a ZIP archive, most
 commonly found on MS-DOS systems.  Such information includes file access
 permissions, encryption status, type of compression, version and operating
 system or file system of compressing program, and the like.

 Funzip acts as a filter; that is, it assumes that a ZIP archive is
 being piped into standard input, and it extracts the first member from
 the archive to stdout.  If there is an argument, then the input comes
 from the specified file instead of from stdin.

 Unzipsfx is a modified version of unzip designed to be prepended to
 existing ZIP archives in order to form self-extracting archives.
 Instead of taking its first non-flag argument to be the zipfile(s) to
 be extracted, unzipsfx seeks itself under the name by which it was
 invoked and tests or extracts the contents of the appended archive."

CFLAGS="-D_FILE_OFFSET_BITS=64 -DWILD_STOP_AT_DIR -DLARGE_FILE_SUPPORT"
CFLAGS="${CFLAGS} -DUNICODE_SUPPORT -DUNICODE_WCHAR -DUTF8_MAYBE_NATIVE"
CFLAGS="${CFLAGS} -DNO_LCHMOD -DDATE_FORMAT=DF_YMD -DUSE_BZIP2 -DNATIVE"

Add_dependency run glibc
Add_dependency run bzip2
Add_dependency build bzip2-devel

do_build()
{
	cd ${wrksrc} && make -f unix/Makefile LOCAL_UNZIP="$CFLAGS" \
		prefix=/usr LF2=""  D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 \
		unzips || return 1
}

do_install()
{
	cd ${wrksrc} && make -f unix/Makefile prefix=${DESTDIR}/usr \
		INSTALL_PROGRAM="install" install || return 1
	mkdir -p ${DESTDIR}/usr/share && \
		mv ${DESTDIR}/usr/man ${DESTDIR}/usr/share
}