#!/bin/sh
#
# Copyright 2005 Paul Blazejowski <paulb@blazebox.homeip.net>
# Available under the terms of the GNU GPL.
#

NAME="wireless-tools"
VERSION="28"
REVISION="1"

PKG_SOURCEURL='http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/wireless_tools.28.pre15.tar.gz'
PKG_SOURCEMD5=''

PKG_PATCH[0]="rc.wireless"
PKG_PATCH[1]="rc.wireless.conf"
PKG_PATCH[2]="wireless_tools.nowhine.diff"
PKG_PATCH[3]="wireless_tools.makefile.patch"

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

PKG_DOCFILES="COPYING INSTALL PCMCIA.txt README"

configfile /etc/rc.d/rc.wireless

cflags
cxxflags
prepare
applypatch 2 1
applypatch 3 1
analyzesource
#configure
make -j2 BUILD_STATIC=y BUILD_SHARED=y 
#makecheck
# Nothing like a bit of magic :D
make install INSTALL_DIR=$PKG_STAGEROOT/sbin \
             INSTALL_LIB=$PKG_STAGEROOT/usr/lib \
				 INSTALL_INC=$PKG_STAGEROOT/usr/include \
				 INSTALL_MAN=$PKG_STAGEROOT/usr/man #install-strip 

# Let the fun begin :D
createdir $PKG_STAGEROOT/etc/rc.d

# Copy static lib
spewdo "cd $PKG_WORKROOT/wireless_tools.28 ; cp libiw.a $PKG_STAGEROOT/usr/lib"

# Make root the owner or sbin
spewdo "chown -R root:bin $PKG_STAGEROOT/sbin"

# Fix doc permissions
spewdo "chmod 0644 $PKG_STAGEROOT/usr/doc/*/*"

# Copy init script(s)
findpatch filename rc.wireless 
spewdo "cp $filename $PKG_STAGEROOT/etc/rc.d/"
spewdo "chmod 755 $PKG_STAGEROOT/etc/rc.d/rc.wireless"

# This might contain a secret key, so we'll use chmod 600
findpatch filename rc.wireless.conf
spewdo "cp $filename $PKG_STAGEROOT/etc/rc.d/rc.wireless.conf.new"
spewdo "chmod 600 $PKG_STAGEROOT/etc/rc.d/rc.wireless.conf.new"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup

