#!/usr/bin/env make
#
# file: Makefile
#
# Copyright (c) 2004 os-cillation
# All rights reserved.
#
# Written by Benedikt Meurer <bm@os-cillation.de>.
#
# 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, 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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
package?=xnetcardconfig
DESTDIR?=/usr/local/opt/${package}
prefix=/usr

INSTALL_DIR=	install -d -o root -m 0755
INSTALL_DATA=	install -c -o root -m 0644
INSTALL_SCRIPT=	install -c -o root -m 0755

VERSION?=0.0.$(shell date -u +%Y%m%d)
PACKAGE=xnetcardconfig

all: xnetcardconfig xnetcardconfig.real

install: all
	$(INSTALL_DIR) $(DESTDIR)$(prefix)/bin
	$(INSTALL_DIR) $(DESTDIR)$(prefix)/share/applications
	$(INSTALL_DIR) $(DESTDIR)$(prefix)/share/apps/xnetcardconfig
	$(INSTALL_DIR) $(DESTDIR)$(prefix)/share/pixmaps

	$(INSTALL_SCRIPT) xnetcardconfig $(DESTDIR)$(prefix)/bin/xnetcardconfig
	$(INSTALL_SCRIPT) xnetcardconfig.real $(DESTDIR)$(prefix)/bin/xnetcardconfig.real
	$(INSTALL_DATA) card.png $(DESTDIR)$(prefix)/share/pixmaps/xnetcardconfig.png
	$(INSTALL_DATA) card.png $(DESTDIR)$(prefix)/share/apps/xnetcardconfig/card.png
	$(INSTALL_DATA) logo.png $(DESTDIR)$(prefix)/share/apps/xnetcardconfig/logo.png
	$(INSTALL_DATA) xnetcardconfig.desktop $(DESTDIR)$(prefix)/share/applications/xfld-xnetcardconfig.desktop

clean:
	@rm -f xnetcardconfig xnetcardconfig.real *~ */*~

dist: rule/tarball

distclean: clean


xnetcardconfig: xnetcardconfig.in
	sed -e s,@PREFIX@,$(prefix),g < $< > $@
	chmod 0755 $@

xnetcardconfig.real: xnetcardconfig.real.in
	sed -e s,@PREFIX@,$(prefix),g < $< > $@
	chmod 0755 $@

rule/tarball: clean
	[ ! -r ../${PACKAGE}-${VERSION} ] || exit 1
	cd .. && ln -s $(shell basename ${CURDIR}) ${PACKAGE}-${VERSION}
	cd .. && tar cfzvh ${PACKAGE}-${VERSION}.tar.gz \
	  --exclude-vcs \
	  --exclude "debian" \
	  --exclude "CVS" --exclude ".bzr" --exclude '.git' \
	  --exclude "*~" \
	 ${PACKAGE}-${VERSION}/

#eof
