#!/usr/bin/make -f

#export DH_VERBOSE = 1

#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export OPENSSL_DIR=$(CURDIR)/local/openssl

%:
	dh $@ --with python3

override_dh_auto_build:
	echo "Downloading OpenSSL"
	wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1i.tar.gz -O $(CURDIR)/local/openssl.tar.gz
	cd $(CURDIR)/local && tar -xzf openssl.tar.gz
	mv $(CURDIR)/local/openssl-OpenSSL_1_1_1i $(OPENSSL_DIR)
	rm $(CURDIR)/local/openssl.tar.gz
	cd $(OPENSSL_DIR) && ./config --prefix=$(OPENSSL_DIR)/local enable-ssl2 enable-ssl3 enable-ssl3-method enable-des enable-rc4 enable-weak-ssl-ciphers no-shared
	cd $(OPENSSL_DIR) && make
	cd $(OPENSSL_DIR) && make install_sw

	echo "Compiling hostapd"
	cd $(CURDIR)/local/hostapd-eaphammer/hostapd && cp defconfig .config
	cd $(CURDIR)/local/hostapd-eaphammer/hostapd && make hostapd-eaphammer_lib V=1

override_dh_install:
	dh_install -Xstub

override_dh_python3:
	dh_python3 --no-ext-rename
