#	upa 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 cio.o conv_adp_r.o gbytesys.o manadp.o \
		proupr.o sigadp.o wppadp.o wzzadp.o adp_upa.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           =       IBM"                            \
		"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 ;


target:		adp_upa.exe

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

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

adp_upa.o:	adp_module.o
proupr.o:	adp_module.o
manadp.o:	adp_module.o
sigadp.o:	adp_module.o
wppadp.o:	adp_module.o
wzzadp.o:	adp_module.o
