summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 44af9cba390304962538853a951156a9571ea2d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
VERSION:=$(shell git describe --dirty | sed 's/^v//')
MANDIR=/usr/share/man
BINDIR=/usr/bin
LIBDIR=/usr/lib
CC=gcc
CFLAGS=-O2 -std=c99 -Wall -Wextra -pedantic

all: fb.1 fb fb-upload

fb: fb.in
	@[ -n "$(VERSION)" ] || (echo "Error: version detection failed"; exit 1)
	sed 's|@VERSION@|$(VERSION)|; s|@LIBDIR@|$(LIBDIR)|' fb.in > fb
	chmod 755 fb

fb-upload.c: fb-upload.c.in
	sed 's/@VERSION@/$(VERSION)/' fb-upload.c.in > fb-upload.c

fb-upload: fb-upload.c
	$(CC) $(CFLAGS) -lcurl -lm -o fb-upload fb-upload.c

fb.1: fb.pod
	pod2man -c "" fb.pod fb.1

clean:
	rm -f fb.1 fb fb-upload.c fb-upload
	rm -rf dist

install: all
	install -Dm755 fb $(DESTDIR)$(BINDIR)/fb
	install -Dm755 fb-upload $(DESTDIR)$(LIBDIR)/fb-upload
	install -Dm644 fb.1 $(DESTDIR)$(MANDIR)/man1/fb.1

uninstall:
	rm -f $(DESTDIR)$(BINDIR)/fb
	rm -f $(DESTDIR)$(LIBDIR)/fb-upload
	rm -f $(DESTDIR)$(MANDIR)/man1/fb.1

dist: all
	@[ -n "$(VERSION)" ] || (echo "Error: version detection failed"; exit 1)
	mkdir -p dist/fb-$(VERSION)
	cp -a fb fb-upload.c fb.in fb.pod fb.1 COPYING Makefile dist/fb-$(VERSION)
	sed -i 's/^VERSION:=.*$$/VERSION:="'$(VERSION)'"/' dist/fb-$(VERSION)/Makefile
	cd dist; tar -czf fb-$(VERSION).tar.gz fb-$(VERSION)

version:
	@echo $(VERSION)

.PHONY: all install clean uninstall version dist