#

CFLAGS= -I include -Wall -Wno-format
CC= gcc
TI= include/Tlib
LFLAGS=
CFLAGS+= -g

TESTPROGS= test-avlprinter test-queue test-rx test-shell

all: tlib.a 

test: $(TESTPROGS)

clean:
	rm -f tlib.a *.o *.bak $(TESTPROGS)

tlib.a: avl.o shell.o queue.o assert.o stack.o math.o set.o list.o vector.o \
dict.o rx.o avlprinter.o io.o
	ar rc $@ $?

dict.o: dict.c $(TI)/dict.h $(TI)/avl.h
queue.o: queue.c $(TI)/queue.h
vector.o: vector.c $(TI)/vector.h
stack.o: stack.c $(TI)/stack.h
set.o: set.c $(TI)/set.h
list.o: list.c $(TI)/list.h
assert.o: assert.c $(TI)/assert.h
shell.o: shell.c $(TI)/shell.h
math.o: math.c $(TI)/math.h
avl.o: avl.c $(TI)/avl.h avl-private.h
printer.o: printer.c $(TI)/avl.h avl-private.h printer.h
rx.o: rx.c rx_predefs $(TI)/rx.h

rx_genpredefs: rx.c rx_genpredefs.c $(TI)/rx.h
	gcc -o $@ rx_genpredefs.c $(CFLAGS)

rx_predefs: rx_genpredefs
	./rx_genpredefs  > $@

test-avlprinter: test-avlprinter.o avlprinter.o avl.o
test-queue: test-queue.o queue.o shell.o
test-queue: LFLAGS+= -lreadline -ltermcap
test-shell: test-shell.o shell.o
test-shell: LFLAGS+= -lreadline -ltermcap
test-rx: rx.o test-rx.o

test-%: %.o
	gcc -o $@ $^ $(LFLAGS)

