default: install
help:
	@echo "make options: install libohana clean dist"

include ../../Makefile.System
HOME 	=	$(ROOT)/src/libohana
BIN	= 	$(HOME)/bin
LIB	= 	$(HOME)/lib
SRC	=	$(HOME)/src
MAN	=	$(HOME)/doc
INC	=	$(HOME)/include
TESTDIR =       $(HOME)/test
include ../../Makefile.Common

# programs may add their own internal requirements here
FULL_CFLAGS   = $(BASE_CFLAGS) -fPIC
FULL_CPPFLAGS = $(BASE_CPPFLAGS)
FULL_LDFLAGS  = $(BASE_LDFLAGS)
TFLAGS        = $(FULL_CFLAGS) $(FULL_CPPFLAGS) $(FULL_LDFLAGS) -lohana -ltap_ohana

install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE)
libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).$(DLLTYPE)

INCS = \
$(DESTINC)/ohana_allocate.h \
$(DESTINC)/ohana_sort.h \
$(DESTINC)/ohana.h

OBJS = \
$(SRC)/ohana_allocate.$(ARCH).o  \
$(SRC)/sorts.$(ARCH).o		 \
$(SRC)/string.$(ARCH).o		 \
$(SRC)/findexec.$(ARCH).o	 \
$(SRC)/glockfile.$(ARCH).o	 \
$(SRC)/time.$(ARCH).o		 \
$(SRC)/gaussj.$(ARCH).o		 \
$(SRC)/config.$(ARCH).o		 \
$(SRC)/Fread.$(ARCH).o		 \
$(SRC)/IOBufferOps.$(ARCH).o	 \
$(SRC)/CommOps.$(ARCH).o	 \
$(SRC)/version.$(ARCH).o

TEST = \
$(TESTDIR)/string.$(ARCH)

testcode: install $(TEST)
test:
	make testcode
	for i in $(TEST); do $$i; done

$(OBJS): $(INCS)

$(LIB)/libohana.$(ARCH).a: $(OBJS)
$(LIB)/libohana.$(ARCH).$(DLLTYPE): $(OBJS)

$(DESTLIB)/libohana.a:  $(LIB)/libohana.$(ARCH).a
$(DESTLIB)/libohana.$(DLLTYPE): $(LIB)/libohana.$(ARCH).$(DLLTYPE)

$(TESTDIR)/%.$(ARCH) : $(TESTDIR)/%.c
	$(CC) $^ -o $@ $(TFLAGS)

.PHONY: test

