#	sfc obs makefile

.IGNORE:

SHELL	=	/bin/sh
.SUFFIXES:	.F .f .c .i .o

.f.o:
		$(FC) -c $(FCFLAGS)  $<
.F.o:
		$(FC) -c $(FCFLAGS) -D$(MACH) $<
.c.o:
		$(CC) -c $(CFLAGS) -D$(MACH) -D$(WLENGTH) $< 

MAKE	=	make 
OBJS	=	adp_module.o build_hdate.o cio.o gbytesys.o geth_newdate.o getsfcobs_hcl.o
RM	=	/bin/rm -f

default:
	uname -a > .tmpfile
	grep CRAY .tmpfile ; \
	if [ $$? = 0 ]; then echo "Compiling for CRAY" ; \
		$(MAKE) target  \
		"MACH		=	CRAY"  \
		"WLENGTH	=	BIT64"  \
		"FC		=	f90"  \
		"FCFLAGS	=	-f free" \
		"CC		=	cc"  \
		"CFLAGS		=	"  \
		"LDOPTIONS	=	-Wl'-i CRAY.LONG.LINES' "  \
		"LIBS		=	"  ; \
	else \
	grep OSF .tmpfile ; \
	if [ $$? = 0 ]; then echo "Compiling for Compaq" ; \
		$(MAKE) target  \
		"MACH		=	DEC"  \
		"WLENGTH	=	BIT32"  \
		"FC		=	f90"  \
		"FCFLAGS	=	-free -convert big_endian -fpe" \
		"CC		=	cc"  \
		"CFLAGS		=	"  \
		"LDOPTIONS	=	"  \
		"LIBS		=	" ; \
	else \
	grep AIX .tmpfile ; \
	if [ $$? = 0 ]; then echo "Compiling for IBM" ; \
		$(MAKE) target  \
		"MACH		=	AIX"  \
		"WLENGTH	=	BIT32"  \
		"FC		=	xlf"  \
		"FCFLAGS	=	-qfree=f90" \
		"CC		=	cc"  \
		"CFLAGS		=	"  \
		"LDOPTIONS	=	"  \
		"LIBS		=	" ; \
        else \
        grep IRIX .tmpfile ; \
        if [ $$? = 0 ]; then echo "Compiling for SGI" ; \
                $(MAKE) target  \
                "MACH           =       SGI"  \
                "WLENGTH        =       BIT32"  \
                "FC             =       f90"  \
                "FCFLAGS        =       -freeform -n32" \
                "CC             =       cc"  \
                "CFLAGS         =       "  \
                "LDOPTIONS      =       -n32"  \
                "LIBS           =       " ; \
        else \
        grep SUN .tmpfile ; \
        if [ $$? = 0 ]; then echo "Compiling for SUN" ; \
                $(MAKE) target  \
                "MACH           =       SUN"  \
                "WLENGTH        =       BIT32"  \
                "FC             =       f90"  \
                "FCFLAGS        =       -ansi -free" \
                "CC             =       cc"  \
                "CFLAGS         =       "  \
                "LDOPTIONS      =       "  \
                "LIBS           =       " ; \
        else \
        grep Linux .tmpfile ; \
        if [ $$? = 0 ]; then echo "Compiling for Linux" ; \
                $(MAKE) target  \
                "MACH           =       DEC"  \
                "WLENGTH        =       BIT32"  \
                "FC             =       pgf90"  \
                "FCFLAGS        =       -Mfreeform -byteswapio" \
                "CC             =       cc"  \
                "CFLAGS         =       "  \
                "LDOPTIONS      =       "  \
                "LIBS           =       " ; \
        fi ; \
        fi ; \
        fi ; \
	fi ; \
	fi ; \
	fi ; \
		echo "done"  ;


target:		adp_sfc.exe

adp_sfc.exe: 	$(OBJS) 
		$(FC) -o $@ $(LDOPTIONS) $(OBJS) $(LIBS)

clean:
		$(RM) *.o *.exe fort.* core

getsfcobs_hcl.o: adp_module.o
