#!/bin/sh

function hook_configure {
	cp -fp ../*.[ch] ./ || Error "unable to configure"
	[ -d man ] || mkdir man || Error "unable to configure"
	cp -fp ../man/*.[0-9] man/ || Error "unable to configure"
	case ${TARGET_SYSNAME} in
		win32)
			[ -d win32 ] || mkdir win32 || Error "unable to configure"
			cp -fp ../win32/*.[ch] win32/ || Error "unable to configure"
			cp ../win32/Makefile.gcc ./Makefile || Error "unable to configure"
			cp ../crc_i386.S ./ || Error "unable to configure"
			;;
		*)
			[ -d unix ] || mkdir unix || Error "unable to configure"
			cp -fp ../unix/*.[ch] unix/ || Error "unable to configure"
			cp ../unix/Makefile ./ || Error "unable to configure"
			;;
	esac
	touch config.status || Error "unable to configure"
}

function hook_premake {
	case ${SYSNAME}-${TARGET_SYSNAME} in
		*-nto)
			[ -n "${make_cmds}" ] || make_cmds='unzips'
			make_defns="${make_defns} prefix=${INSTALL_ROOT_nto}/${cpudir}"
			;;
		linux-linux)
			[ -n "${make_cmds}" ] || make_cmds='linux'
			;;
		solaris-solaris)
			[ -n "${make_cmds}" ] || make_cmds='solaris'
			;;
		*-win32)
			make_defns="${make_defns} CC_CPU_OPT="
			;;
	esac
	make_defns="${make_defns} AS=${machine:+${machine}-}as"
	make_defns="${make_defns} AR=${machine:+${machine}-}ar"
	make_defns="${make_defns} STRIP=${machine:+${machine}-}strip"
	make_CC="${make_CC} -g ${CPPFLAGS} ${LDFLAGS}"
	unset ac_autotools
}

function hook_pinfo {
	gen_pinfo -e unzip     usr/bin "DESCRIPTION=InfoZIP dearchiver"           "USE=%1>%C -h" SYMLINK=zipinfo
	gen_pinfo -e funzip    usr/bin "DESCRIPTION=InfoZIP dearchiver filter"    "USE=%1>%C -h"
	gen_pinfo -e unzipsfx  usr/bin "DESCRIPTION=InfoZIP self-extracting stub" "USE=%1>%C -h"
}
