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

#
#  Makefile for Adlib/src/pcrcFortran
#

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 = pcrc.o pcrc_clock.o pcrc_stack.o

LIB     = libpcrcf.a

all: $(LIB)

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

pcrc_stack.o : pcrc_stack.f pcrc_stack.inc
	$(FCL) $(OPT) $(FC_OPT) -c pcrc_stack.f

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

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

clean:
	rm -f *.o core

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

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

uninstall:
	for i in pcrcf ;\
	do (rm -f ${bindir}/$$i); done
	for i in  pcrc.inc        pcrc90.inc      pcrc_stack.inc ;\
	do (rm -f ${includedir}/$$i); done
	rm -f ${libdir}/$(LIB)	

