# Compile tek401x driver routines and put .o files into standard directory
# to be wrapped up into library with other routines by master Makefile.
# Determines what to make by whether C binding is up-to-date relative to
# source, but compiles both C and Fortran binding versions.
# Phil Farrell, Stanford Earth Sciences
# 29 March 1989

# MARGS can be used in testing to pass argument to recursive make call.
MARGS=
# LIBGKS may be overridden by top level makefile.
LIBGKS = ../../libgks.a
# Expects CFLAGS to be supplied by top level makefile.

CFILES =  tek401x.c
OFILES =  tek401x.o

# all compiled modules put into OBJDIR to be wrapped up later into library.
OBJDIR = ../../.objects

default: $(LIBGKS)

# Top level Makefile has already de-archived library into OBJDIR.
# If library is out of date with regard to any of the source files here, 
# first move the de-archived object files to this directory, then
# recursively call make to only update the specific ones that are changed.
$(LIBGKS): ${CFILES}
	-thisdir=`pwd`; cd $(OBJDIR); mv $(OFILES) $$thisdir > /dev/null 2>&1
	make $(MARGS) CFLAGS="$(CFLAGS)" objs
	-mv *.o $(OBJDIR)

objs: $(OFILES)

# If C binding routine out of date, also make Fortran binding version
.c.o:
	cc -c $(CFLAGS) $*.c
	cp $*.c $*_.c
	cc -c $(CFLAGS) -DFORTRAN $*_.c
	rm -f $*_.c

clean:
	-rm -f *.o *_.c
	-cd $(OBJDIR); rm -f $(OFILES)

