
SHELL = /bin/sh
VPATH = @srcdir@

subdirs = @subdirs@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = $(exec_prefix)/bin
sbindir = $(exec_prefix)/sbin
logdir = $(prefix)/log
rundir =  $(prefix)/log/run

perl=@PERLPATH@
INSTALL = @INSTALL@

all:
	@echo "Typing 'make install' will install into $(prefix)"
	@echo "run ./configure with --prefix option to install elsewhere."

install: 
	@echo
	# Make our install directories if needed
	@$(top_srcdir)/mkinstalldirs $(bindir)
	@$(top_srcdir)/mkinstalldirs $(sbindir) 
	@$(top_srcdir)/mkinstalldirs $(logdir) 
	@$(top_srcdir)/mkinstalldirs $(rundir)

	@echo
	# Install our programs into sbindir
	$(INSTALL) src/log_u2000 $(sbindir)
	$(INSTALL) src/rpt_aprsd $(sbindir)
	$(INSTALL) src/rpt_wu $(sbindir)

	@echo
	@echo "##############################################################################"
	@echo 
	@echo "Weather scripts have (hopefully) been installed to $(prefix)"
	@echo "PLEASE edit the (PORT, MYCALL, aprsServer, aprsPort, etc) variables."
	@echo "See the INSTALL file for which variables to edit in which files."
	@echo 
	@echo "To install SysV init scripts (Redhat, SuSE, etc) run 'make install-sysv'"
	@echo "To install BSD init script (Slackware, BSD, etc) run 'make install-bsd'"
	@echo
	@echo "##############################################################################"
	@echo

install-sysv:
	@echo
	# Let's try to determine if we really are on a SysV system.
	@(if [ ! -d /etc/init.d ]; then echo "/etc/init.d does not exist, BSD init system?";/bin/false; else echo "Good we seem to have a SysV init system!";fi)

	@echo
	# Install SysV Init scripts to /etc/init.d
	$(INSTALL) init/met_log /etc/init.d
	$(INSTALL) init/met_rpt_wu /etc/init.d
	$(INSTALL) init/met_rpt_aprsd /etc/init.d
	
	@echo
	@(if [ -f /etc/init.d/met_log ] && [ -f /etc/init.d/met_rpt_aprsd ] && [ -f /etc/init.d/met_rpt_wu ]; then echo "Success installing SysV init scripts";else echo "Failed installing SysV scripts.  Are you root or a wheel user? Try manually copying init scripts to /etc/init.d/";fi)

install-bsd:
	@echo
	#$(INSTALL) init/rc.met /etc/rc.d/rc.met
	@(if [ -f /etc/rc.d/rc.met ]; then echo "Success installing BSD init script";else echo "Failed installing BSD script.  Are you root or a wheel user? Try manually copying rc.met init script to /etc/rc.d/";/bin/false;fi)

	@echo
	@echo "##############################################################################"
	@echo
	@echo "You will need to add the following line to your '/etc/rc.d/rc.local' script"
	@echo ". /etc/rc.d/rc.met"
	@echo "Or, you may execute this script in any other suitable manner.  It's a simple shell script."
	@echo
	@echo "##############################################################################"
	@echo

clean:
	@rm -vf init/rc.met init/met_rpt_wu init/met_rpt_aprsd init/met_log src/log_u2000 src/rpt_aprsd src/rpt_wu

distclean: clean
	@rm -vf Makefile config.cache config.log