include config.mk

PREFIX?=/usr/local/
CFLAGS  += -pedantic -Wall -Wextra -Wmissing-prototypes \
           -Wstrict-prototypes -Wwrite-strings ${EXTRAFLAGS}

.SUFFIXES: .c .o

.c.o:
	${CC} ${CFLAGS} -c $<

all: vger

clean:
	find . \( -name vger -o \
		  -name unit_test -o \
		  -name "*.o" -o \
		  -name "*.core" \) \
		  -delete

vger: main.c vger.c mimes.o utils.o opts.h
	${CC} ${CFLAGS} -o $@ main.c mimes.o utils.o

install: vger
	install -o root -g wheel vger ${PREFIX}/bin/
	install -o root -g wheel vger.8 ${PREFIX}/man/man8/

unit_test: tests.c vger.o
	${CC} ${CFLAGS} -o $@ vger.o tests.c mimes.o utils.o

test: vger unit_test
	./unit_test
	cd tests && sh test.sh
