include ../../Makefile.generic
FUNCS_DIR = ..
TOBJDIR = $(FUNCS_DIR)/build/obj
TLIBDIR = $(FUNCS_DIR)/build/lib

TARGET = bwf
TARGETLIB = $(TLIBDIR)/lib$(TARGET).a
SRC = $(TARGET).cpp
OBJFILES = $(SRC:.cpp=.o)
OBJS = $(addprefix $(TOBJDIR)/,$(OBJFILES))

all: $(TARGETLIB)

$(TARGETLIB): $(OBJS)
	rm -f $@
	$(AR) rv $@ $(OBJS)
	$(RANLIB) $@

clean: clean_objs
	rm -f *~ test-bwf *.log

clean_objs:
	rm -f $(OBJS) $(TARGETLIB)

$(TOBJDIR)/$(TARGET).o: $(TARGET).cpp $(TARGET).h
	rm -f $@
	$(CXX) $(CXXFLAGS) -c -o $@ $<

test: all test-bwf.cpp
	$(CXX) -o test-bwf test-bwf.cpp $(CXXFLAGS) $(LDFLAGS) -l$(TARGET)
