SUMMARY="A WPA Supplicant with support for WPA and WPA2"
DESCRIPTION="
wpa_supplicant is a WPA Supplicant for Linux, BSD, macOS, Windows, and Haiku \
with support for WPA and WPA2 (IEEE 802.11i / RSN). It is suitable for both \
desktop/laptop computers and embedded systems. Supplicant is the IEEE \
802.1X/WPA component that is used in the client stations. It implements key \
negotiation with a WPA Authenticator and it controls the roaming and IEEE \
802.11 authentication/association of the wlan driver."
HOMEPAGE="https://w1.fi/wpa_supplicant/"
COPYRIGHT="2003-2022 Jouni Malinen"
LICENSE="BSD (2-clause)
	GNU GPL v2"
REVISION="1"
srcGitRev="8fb311b20f7661e3fbd899dbf110d49d99f4d2f1"
SOURCE_URI="https://github.com/haiku/wpa_supplicant/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="7bdc7bef9f30c754689806998a5e4d492976c8e050b6220e58406a0ee5adbf79"
SOURCE_DIR="wpa_supplicant-$srcGitRev"
PATCHES="wpa_supplicant-2.10-gcc2.patch"

ARCHITECTURES="all"

PROVIDES="
	wpa_supplicant = $portVersion compat >= 2
	cmd:wpa_supplicant = $portVersion compat >= 2
	"
REQUIRES="
	haiku
	lib:libssl
	"

BUILD_REQUIRES="
	devel:libssl
	"
BUILD_PREREQUIRES="
	haiku_devel
	cmd:gcc
	cmd:ld
	cmd:make
	"

BUILD()
{
	cd wpa_supplicant
	make wpa_supplicant
}

INSTALL()
{
	cd wpa_supplicant
	mkdir -p $binDir
	cp -v wpa_supplicant $binDir

	appSig=$(catattr -r BEOS:APP_SIG wpa_supplicant | cut -f2 -d"/")
	localeFolder=$dataDir/locale/catalogs
	mkdir -p $localeFolder/$appSig

	for file in wpa_gui-haiku/locales/*.catkeys; do
		catLang=$(basename $file .catkeys)
		echo "Linking $catLang.catalog..."
		linkcatkeys -o $localeFolder/$appSig/$catLang.catalog \
			-s "application/$appSig" -l $catLang "$file"
	done
}
