CC = cc -std=c99
CFLAGS = -Wall -g -I$(PSLIB_DIR)/include

PSLIB_DIR = ../..

# array.o dlist.o 
libUtils.a : error.o hash.o logmsg.o memory.o misc.o trace.o
	ar r libUtils.a $?
	ranlib libUtils.a
#
# Error codes
#
psErrorCodes.c : $(PSLIB_DIR)/src/Utils/psErrorCodes.dat
	$(PSLIB_DIR)/bin/makeErrorCodes -c psErrorCodes.c -h $(PSLIB_DIR)/include/psErrorCodes.h \
			$(PSLIB_DIR)/src/Utils/psErrorCodes.dat
error.o : psErrorCodes.c
#
# Test code
#
TST_PROGS = tst_array tst_dlist tst_error tst_hash tst_logmsg tst_memory tst_trace
test : $(TST_PROGS)
	for p in $(TST_PROGS); do \
		echo $$p; \
		$$p; \
	done
tst_array : libUtils.a tst_array.o
	$(CC) -o tst_array tst_array.o libUtils.a
tst_dlist : libUtils.a tst_dlist.o
	$(CC) -o tst_dlist tst_dlist.o libUtils.a
tst_error : libUtils.a tst_error.o
	$(CC) -o tst_error tst_error.o libUtils.a
tst_hash : libUtils.a tst_hash.o
	$(CC) -o tst_hash tst_hash.o libUtils.a
tst_logmsg : libUtils.a tst_logmsg.o
	$(CC) -o tst_logmsg tst_logmsg.o libUtils.a
tst_memory : libUtils.a tst_memory.o
	$(CC) -o tst_memory tst_memory.o libUtils.a
tst_trace : libUtils.a tst_trace.o
	$(CC) -o tst_trace tst_trace.o libUtils.a
#
#
_tags :;
tags : _tags
	etags *.[ch]
#
clean :
	$(RM) $(TST_PROGS) *.o *.a *.log *.dvi *.aux *.toc *.log *.out *~ core TAGS psErrorCodes.c
empty : clean
