# Define ARCH to be one the of architectures found in the conf directory.
# The names are the same as the ones used for compiling pvm, so you might
# want to use the value of PVM_ARCH.
ARCH	= SGI

# Set FORTRAN compiler and flags for ARCH
F77     = f77
FFLAGS  = -O1

# Set C compiler and flags for ARCH
CC      = cc
CFLAGS 	= -cckr -O -D$(ARCH)

# Set HASRANLIB to t if your system needs ranlib
HASRANLIB = f	

# Set LIBS to libraries to link your c program with
# for SUN Solaris 2:
# LIBS = -lnsl
LIBS = -lsun

SHELL	= /bin/sh
# set RM to rm -f if you want to remove the intermediate C source file
# generated for the FORTRAN interface library
RMCMD 	= rm -f
#RMCMD	= /bin/true
M4 	= m4
M4FILE	= conf/$(ARCH).m4

LFOBS 	= libxdrf.o xtciof.o
LOBS	= xdr3dfcoord.o

default: libxdrf.a ctest ftest xtc2tra tra2xtc

libxdrf.a:  $(LFOBS) ftocstr.o
	ar cr libxdrf.a $?
	case x$(HASRANLIB) in xt ) echo ranlib; ranlib libxdrf.a ;; esac

ctest:	ctest.c libxdrf.a 
	$(CC) -o ctest $(CFLAGS) ctest.c libxdrf.a -lm $(LIBS)

ftest:	ftest.f libxdrf.a
	$(F77) -o ftest $(FFLAGS) ftest.f libxdrf.a $(LIBS)

xtc2tra:  xtc2tra.f libxdrf.a
	$(F77) -o xtc2tra $(FFLAGS) xtc2tra.f libxdrf.a $(LIBS)

tra2xtc:  tra2xtc.f libxdrf.a
	$(F77) -o tra2xtc $(FFLAGS) tra2xtc.f libxdrf.a $(LIBS)

clean:
	rm -f $(LFOBS) $(LOBS) ftocstr.o libxdrf.a

tidy:
	rm -f $(LOBS) $(LFOBS)

ftocstr.o: ftocstr.c
	$(CC) $(CFLAGS) -c ftocstr.c

libxdrf.o:	libxdrf.m4 $(M4FILE)
	$(M4) $(M4FILE) libxdrf.m4 > libxdrf.c
	$(CC) $(CFLAGS) -c libxdrf.c
	$(RMCMD) libxdrf.c

conf/.m4:
	@echo "ERROR: you didn't set ARCH in the Makefile"
