SHELL	= /bin/sh
SRCS	= ptest_ctx.c ptest_error.c ptest_log.c pmock_expect.c ptest_run.c \
	msg_jmp.c
LIB_OBJ	= ptest_ctx.o ptest_error.o ptest_log.o pmock_expect.o ptest_run.o \
	msg_jmp.o
HDRS	= ptest.h pmock_expect.h ptest_main.h msg_jmp.h
TESTSRC	=
DEFS	= -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS	= $(DEBUG) $(OPT) $(DEFS)
INCL	=
LIB	= libptest.a
TESTPROG= pmock_expect_test ptest_log_test

LIBS    = ../../lib/lib$(LIB_PREFIX)global$(LIB_SUFFIX) \
	../../lib/lib$(LIB_PREFIX)util$(LIB_SUFFIX)
LIB_DIR	= ../../lib
INC_DIR	= ../../include
MAKES	=

.c.o:;	$(CC) $(SHLIB_CFLAGS) $(CFLAGS) -c $*.c

all: $(LIB_OBJ) $(MOCK_OBJ)

$(LIB_OBJ) $(TESTPROG): ../../conf/makedefs.out

Makefile: Makefile.in
	cat ../../conf/makedefs.out $? >$@

test:	$(TESTPROG)

$(LIB): $(LIB_OBJ)
	$(_AR) $(ARFL) $(LIB) $?
	$(_RANLIB) $(LIB)

$(LIB_DIR)/$(LIB): $(LIB)
	cp $(LIB) $(LIB_DIR)
	$(_RANLIB) $(LIB_DIR)/$(LIB)

update: $(LIB_DIR)/$(LIB) $(HDRS) $(MOCK_OBJ)
	-for i in $(HDRS); \
	do \
	  cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
	done
	(cd $(INC_DIR); chmod 644 $(HDRS))
	-for i in $(MOCK_OBJ); \
	do \
	  cmp -s $$i $(LIB_DIR)/$$i 2>/dev/null || cp $$i $(LIB_DIR); \
	done

clean:
	rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp

tidy:   clean

tests:	update test_pmock_expect test_ptest_log

pmock_expect_test: pmock_expect_test.o $(LIB) $(LIBS)
	$(CC) $(CFLAGS) -o $@ $@.o $(LIB) $(LIBS) $(SYSLIBS)

test_pmock_expect: update pmock_expect_test
	$(SHLIB_ENV) ${VALGRIND} ./pmock_expect_test

ptest_log_test: ptest_log_test.o ptest_log.o $(LIB) $(LIBS)
	$(CC) $(CFLAGS) -o $@ $@.o ptest_log.o $(LIB) $(LIBS) $(SYSLIBS)

test_ptest_log: update ptest_log_test
	$(SHLIB_ENV) ${VALGRIND} ./ptest_log_test

depend: $(MAKES)
	(sed '1,/^# do not edit/!d' Makefile.in; \
	set -e; for i in [a-z][a-z0-9]*.c; do \
	    $(CC) -E $(DEFS) $(INCL) $$i | grep -v '[<>]' | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \
	    -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' \
	    -e 's/o: \.\//o: /' -e p -e '}' ; \
	done | LANG=C sort -u) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in
	@$(EXPORT) make -f Makefile.in Makefile 1>&2

