#GNU Makefile to build Library libplot_fpreact.a 
#
#11/20/02 C. Ludescher
#

ifneq ($(MAKELEVEL),0)
# if OBJ was defined for main Makefile one level down
ifeq ("${OBJ}",".")
	override OBJ=..
endif
endif

# define system dependent flags, etc.
-include  ../share/Make.local
include ../share/Make.flags



ifdef DEBUG
        FFLAGS := $(DFFLAGS)
endif


.PHONY: all install clean realclean

ARC =  $(OBJ)/lib/libplot_fpreact.a
OBJDIR = $(OBJ)/obj/plot_fpreact

# don't rebuild library if using installed one in $PREFIX 
ifeq ($(MAKELEVEL),0)
	THISLIB=$(ARC)
endif


# library members
FMEM = $(subst .f90,.o, $(wildcard *.f90))
MEM = $(foreach m,$(FMEM),$(ARC)($(m)))


libs: chkdirs $(ARC)

all: libs
	@echo done 

$(OLDLIB): timestamp.inf
	@echo "--- DETECTED plot_fpreact.a source update"
	@echo "--- Re-Making $(ARC)"
	@$(MAKE) libs

chkdirs:
	@test -d $(OBJ)/lib || mkdir -p $(OBJ)/lib
	@test -d $(OBJ)/obj/plot_fpreact || mkdir -p $(OBJ)/obj/plot_fpreact

# compile f90
$(ARC)(%.o): %.f90
	$(FC90) $(FFLAGS) $(MODFLAGS) -I./ $(INCFLAGS) $(OUT) $(OBJDIR)/$*.o $<
	$(make_ar)

$(ARC): $(MEM)
	@$(RANLIB) $@ > /dev/null

#-------------------------------------------------------------
exec: 
	@echo 	   


install: installdirs installlib

installlib: 
	umask 133; cp $(OBJ)/lib/libplot_fpreact.a $(LIBDIR)


installdirs:
	@test -d $(LIBDIR) || mkdir -p $(LIBDIR)


clean:
	@rm -f $(OBJDIR)/*

realclean: clean
	@rm -f $(ARC)



