###
###  Copyright 2000-2007 University of Illinois Board of Trustees
###  All rights reserved.
###
###  Makefile.PL - configuration rules for psgconf
###
###  Campus Information Technologies and Educational Services
###  University of Illinois at Urbana-Champaign
###


use ExtUtils::MakeMaker;
use Getopt::Long;

use strict;


my ($etc_dir, $share_dir);

$etc_dir	= '$(PREFIX)/etc';
$share_dir	= '$(PREFIX)/share/psgconf';

GetOptions(
	'etcdir=s'		=> \$etc_dir,
	'sharedir=s'		=> \$share_dir
) || die "Usage: $0 [--etcdir=DIR] [--sharedir=DIR]\n";


sub MY::postamble
{
	return 'SHARE_DIR	= ' . $share_dir . '
ETC_DIR		= ' . $etc_dir . '

install ::
	$(MKPATH) $(DESTDIR)$(SHARE_DIR)/config
	$(CP) config/*.conf $(DESTDIR)$(SHARE_DIR)/config
	$(MKPATH) $(DESTDIR)$(SHARE_DIR)/files
	$(CP) files/rc.shutdown $(DESTDIR)$(SHARE_DIR)/files
	$(CP) files/magic $(DESTDIR)$(SHARE_DIR)/files

#	$(SH) MAKE=$(MAKE) ROOT_PATH=$(DESTDIR) ETC_DIR=$(ETC_DIR) ./postinstall

svr4pkg:
	$(MAKE) DESTDIR=$(DESTDIR) install
	if [ -d $(DESTDIR)$(ETC_DIR) ]; then \
		$(RM) -f $(DESTDIR)$(ETC_DIR)/*; \
		$(CP) etc/psg.conf $(DESTDIR)$(ETC_DIR)/psg.conf.sample; \
		$(CP) etc/psgconf_modules $(DESTDIR)$(ETC_DIR)/psgconf_modules.sample; \
	fi
	if [ ! -d $(DESTDIR)/usr/local/sbin -a -d $(DESTDIR)/usr/local/bin ]; then \
		$(MV) $(DESTDIR)/usr/local/bin $(DESTDIR)/usr/local/sbin; \
	fi
	if [ ! -f $(DESTDIR)/prototype ]; then \
		echo "i copyright=./COPYRIGHT" > $(DESTDIR)/prototype; \
		echo "i pkginfo=./pkginfo" >> $(DESTDIR)/prototype; \
		if [ `uname -r` = "5.10" ]; then \
			echo "i depend=./depend.sol10" >> $(DESTDIR)/prototype; \
		elif [ `uname -r` = "5.9" ]; then \
			echo "i depend=./depend.sol9" >> $(DESTDIR)/prototype; \
		elif [ `uname -r` = "5.8" ]; then \
			echo "i depend=./depend.sol8" >> $(DESTDIR)/prototype; \
		fi; \
		echo "i checkinstall=./preinstall" >> $(DESTDIR)/prototype; \
		echo "i postinstall=./postinstall" >> $(DESTDIR)/prototype; \
		/usr/bin/chown -R bin:bin $(DESTDIR); \
		(cd $(DESTDIR); find . -print|grep -v ./prototype|sort|pkgproto >> $(DESTDIR)/prototype; )\
	fi
	$(CP) COPYRIGHT depend.sol* pkginfo preinstall postinstall $(DESTDIR)/.
	/usr/bin/chown -R bin:bin $(DESTDIR)/COPYRIGHT $(DESTDIR)/depend.sol* $(DESTDIR)/pkginfo $(DESTDIR)/preinstall $(DESTDIR)/postinstall
';
}


WriteMakefile(
	'NAME'		=> 'PSGConf',
	'DISTNAME'	=> 'psgconf',
	'VERSION_FROM'	=> 'sbin/psgconf',
	'PREREQ_PM'	=> {
				'Config::Objective'	=> '0.9.1',	# For DataStore::ConfigFile
				'NetAddr::IP'		=> 3.011,		# For Control::Network
				'Proc::ProcessTable'	=> 0.35,	# For Action::RestartDaemon
				'Unix::Mknod'	=> 0.02,			# For Action::MkNod
				'Text::Diff'	=> 0.35,			# For Action::File
				'version'		=> 0.29,			# For Action::PackageManager
				'AppConfig'	=> 1.55,			# For Action::GenerateFile::AppConfig
											# and DataStore::AppConfig
				($] < 5.80 ? (
				'Net::FTP'	=> 1.19,			# For Action::PackageManager::FTPArchive
				'Storable'	=> 2.04)			# For DataStore::Storable
				: ())
			   },
	'INSTALLSCRIPT'	=> '/usr/local/sbin',
	'EXE_FILES'	=> [ qw(
				sbin/ConfigFile2Storable
				sbin/platform-name
				sbin/psgconf
				sbin/psgconf-import
			   ) ],
	## Add these new keywords supported since 5.005
	($] >= 5.005 ? (
	'ABSTRACT_FROM'	=> 'sbin/psgconf')
	: ()),
);




syntax highlighted by Code2HTML, v. 0.9.1