-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGNUmakefile
69 lines (57 loc) · 1.86 KB
/
GNUmakefile
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
PROG= cpdup
MAN= cpdup.1
SRCS= $(wildcard src/*.c)
OBJS= $(SRCS:.c=.o)
DISTFILES= GNUmakefile LICENSE README.md src $(MAN)
DISTFILES+= BACKUPS PORTING
CFLAGS= -O -pipe -std=c99 -pedantic
CFLAGS+= -Wall -Wextra -Wlogical-op -Wshadow -Wformat=2 \
-Wwrite-strings -Wcast-qual -Wcast-align
#CFLAGS+= -Wduplicated-cond -Wduplicated-branches \
-Wrestrict -Wnull-dereference \
#CFLAGS+= -Wconversion
CFLAGS+= $(shell pkg-config --cflags openssl)
LIBS+= $(shell pkg-config --libs openssl)
OS?= $(shell uname -s)
ifeq ($(OS),FreeBSD)
CFLAGS+= -D_ST_FLAGS_PRESENT_
else ifeq ($(OS),Linux)
CFLAGS+= -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
CFLAGS+= $(shell pkg-config --cflags libbsd-overlay)
LIBS+= $(shell pkg-config --libs libbsd-overlay)
endif
PREFIX?= /usr/local
MAN_DIR?= $(PREFIX)/share/man
TMPDIR?= /tmp
RPMBUILD_DIR?= $(TMPDIR)/$(PROG)-rpmbuild
ARCHBUILD_DIR?= $(TMPDIR)/$(PROG)-archbuild
all: $(PROG)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
install:
install -s -Dm 0755 $(PROG) $(PREFIX)/bin/$(PROG)
install -Dm 0644 $(MAN) $(MAN_DIR)/man1/$(MAN)
gzip -9 $(MAN_DIR)/man1/$(MAN)
rpm:
mkdir -p $(RPMBUILD_DIR)/BUILD
cp -Rp $(DISTFILES) $(RPMBUILD_DIR)/BUILD/
rpmbuild -bb -v \
--define="_topdir $(RPMBUILD_DIR)" \
linux/$(PROG).spec
@arch=`uname -m` ; \
pkg=`( cd $(RPMBUILD_DIR)/RPMS/$${arch}; ls $(PROG)-*.rpm )` ; \
cp -v $(RPMBUILD_DIR)/RPMS/$${arch}/$${pkg} . ; \
rm -rf $(RPMBUILD_DIR) ; \
echo "Install with: 'sudo yum localinstall $${pkg}'"
archpkg:
mkdir -p $(ARCHBUILD_DIR)/src
cp linux/PKGBUILD $(ARCHBUILD_DIR)/
cp -Rp $(DISTFILES) $(ARCHBUILD_DIR)/src/
( cd $(ARCHBUILD_DIR) && makepkg )
@pkg=`( cd $(ARCHBUILD_DIR); ls $(PROG)-*.pkg.* )` ; \
cp -v $(ARCHBUILD_DIR)/$${pkg} . ; \
rm -rf $(ARCHBUILD_DIR) ; \
echo "Install with: 'sudo pacman -U $${pkg}'"
clean:
rm -f $(PROG) $(OBJS)
.PHONY: all install clean rpm archpkg