# $Id: Makefile,v 1.16 2006/10/30 14:10:18 koehler Exp $
#
# Makefile installing EWS and MIA
#
# Last Change: Sun Oct 29 19:09:17 2006
#

help:
	@echo "+-----------------------------------------------------------------------+"
	@echo "| MIA+EWS can be installed with a graphical installation wizard,        |"
	@echo "| or with the classical text-based installation.                        |"
	@echo "|                                                                       |"
	@echo '| type "make gui" or "make wiz" for the installation wizzard,           |'
	@echo '| type "make cli" or "make "cl_install" for the text-based installation |'
	@echo "+-----------------------------------------------------------------------+"

gui:
	@echo "installwiz" | idl

wiz: gui

cl_install:  install_cfitsio install_c startup

cli:  install_cfitsio install_c startup


install32:  install_cfitsio32 install_c32 startup

install_cfitsio:
	@echo "Making cfitsio ================================================"
	./makecfitsio

install_cfitsio32:
	@echo "Making cfitsio (force 32-bit mode) ============================"
	./makecfitsio 32

install_c:  cfitsio
	@echo "Making c programs ============================================="
	$(MAKE) -C c/src CPUTYPE=`uname -p`

install_c32:  cfitsio
	@echo "Making c programs (force 32-bit mode) ========================="
	$(MAKE) -C c/src CC_OPT32="-m32"
#	mv c/bin/disp* software/EWS/c/bin

startup:
	@echo "Creating STARTUP-file =================================================="
	@echo "Please enter the name of the browser you want to use for the online help"
	@sed -e "s,%HERE%,`pwd`,"\
	     -e "s,%BROWSER%,`read -p '(e.g. netscape, mozilla, or opera): ' b; echo $$b`,"\
	     STARTUP.in > STARTUP
	@echo ""
	sed -e "s,%HERE%,`pwd`," setup.csh_in > setup.csh
	sed -e "s,%HERE%,`pwd`," mia.in > mia.sh
	cp -p mia.sh mia
	chmod a+x mia.sh mia
	@echo "----------------------------------------------------------------------"
	@echo ""
	@echo "To start MIA+EWS, type"
	@echo ""
	@echo "	`pwd`/mia"
	@echo "or"
	@echo "	`pwd`/mia.sh"
	@echo ""
	@echo "(You might want to copy mia into a directory that's in your PATH,"
	@echo " or create a link from somewhere in your PATH to it)"
	@echo ""
	@echo "----------------------------------------------------------------------"

EWS: install

MIA: install

clean_c:
	$(MAKE) -C c/src clean

clean_cfitsio:
	$(MAKE) -C cfitsio clean;

clean_tmp:
	rm -rf tmp

clean: clean_c clean_cfitsio clean_tmp
