#
#
# $Id: Makefile,v 1.3 2000-07-27 03:05:31+09 kabe Exp $

# inherited values
SOFDV=1
SOPCV=1
SVX = .dist
BINDIR = /usr/local/bin

PKG=VEGAmtpcv
VERSION=2.0

TOPDIR=..

# local
# If you want to build the package on device directly, change this
PKGDEV=./pkgdev

RM = rm -f
RMDIR = rm -fr

##-------------------------------
all:
	@echo "Use \"make pkg\" from top directory."

pkg: $(PKGDEV)/pkgmap

## create package in $(PKGDEV)
$(PKGDEV)/pkgmap: pkginfo prototype depend postinstall postremove
	## creating pkgdev/$(PKG)/
	test -d $(PKGDEV) || mkdir $(PKGDEV)
	pkgmk -o -d $(PKGDEV) -f prototype build=$(TOPDIR)
	@echo ================
	@echo "Now test the package by \"make pkgtest\", or install it by \"pkgadd -d $(PKGDEV)\"."
	@#$(MAKE) postinst-message

pkginfo prototype depend postinstall postremove: \
	pkginfo.in prototype.in depend.in postinstall.in postremove.in
	sed -e 's/@PKG@/$(PKG)/; s/@VERSION@/$(VERSION)/; s/@SOFDV@/$(SOFDV)/g; s/@SOPCV@/$(SOPCV)/g; s/@SVX@/$(SVX)/g' -e "s:@BINDIR@:"`expr $(BINDIR) : '/*\(.*\)/*'`":" $@.in > $@
	# touch -r $@.in $@
	
clean::
	$(RM) pkginfo prototype depend postinstall postremove
	-test -d $(PKGDEV) && $(RMDIR) $(PKGDEV)
pkgtest:
	mkdirhier ROOT/usr/lib/fs/pcfs;
	mkdirhier ROOT/usr/sbin;
	touch ROOT/usr/lib/fs/pcfs/fstyp;
	touch ROOT/usr/lib/fs/pcfs/ident_pcfs.so.1;
	touch ROOT/usr/sbin/rmmount;
	-pkgadd -d pkgdev -R `pwd`/ROOT
clean::
	$(RMDIR) ROOT
