#!/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 ../match.S ./ || 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='zips'
			make_defns="${make_defns} prefix=${INSTALL_ROOT_nto}/${cpudir}"
			export CPPFLAGS="${CPPFLAGS} -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -DNO_MKTEMP"
			;;
		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 zip       usr/bin DESCRIPTION="InfoZIP archiver"   "USE=%1>%C -h"
	gen_pinfo -e zipcloak  usr/bin DESCRIPTION="InfoZIP encrypter"  "USE=%1>%C -h"
	gen_pinfo -e zipnote   usr/bin DESCRIPTION="InfoZIP note adder" "USE=%1>%C -h"
	gen_pinfo -e zipsplit  usr/bin DESCRIPTION="InfoZIP splitter"   "USE=%1>%C -h"
    #Should we generate a .pinfo for the 'zipgrep' shell script?
}
