blob: 3b2c17254361f2c531b85aee0ce99dd6ffe8185f (
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
49
50
51
52
53
54
|
VERSION:=$(shell git describe --dirty | sed 's/^v//; s/-/./g')
PREFIX=/usr
MANDIR=$(PREFIX)/share/man
BINDIR=$(PREFIX)/bin
LIBDIR=$(PREFIX)/lib
MY_LIBDIR=$(LIBDIR)/fb-client
CC?=cc
CFLAGS:=-std=c99 -O2 -Wall -Wextra -pedantic $(CFLAGS)
LIBCURL:=$(shell pkg-config --silence-errors --libs --cflags libcurl)
ifdef LIBCURL
all: fb fb-helper
else
all: fb
endif
fb: fb.in
@[ -n "$(VERSION)" ] || (echo "Error: version detection failed"; exit 1)
sed 's|@VERSION@|$(VERSION)|; s|@LIBDIR@|$(MY_LIBDIR)|' $< > $@
chmod 755 $@
fb-helper: fb-helper.c
$(CC) $(CFLAGS) $(LDFLAGS) -DVERSION=\"$(VERSION)\" -o $@ $< $(LIBCURL)
clean:
rm -f fb fb-helper
rm -rf dist
install: all
install -dm755 $(DESTDIR)$(BINDIR)
install -m755 fb $(DESTDIR)$(BINDIR)/fb
ifdef LIBCURL
install -dm755 $(DESTDIR)$(MY_LIBDIR)
install -m755 fb-helper $(DESTDIR)$(MY_LIBDIR)/fb-helper
endif
install -dm755 $(DESTDIR)$(MANDIR)/man1
install -m644 fb.1 $(DESTDIR)$(MANDIR)/man1/fb.1
uninstall:
rm -f $(DESTDIR)$(BINDIR)/fb
rm -rf $(DESTDIR)$(MY_LIBDIR)
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-helper.c fb{,.in} 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
|