# Requires fakedestdir.

NAME=wvdial
VERSION=( 1.54.0 4.0.2 )
BUILD=1slackles
SOURCE=(http://open.nit.ca/download/wvdial-$VERSION.tar.gz
	http://www.csclub.uwaterloo.ca/~ja2morri/wvstreams-${VERSION[1]}.tar.gz )
SOURCE_MD5=(8648c044305fc66ee33ecc55d36f8c8b
	ecb4e74ebaa1f45206f5d88eb34c5623 )
SOURCE_SHA1=(7bd9fff181f5e5f897b6355bf4242b8b96f4a0c5
	c613491cff9e002f73ffcf40abb907bea4fc81b7 )

build() {
	_cflags -O2
	_explode_all
	
	cd wvstreams-${VERSION[1]}
	# A few hacks with prefix and includedir.
	# Also --disable-shared isn't supported.
	./configure --prefix=/ \
			--includedir=/ \
			--disable-debug \
			--without-fam \
			--without-fftw \
			--without-bdb \
			--without-qdbm \
			--without-ogg \
			--with-openssl \
			--without-openslp \
			--without-pam \
			--without-tcl \
			--without-telephony \
			--without-swig \
			--without-qt \
			--without-speex \
			--without-vorbis \
			--with-xplc \
			--with-zlib
	make
	# wvdial searches ../wvstreams:
	make DESTDIR=$TMP/wvstreams install

	# Take no documentation from wvstreams, it's under LGPL
	# and COPYING.LIB will be included from wvdial anyway.
	
	# Fix the location of include files:
	mv $TMP/wvstreams/wvstreams $TMP/wvstreams/include
	

	cd "$TMP/wvdial-$VERSION"

	# Patch to use the correct static libs:
	sed -i 's|^LIBS +=.*$|LIBS += ../wvstreams/lib/libwvbase.a ../wvstreams/lib/libxplc-cxx.a ../wvstreams/lib/libwvstreams.a ../wvstreams/lib/libwvutils.a|' Makefile

	# Patch PREFIX:
	sed -i "s|^PREFIX=.*$|PREFIX=$PREFIX|" Makefile

	make
	fakedestdir $PKG install
	_doc 0 $NAME-$VERSION CHANGES COPYING.LIB FAQ MENUS README TODO

	_chfix
	_chgrp_bin
}
