####################################################################
#   Copyright (c)
#
#   You may copy, distribute, and modify it freely as long as you  #
#   preserve this copyright and permission notice.                 #
#                                                                  #
#
####################################################################

#
#  Makefile for Adlib/src/shpfFortran
#

SHELL       = /bin/sh


srcdir      = @srcdir@
top_srcdir  = @top_srcdir@

prefix      = @prefix@
exec_prefix = @exec_prefix@

bindir      = @bindir@
includedir  = @includedir@
libdir      = @libdir@

config_dir = ../include

VPATH       = .:${srcdir}

FCL         = @FCL@
FC_OPT      = @FC_OPT@

OPT         = @OPTIMIZE@

PLATFORM    = @PLATFORM@

AR          = ar rcu
RANLIB      = @RANLIB@

INSTALL     = cp

OBJECTS = shpf.o farg.o gadlib.o

LIB     = libadaptf.a

all: $(LIB)

libadaptf.a : $(OBJECTS)
	rm -f $@
	$(AR) $@ $(OBJECTS)
	$(RANLIB) $@

shpf.o : shpf.C shpf.h ${top_srcdir}/src/include/ad++.h
	${top_srcdir}/src/script/ad++ -c $(OPT) $(PLATFORM) shpf.C

farg.o: farg.f
	$(FCL) $(FC_OPT) -c farg.f

gadlib.o: gadlib.f
	$(FCL) $(FC_OPT) -c gadlib.f

clean:
	rm -f *.o core

distclean:
	rm -f *.o core $(LIB)
	rm -f adaptf Makefile

install: $(LIB) 
	if [ ! -d ${bindir} ] ; then mkdir ${bindir} ; fi
	for i in adaptf ;\
	do ($(INSTALL) ${srcdir}/$$i ${bindir}); done
	if [ ! -d ${includedir} ] ; then mkdir ${includedir} ; fi
	if [ ! -d ${libdir} ] ; then mkdir ${libdir} ; fi
	$(INSTALL) $(LIB) ${libdir}

uninstall:
	for i in adaptf ;\
	do (rm -f ${bindir}/$$i); done
	rm -f ${libdir}/$(LIB)	

