#!/bin/sh
#
# Produced by Daniel Moerner (dmoerner@gmail.com)
# This script is in the public domain under the terms of the MIT license.
#
# Requires openssl-dev headers

wget -c http://hostap.epitest.fi/releases/wpa_supplicant-0.5.11.tar.gz
tar -zxvf wpa_supplicant-0.5.11.tar.gz
cd wpa_supplicant-0.5.11

cp defconfig .config

# Note: CONFIG_NO_STDOUT_DEBUG was not uncommented, even though this produces an
# extra 90kB of code because this debugging information is key to seeing if
# wpa_supplicant is actually working.

make

strip wpa_cli
strip wpa_passphrase
strip wpa_supplicant

sudo mkdir -p /usr/local/sbin
sudo mkdir -p /usr/local/bin
sudo cp wpa_cli wpa_supplicant /usr/local/sbin
sudo cp wpa_passphrase /usr/local/bin

cat > /tmp/new_files.list << EOF
/usr/local/bin/wpa_passphrase
/usr/local/sbin/wpa_cli
/usr/local/sbin/wpa_supplicant
EOF

tar -T /tmp/new_files.list -czvf ../wpa-supplicant.tce
rm -f /tmp/new_files.list
