### this file is sourced not run
PKGVER=3.18
PKGARCH=x86_64
PKGBUILD=1

# source: james
TARBALL=crda-3.18.tar.xz
MD5SUM=0431fef3067bf503dfb464069f06163a
SRC_URL=https://www.kernel.org/pub/software/network/crda/$TARBALL
BUNDLE=

SLACKREQ='libnl' # python-m2crypto build-time only
SLACKDESC="crda: crda $PKGVER (Wifi Regulatory Domain Agent)
crda: 
crda: CRDA acts as the udev helper for communication between the kernel and 
crda: userspace for regulatory compliance. It relies on nl80211 for 
crda: communication.
crda: 
crda: You also need to install the data file from crda-regdb.
crda: Master config files in /lib/crda.
crda: 
crda: https://wireless.wiki.kernel.org/en/developers/regulatory/crda
crda: 
"
SLACKSUG='crda-regdb'

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/crda* &&
	#patch -Np1 -i ../pkg/crda-openssl.patch && # FTBFS with openssl
	sed -i -e 's/-Werror//; /ldconfig/d' Makefile # remove -Werror, remove ldconfig		
}

### default pkg_package
pkg_build() { 
	CRDA_DATA=/lib/crda # must match with crda-regdb
	BUILD_FLAGS="
		PREFIX=/usr \
		LIBDIR=/usr/$LIBDIR \
		UDEV_RULE_DIR=/$LIBDIR/udev/rules.d \
		REG_BIN=$CRDA_DATA/regulatory.bin \
		PUBKEY_DIR=$CRDA_DATA/pubkeys"
		## USE_OPENSSL=1" # openssl 1.1 breaks it

	cd /tmp/crda* &&
	make $BUILD_FLAGS all &&
	make $BUILD_FLAGS install &&
	pkg_build_slackdesc &&

	install -dm755 $CRDA_DATA/pubkeys
}
