forked from romilly/quick2wire-gpio-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (58 loc) · 1.5 KB
/
Makefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
PROJECT=quick2wire-gpio-admin
VERSION=1.0.0
PACKAGE=$(PROJECT)-$(VERSION)
CC=gcc
CFLAGS=-Wall -O2
ARCH:=$(shell uname -s)-$(shell uname -m)
SRCDIR=src
OUTDIR=out/$(ARCH)
SRC=$(wildcard $(SRCDIR)/*.c)
OBJS=$(SRC:$(SRCDIR)/%.c=$(OUTDIR)/%.o)
ifndef DESTDIR
DESTDIR=/usr/local
endif
all: $(OUTDIR)/gpio-admin out/gpio-admin.1.gz
.PHONY: all
dist: out/$(PACKAGE).tar.gz
.PHONY: dist
package: out/$(PACKAGE).tar.gz
mkdir -p out/package
cp out/$(PACKAGE).tar.gz out/package/$(PROJECT)_$(VERSION).orig.tar.gz
(cd out/package && tar xzf $(PROJECT)_$(VERSION).orig.tar.gz)
(cd out/package/$(PACKAGE) && dh_make)
.PHONY: package
out/$(PACKAGE).tar.gz:
mkdir -p out/
ln -s $(PWD) out/$(PACKAGE)
tar czf out/$(PACKAGE).tar.gz \
--dereference \
--exclude-vcs \
--exclude="out" \
-C out/ $(PACKAGE)
rm out/$(PACKAGE)
$(OUTDIR)/gpio-admin: $(OBJS)
$(OUTDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $< -c -o $@
out/gpio-admin.1.gz: man/gpio-admin.1
gzip -c $< > $@
install: install-files
groupadd -f --system gpio
chgrp gpio $(DESTDIR)/bin/gpio-admin
chmod u=rwxs,g=rx,o= $(DESTDIR)/bin/gpio-admin
.PHONY: install
install-files: all
mkdir -p $(DESTDIR)/bin/
install $(OUTDIR)/gpio-admin $(DESTDIR)/bin/
mkdir -p $(DESTDIR)/share/man/man1/
install out/*.1.gz $(DESTDIR)/share/man/man1/
.PHONY: install-files
uninstall:
rm -vf $(DESTDIR)/bin/gpio-admin $(DESTDIR)/share/man/man1/gpio-admin.1.gz
delgroup gpio
.PHONY: uninstall
clean :
rm -rf out
.PHONY: clean
again: clean all
.PHONY: again