NAME=module-init-tools
VERSION=3.2.2
SOURCE=http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-$VERSION.tar.bz2
PATCH=modprobe.favor.etc.modprobe.d.diff.gz
BUILD=${BUILD:-2}
OPTIMIZE=${OPTIMIZE:-"-Os"}

build() {
	_explode 0
	cd module-init-tools-$VERSION

	# Patch from Slackware:
	# Look for /etc/modprobe.d/ first rather than bailing on the
	# idea if /etc/modprobe.conf exists.  IMHO, this is a better
	# default behavior because it allows /etc/modprobe.conf to
	# remain behind for 2.4 kernels and allows a smoother transition
	# towards using /etc/modprobe.d/.
	_patch 0 -p1

	./configure \
		--prefix= \
		--mandir=$MANDIR \
		--enable-zlib \
		--build=$CONFIGURE_TRIPLET
	make
	make DESTDIR=$PKG install

	# Everyone using this package should have switched to Linux 2.6
	# already, thus no need to convert module configuration.
	rm $PKG/sbin/generate-modprobe.conf

	# Some extra docs and license file:
	_doc 0 module-init-tools-$VERSION  AUTHORS COPYING ChangeLog FAQ

	# Create the directory to hold modprobe configuration:
	mkdir -p $PKG/etc/modprobe.d

	cd $PKG$MANDIR/man5
	[ ! -e modprobe.d.5 ] && ln -s modprobe.conf.5 modprobe.d.5
	cd -

	# This is nice together with Slackware's patch:
	# Retain legacy behavior by tossing a symlink in /etc/modprobe.d.
	# Note that the plan is to eliminate /etc/modprobe.conf and
	# /etc/modules.conf in the long run, so you may wish to remove the
	# link and move your actual file into /etc/modprobe.d/ if you want
	# to keep it instead of going with smaller chunks in there...
	cat << "EOF" >> $PKG/install/doinst.sh

if [ -f etc/modprobe.conf -a ! -f etc/modprobe.d/modprobe.conf ]; then
	ln -sf ../modprobe.conf etc/modprobe.d/modprobe.conf
fi
EOF

	_chfix
	_chgrp_bin
}
