#! gmake

## AbiSource Applications
## Copyright (C) 1998 AbiSource, Inc.
##
## 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., 59 Temple Place - Suite 330, Boston, MA  
## 02111-1307, USA.

ABI_ROOT:=$(shell pwd)/../../..
include $(ABI_ROOT)/src/config/abi_defs_wp.mk
include $(ABI_ROOT)/src/config/abi_rules.mk

##################################################################
## This makefile serves two purposes.  It exposes an "install" 
## target, wherein it installs AbiSuite applications.  The
## eventual layout of these files is $(prefix)/AbiSuite, except
## for symbolic links in $(prefix/bin.  /usr/local is a good value
##  to use for $(prefix), and it is the default.

# The plain "install" common to all Unix targets
install:
	@TARGET=$(prefix)/AbiSuite BINDIR=$(prefix)/bin SRCDIR=$(OUTDIR) \
		SCRIPTDIR=$(ABI_ROOT)/src/pkg/common/unix/scripts \
		$(ABI_ROOT)/src/pkg/common/unix/scripts/install.sh 

########################################################################

# Native Solaris pkg format; first does an install, then packages,
# then uninstalls.
pkg: install
	@echo "Producing Solaris PKG..."
	@sed "s/__ABI_BUILD_VERSION__/$(ABI_BUILD_VERSION)/" pkg/pkginfo | sed \
		"s/__ABI_ARCH__/$(OS_ARCH)/" > $(DIST)/pkginfo
	@echo "i pkginfo" > $(DIST)/Prototype
	@echo "i checkinstall=./checkinstall" >> $(DIST)/Prototype
	@find /usr/local/AbiSuite /usr/local/bin/AbiWord /usr/local/bin/abiword -print \
		| pkgproto >> $(DIST)/Prototype
	@(cd $(DIST); pkgmk -o -r / -d $(DIST) -f Prototype)
	@rm -f $(DIST)/Prototype
	@rm -f $(DIST)/pkginfo
	@rm -f $(DIST)/checkinstall
	@echo "Compressing pkg into .tar.gz format..."
	@(cd $(DIST); tar cf - abisuite | gzip -c > \
		$(DIST)/abisuite.$(ABI_BUILD_VERSION).$(OS_ARCH).SunOS.$(OS_RELEASE).pkg.tar.gz)
	@rm -rf $(DIST)/abisuite
	@echo "Removing installation..."
	@rm -rf /usr/local/AbiSuite
	@rm -f /usr/local/bin/AbiWord
	@rm -f /usr/local/bin/abiword

########################################################################

# Tgz target is provided by a common Unix makefile

include $(ABI_ROOT)/src/pkg/common/unix/tgz.mk
include $(ABI_ROOT)/src/pkg/common/unix/tbz.mk

########################################################################

# This target should build all packages 
# uhh, no it shouldn't. -ed
distribution: tgz pkg
