include $(top_objdir)/src/lib/MakeVars
include $(top_objdir)/src/lib/libderiv/MakeVars

TARGET = $(top_objdir)/lib/libPSI_deriv.a

TRUESRC_C = $(shell echo `ls *.c`)
TRUESRC_CXX = $(shell echo `ls *.cc`)
LIBOBJ_C = $(TRUESRC_C:%.c=%.o)
LIBOBJ_CXX = $(TRUESRC_CXX:%.cc=%.o)
LIBOBJ = $(LIBOBJ_C) $(LIBOBJ_CXX)

default:: $(TARGET) $(TARGET_HEADERS)

%.$(OBJSUF): %.c
	$(CC) $(CFLAGS) -c $< $(OUTPUT_OPTION)

%.$(OBJSUF): %.cc
	$(CXX) $(CXXFLAGS) -c $< $(OUTPUT_OPTION)

#
# do installations
#

$(TARGET): $(LIBOBJ)
	$(MKDIRS) `dirname $(TARGET)`
	rm -f $(TARGET)
	$(AR) $(ARFLAGS) $(TARGET) $^
	$(RANLIB) $(TARGET)

$(top_objdir)/include/libderiv/%.h: %.h
	$(MKDIRS) `dirname $@`
	$(INSTALL_INCLUDE) $^ $@

#
# clean up
#

clean:: iclean oclean dclean targetclean

iclean:
	-rm -f *.gbl *.lcl

oclean:
	-rm -f *.o

dclean:
	-rm -f *.d

targetclean:
	-rm -f `basename $(TARGET)`
