# Top-level Makefile for MM5toGRIB

SHELL=/bin/ksh

.IGNORE:

CD  =   cd
LN  =   ln -s
MAKE    =   make -i -f Makefile
RM  =   /bin/rm -f
RM_LIST =   *.o MM5toGRIB core

# Supported architectures

# Linux ifc compiler
# "FC  =   ifc"\
# "LIBDIR  =   -L/home/alf/MM5V3/MM5toGRIB/lib/emosdir_000220"\
# "LIBEMOS =   -lemos"\
# "FFLAGS =    -FR -Vaxlib -w" ) ; \
# Linux pgf90 compiler
# "FC  =   pgf90"\
# "LIBDIR  =   -L/home/alf/MM5V3/MM5toGRIB/lib/emosdir_000220_r4_static"\
# "LIBEMOS =   -lemos_pgf90_static3"\
# "FFLAGS =    -i4 -r4 -w -Mpreprocess -Mfreeform -Bstatic -byteswapio" ) ; \

default:
	uname -a > .tmpfile
	grep SUN .tmpfile ; \
	if [ $$? = 0 ]; then echo "Compiling for SUN" ; \
		( $(CD) ./src ; $(MAKE) all\
		"RM  = $(RM)"\
		"MAKE       = $(MAKE)"\
		"LN  = $(LN)"\
		"FC  =   f95"\
		"LIBDIR  =   -L/export/home/alfons/MM5V3/Util/MM5toGRIB/lib/emosdir_000220/"\
		"LIBEMOS =   -lemos_200"\
		"FFLAGS =	-free" ) ; \
	else \
	grep Linux .tmpfile ; \
	if [ $$? = 0 ]; then echo "Compiling for Linux" ; \
		( $(CD) ./src ; $(MAKE) all\
		"RM  = $(RM)"\
		"MAKE       = $(MAKE)"\
		"LN  = $(LN)"\
		"FC  =   pgf90"\
		"LIBDIR  =   -L/home/alf/MM5V3/MM5toGRIB/lib"\
		"LIBEMOS =   -lgribex_pgf90_i4r4_static"\
		"FFLAGS =    -i4 -r4 -w -Mpreprocess -Mfreeform -byteswapio" ) ; \
	else \
	grep crayx1 .tmpfile ; \
	if [ $$? = 0 ]; then echo "Compiling for cray X1" ; \
		( $(CD) ./src ; $(MAKE) all\
		"RM  = $(RM)"\
		"MAKE       = $(MAKE)"\
		"LN  = $(LN)"\
		"FC  =   ftn"\
		"LIBDIR  =   -L/desa/inf/emos"\
		"LIBEMOS =   -lemos_240"\
		"OFLAGS =   "\
		"FFLAGS =   -e Z -I. -ra" ) ; \
	fi ; \
	fi ; \
	fi ; \

clean:
	uname -a > .tmpfile
	grep SUN .tmpfile ; \
	if [ $$? = 0 ]; then echo "Clean for SUN" ; \
		( $(CD) ./src ; $(MAKE) clean "RM = $(RM)" "RM_LIST = $(RM_LIST)" ) ; \
	else \
	grep Linux .tmpfile ; \
	if [ $$? = 0 ]; then echo "Clean for Linux" ; \
                ( $(CD) ./src ; $(MAKE) clean "RM = $(RM)" "RM_LIST = $(RM_LIST)" ) ; \
	else \
	grep crayx1 .tmpfile ; \
	if [ $$? = 0 ]; then echo "Clean for cray X1" ; \
		( $(CD) ./src ; $(MAKE) clean "RM = $(RM)" "RM_LIST = $(RM_LIST) *.lst" ) ; \
	fi ; \
	fi ; \
	fi ; \

