VERSION=0.3.7
CFLAGS=-O2 -Wall
LIBS=-lm -lrt

prefix = /usr
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin

all: hist bogoseek

hist: hist.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS)

bogoseek: bogoseek.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS)

bogoseek.h: ver.h

bogoseek.c: bogoseek.h

ver.h: Makefile
	echo '#define PACKAGE_VERSION		"$(VERSION)"' > ver.h

distclean: clean

clean:;
	rm -rf hist bogoseek hist.o bogoseek.o

install: all
	mkdir -p $(DESTDIR)$(bindir)
	install bogoseek $(DESTDIR)$(bindir)
	install hist $(DESTDIR)$(bindir)

dist:
	@if test "`git describe`" != "$(VERSION)" ; then \
		echo 'Update VERSION in the Makefile/bogoseek.h before running "make dist".' ; \
		exit 1 ; \
	fi
	git archive --format=tar --prefix=bogoseek-$(VERSION)/ HEAD^{tree} | gzip -9 > bogoseek-$(VERSION).tar.gz
