#-------------------------------------------------------------------------#
#                                                                         #
#  COPYRIGHT[copyright mark] 2000, Raytheon System Company, its vendors,  #
#  and suppliers.  ALL RIGHTS RESERVED.                                   #
#                                                                         #
#-------------------------------------------------------------------------#
#----------------------------------------------------------------------------
# file:		makefile for HDF-EOS testdrivers
# 	
# 
# author:  Abe Taaheri 
#
# history:
#	04 Jan-2006 AT Initial version
#       12 Dec 2006 AT Duplicated makefile with different name so that
#                   we could exclude makefile in testdriver directory
#                   for avoiding conflict with the automake makfile generation
#----------------------------------------------------------------------------

# force make to use the 'sh' shell
SHELL = /bin/ksh

# name of remove utility
MAKE=$(MAKECMD)
RM= /bin/rm
RMFLAGS= -f 
CFLAGS_SUN= -DSUN5
FFLAGS_SUN= -DSUN5
CFLAGS_HP11= -Aa -Ae -DHP9000 -Dunix
FFLAGS_HP11= -Aa -Ae -DHP9000 -Dunix
CFLAGS_HP10= -Aa -Ae -DHP9000 -Dunix
FFLAGS_HP10= -Aa -Ae -DHP9000 -Dunix
CFLAGS_DEC= -DDEC_ALPHA -Dunix
FFLAGS_DEC= -DDEC_ALPHA -Dunix
CFLAGS_IBM= -DIBM6000 -Dunix
FFLAGS_IBM= -DIBM6000 -Dunix
CFLAGS_ALL= -D$(HDFSYS)
FFLAGS_ALL= -D$(HDFSYS)
CFLAGS_SGIn32= -n32 -mips3 -DIRIX -Dunix
FFLAGS_SGIn32= -n32 -mips3 -DIRIX -Dunix
CFLAGS_SGI64= -64 -mips4 -DSGI64 -Dunix 
FFLAGS_SGI64= -64 -mips4 -DSGI64 -Dunix 
CFLAGS_IRX65= -64 -mips4 -DSGI64 -Dunix
FFLAGS_IRX65= -64 -mips4 -DSGI64 -Dunix
CFLAGS_LINUX= -O2 -ansi -Df2cFortran
FFLAGS_LINUX= -O2 -ansi -fno-second-underscore


CSUNLIB= -lnsl -lsocket
FSUNLIB= -lnsl -lsocket
CHP10LIB=
FHP10LIB=
CHP11LIB= -lnsl
FHP11LIB= -lnsl
CLINUXLIB= 
FLINUXLIB= 
CALLLIB=
FALLLIB=

all: select_brand

select_brand:
	@if [ $(BRAND) = "sun5.8" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_SUN)"; \
		FFLAGS="$(FFLAGS_SUN)"; \
		CEXTRAL="$(CSUNLIB)"; \
		FEXTRAL="$(FSUNLIB)"; \
	elif [ $(BRAND) = "sun5.9" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_SUN)"; \
		FFLAGS="$(FFLAGS_SUN)"; \
		CEXTRAL="$(CSUNLIB)"; \
		FEXTRAL="$(FSUNLIB)"; \
	elif [ $(BRAND) = "sun5.10" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_SUN)"; \
		FFLAGS="$(FFLAGS_SUN)"; \
		CEXTRAL="$(CSUNLIB)"; \
		FEXTRAL="$(FSUNLIB)"; \
	elif [ $(BRAND) = "hp" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_HP10)"; \
		FFLAGS="$(FFLAGS_HP10)"; \
		CEXTRAL="$(CHP10LIB)"; \
		FEXTRAL="$(FHP10LIB)"; \
	elif [ $(BRAND) = "hp11" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_HP11)"; \
		FFLAGS="$(FFLAGS_HP11)"; \
		CEXTRAL="$(CHP11LIB)"; \
		FEXTRAL="$(FHP11LIB)"; \
	elif [ $(BRAND) = "dec" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_ALL)"; \
		FFLAGS="$(FFLAGS_ALL)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "ibm" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_ALL)"; \
		FFLAGS="$(FFLAGS_ALL)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "irix65" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_SGI65)"; \
		FFLAGS="$(FFLAGS_SGI65)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "linux" ] ; then \
		CC="gcc -m32"; \
		F77="g77 -m32"; \
		CFLAGS="$(CFLAGS_LINUX)"; \
		FFLAGS="$(FFLAGS_LINUX)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "linux32" ] ; then \
		CC="gcc -m32"; \
		F77="g77 -m32"; \
		CFLAGS="$(CFLAGS_LINUX)"; \
		FFLAGS="$(FFLAGS_LINUX)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "linux64" ] ; then \
		CC="gcc"; \
		F77="g77"; \
		CFLAGS="$(CFLAGS_LINUX)"; \
		FFLAGS="$(FFLAGS_LINUX)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "sgi32" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_SGIn32)"; \
		FFLAGS="$(FFLAGS_SGIn32)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "sgi64" ] ; then \
		CC="cc"; \
		F77="f77"; \
		CFLAGS="$(CFLAGS_SGI64)"; \
		FFLAGS="$(FFLAGS_SGI64)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "macintosh" ] ; then \
		CC="gcc"; \
		F77="$(F77)"; \
		CFLAGS="$(CFLAGS_ALL)"; \
		FFLAGS="$(FFLAGS_ALL)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	elif [ $(BRAND) = "macintel" ] ; then \
		CC="gcc"; \
		F77="$(F77)"; \
		CFLAGS="$(CFLAGS_ALL)"; \
		FFLAGS="$(FFLAGS_ALL)"; \
		CEXTRAL="$(CALLLIB)"; \
		FEXTRAL="$(FALLLIB)"; \
	else \
		echo " The brand $(BRAND) is not supported. " ; \
		echo " Set the env. vriable BRAND to a supported one then make this makefile"; \
	fi ; \
	RM="$(RM)";\
	RMFLAGS="$(RMFLAGS)";\
	export CC F77 CFLAGS FFLAGS FEXTRAL;\
	export CEXTRAL RMFLAGS RM;\
	make -f make.com;



