SUMMARY="Unclutter your .profile"
DESCRIPTION="direnv is an environment switcher for the shell. It knows \
how to hook into bash, zsh, tcsh and fish shell to load or unload \
environment variables depending on the current directory. This allows \
project-specific environment variables without cluttering the ~/.profile file."
HOMEPAGE="https://direnv.net/"
COPYRIGHT="2017 zimbatm and contributors"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/direnv/direnv/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="917838827cb753153b91cb2d10c0d7c20cbaa85aa2dde520ee23653a74268ccd"
PATCHES="direnv-$portVersion.patchset"

ARCHITECTURES="?all"

PROVIDES="
	direnv = $portVersion
	cmd:direnv = $portVersion
	"
REQUIRES="
	haiku
	"

BUILD_REQUIRES="
	haiku_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc
	cmd:git
	cmd:go
	cmd:go_md2man
	cmd:make
	cmd:makeinfo
	cmd:which
	"

BUILD()
{
	# setup go environment
	BUILD=$(pwd)/build
	BUILD_GOPATH=$BUILD/gopath
	BUILD_GOROOT=$BUILD/goroot

	rm -rf $BUILD
	mkdir -p $BUILD_GOPATH/bin $BUILD_GOPATH/src $BUILD_GOROOT
	cp -R -s $(go env GOROOT)/* $BUILD_GOROOT

	export GOPATH=$BUILD_GOPATH
	export GOROOT=$BUILD_GOROOT
	export PATH=$PATH:$GOPATH/bin

	# copy additional packages
	cp -R -s $(pwd)/vendor/* $GOPATH/src

	make $jobArgs
}

INSTALL()
{
	install -d $binDir $manDir/man1
	install -t $binDir direnv
	install -t $manDir/man1 man/*.1
}

TEST()
{
	make test
}