# do not edit below this line - it is generated by 'make depend'
msg_jmp.o: ../../include/msg.h
msg_jmp.o: ../../include/sys_defs.h
msg_jmp.o: msg_jmp.c
msg_jmp.o: msg_jmp.h
pmock_expect.o: ../../include/argv.h
pmock_expect.o: ../../include/check_arg.h
pmock_expect.o: ../../include/htable.h
pmock_expect.o: ../../include/msg.h
pmock_expect.o: ../../include/mymalloc.h
pmock_expect.o: ../../include/sys_defs.h
pmock_expect.o: ../../include/vbuf.h
pmock_expect.o: ../../include/vstream.h
pmock_expect.o: ../../include/vstring.h
pmock_expect.o: msg_jmp.h
pmock_expect.o: pmock_expect.c
pmock_expect.o: pmock_expect.h
pmock_expect.o: ptest.h
pmock_expect_test.o: ../../include/argv.h
pmock_expect_test.o: ../../include/check_arg.h
pmock_expect_test.o: ../../include/msg.h
pmock_expect_test.o: ../../include/msg_output.h
pmock_expect_test.o: ../../include/msg_vstream.h
pmock_expect_test.o: ../../include/mymalloc.h
pmock_expect_test.o: ../../include/myrand.h
pmock_expect_test.o: ../../include/stringops.h
pmock_expect_test.o: ../../include/sys_defs.h
pmock_expect_test.o: ../../include/vbuf.h
pmock_expect_test.o: ../../include/vstream.h
pmock_expect_test.o: ../../include/vstring.h
pmock_expect_test.o: msg_jmp.h
pmock_expect_test.o: pmock_expect.h
pmock_expect_test.o: pmock_expect_test.c
pmock_expect_test.o: ptest.h
pmock_expect_test.o: ptest_main.h
ptest_ctx.o: ../../include/argv.h
ptest_ctx.o: ../../include/check_arg.h
ptest_ctx.o: ../../include/msg.h
ptest_ctx.o: ../../include/mymalloc.h
ptest_ctx.o: ../../include/stringops.h
ptest_ctx.o: ../../include/sys_defs.h
ptest_ctx.o: ../../include/vbuf.h
ptest_ctx.o: ../../include/vstream.h
ptest_ctx.o: ../../include/vstring.h
ptest_ctx.o: msg_jmp.h
ptest_ctx.o: ptest.h
ptest_ctx.o: ptest_ctx.c
ptest_error.o: ../../include/argv.h
ptest_error.o: ../../include/check_arg.h
ptest_error.o: ../../include/msg.h
ptest_error.o: ../../include/mymalloc.h
ptest_error.o: ../../include/sys_defs.h
ptest_error.o: ../../include/vbuf.h
ptest_error.o: ../../include/vstream.h
ptest_error.o: ../../include/vstring.h
ptest_error.o: msg_jmp.h
ptest_error.o: ptest.h
ptest_error.o: ptest_error.c
ptest_log.o: ../../include/argv.h
ptest_log.o: ../../include/check_arg.h
ptest_log.o: ../../include/msg.h
ptest_log.o: ../../include/msg_output.h
ptest_log.o: ../../include/sys_defs.h
ptest_log.o: ../../include/vbuf.h
ptest_log.o: ../../include/vstream.h
ptest_log.o: ../../include/vstring.h
ptest_log.o: msg_jmp.h
ptest_log.o: ptest.h
ptest_log.o: ptest_log.c
ptest_log_test.o: ../../include/argv.h
ptest_log_test.o: ../../include/check_arg.h
ptest_log_test.o: ../../include/msg.h
ptest_log_test.o: ../../include/msg_output.h
ptest_log_test.o: ../../include/msg_vstream.h
ptest_log_test.o: ../../include/myrand.h
ptest_log_test.o: ../../include/stringops.h
ptest_log_test.o: ../../include/sys_defs.h
ptest_log_test.o: ../../include/vbuf.h
ptest_log_test.o: ../../include/vstream.h
ptest_log_test.o: ../../include/vstring.h
ptest_log_test.o: msg_jmp.h
ptest_log_test.o: pmock_expect.h
ptest_log_test.o: ptest.h
ptest_log_test.o: ptest_log_test.c
ptest_log_test.o: ptest_main.h
ptest_run.o: ../../include/argv.h
ptest_run.o: ../../include/check_arg.h
ptest_run.o: ../../include/msg.h
ptest_run.o: ../../include/msg_vstream.h
ptest_run.o: ../../include/sys_defs.h
ptest_run.o: ../../include/vbuf.h
ptest_run.o: ../../include/vstream.h
ptest_run.o: ../../include/vstring.h
ptest_run.o: msg_jmp.h
ptest_run.o: pmock_expect.h
ptest_run.o: ptest.h
ptest_run.o: ptest_run.c
