#
# Makefile for buildkernel script package
#
#Copyleft:
#    Buildkernel is used to create a new linux kernel from the raw source
#    and patches.
#    Copyright (C) 1997-2002 William Stearns <wstearns@pobox.com>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#    The author can also be reached at:
#        William Stearns
#email:  wstearns@pobox.com              (preferred)
#web:    http://www.stearns.org
#snail:  6 Manchester Drive
#        Lebanon NH, 03766
#
#Make sure buildkernel has BKSCRIPTVER updated when this changes
BKSCRIPTVER = 1.06

BINDIR = $(DESTDIR)/usr/bin
DOCFILES = COPYING QUICKSTART TURBOSTART-NEWESTSTABLE buildkernel.doc buildkernel.lsm index.html sample.bklog
DOCDIR = $(DESTDIR)/usr/share/doc/buildkernel-${BKSCRIPTVER}
#bkrun-ltmodem isn't finished
LIBFILES = bkrun-alsa bkrun-cipe bkrun-cml2 bkrun-freeswan bkrun-iptables bkrun-pctel
LIBDIR = $(DESTDIR)/var/lib/buildkernel

install: 
	@echo -n "Installing files... "
	@echo -n "buildkernel... "
	@install -o root -g root -m 0755 buildkernel ${BINDIR}/buildkernel
	@echo -n "doc directory... "
	@install -o root -g root -m 0755 -d ${DOCDIR}
	@echo -n "${DOCFILES}... "
	@install -o root -g root -m 0644 ${DOCFILES} ${DOCDIR}
	@echo -n "lib directory... "
	@install -o root -g root -m 0755 -d ${LIBDIR}
	@echo -n "${LIBFILES}... "
	@install -o root -g root -m 0644 ${LIBFILES} ${LIBDIR}
	@echo done!
	@if [ ! -f $(DESTDIR)/etc/bkrc ] ; then \
	install -o root -g root -m 0644 bkrc $(DESTDIR)/etc ; \
	else \
	echo /etc/bkrc already exists, not overwriting ; \
	fi

mini-install:
	@echo -n "Quick binary update for developers..."
	@install -o root -g root -m 0755 buildkernel ${BINDIR}/buildkernel
	@install -o root -g root -m 0644 ${LIBFILES} ${LIBDIR}
	@echo Done!

distribs:
	@echo This should only need to be used by the author in 
	@echo packing up the buildkernel package.
	cd .. \
	&& tar cf - buildkernel-${BKSCRIPTVER}/ | \
	gzip -9 > buildkernel-${BKSCRIPTVER}.tar.gz \
	&& rm -f buildkernel-current \
	&& ln -sf buildkernel-${BKSCRIPTVER} buildkernel-current \
	&& tar cf - buildkernel-current/* | \
	gzip -9 > buildkernel-current.tar.gz \
	&& cp buildkernel-${BKSCRIPTVER}.tar.gz /usr/src/redhat/SOURCES/ \
	&& cd buildkernel-${BKSCRIPTVER} \
	&& cp -f buildkernel.spec /usr/src/redhat/SPECS/ \
	&& rpm --sign -ba /usr/src/redhat/SPECS/buildkernel.spec \
	&& mv -f /usr/src/buildkernel-*.tar.gz /usr/src/mysource/ \
	&& mv -f /usr/src/redhat/RPMS/noarch/buildkernel-*.noarch.rpm /usr/src/mysource/ \
	&& mv -f /usr/src/redhat/SRPMS/buildkernel-*.src.rpm /usr/src/mysource/


#old:	&& rpm-2.5 --buildarch noarch -ba /usr/src/redhat/SPECS/buildkernel.spec \
#new:	&& rpm --target noarch -ba /usr/src/redhat/SPECS/buildkernel.spec \
