###
### I think it's not worth to make such a small project
### modular. So this is a simple gnu Makefile...
###
### $Id: Makefile 12177 2015-08-15 13:46:56Z NiLuJe $
###

.DELETE_ON_ERROR:
.PHONY: install clean all

GZIP := gzip
GZIPFLAGS := --best --to-stdout

# Build version string w/ the SVN revision of the file...
SVNREV := -DVERSION='"1.3.$(shell sed -ne '/Revision:/p' fbgrab.c | sed -re 's/(.*?)(Revision: )([[:digit:]]*)(.*?)/\3/').N"'

all: fbgrab fbgrab.1.gz

fbgrab: fbgrab.c
	$(CC) $(CPPFLAGS) $(SVNREV) -Wall -Wformat -Wformat-security -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -Wcast-align -Wconversion $(CFLAGS) $(LDFLAGS) $< -lpng -lm -lz -o $@

fbgrab.1.gz: fbgrab.1.man
	$(GZIP) $(GZIPFLAGS) $< > $@

install: fbgrab fbgrab.1.gz
	install -D -m 0755 fbgrab $(DESTDIR)/usr/bin/fbgrab
	install -D -m 0644 fbgrab.1.gz $(DESTDIR)/usr/share/man/man1/fbgrab.1.gz

clean:
	-$(RM) fbgrab fbgrab.1.gz *~ \#*\#
