-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (103 loc) · 3.42 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
############################# configurable section #############################
# configure install path
PREFIX?=/usr/local
LIBDIR?=/lib/
INCDIR?=/include/
INSTALL?=install
# configure debug or release build
# for debug build, uncomment the line below
#DEBUG?=-DDEBUG=1 -O0 -g3 -fno-inline -fstack-protector-all
DEBUG?=-O3
PKG_CONFIG?=pkg-config
YASCC?=$(shell $(PKG_CONFIG) --cflags yascreen)
YASLD?=$(shell $(PKG_CONFIG) --libs yascreen)
ifeq ("$(YASLD)","")
YASCC:=-lyascreen
YASLD:=
endif
# configure default tools
# make defines AR, so we have to override to gcc-ar, so -flto works
AR=gcc-ar
RANLIB?=gcc-ranlib
########################## end of configurable section #########################
VER=$(shell grep Revision yacli.c|head -n1|sed -e 's/.\+Revision: \([0-9.]\+\) \+.\+/\1/'|tr . ' '|awk '{printf "%i.%02u\n",$$1+$$2/100,$$2%100}')
# change options based on wild guess of compiler brand/type
ifeq ($(lastword $(subst /, ,$(CC))),tcc)
CCOPT:=-Wall $(DEBUG) -I.
STLINK:=-L. -static -lyascreen
else
ifeq ($(lastword $(subst /, ,$(CC))),clang)
CCOPT:=-Wall $(DEBUG) -I. --std=gnu89
STLINK:=-L. -lyascreen
else
CCOPT:=-Wall $(DEBUG) -I. --std=gnu89 -flto
STLINK:=-L. -lyascreen
endif
endif
ifeq ($(shell uname -s),OpenBSD)
ifeq ($(CC),cc)
CC:=egcc
endif
AR=ar
RANLIB=ranlib
CCOPT:=-Wall $(DEBUG) -I. --std=gnu89
endif
# shared library version
SOVERM:=0
SOVERF:=0.0.0
# allow to pass additional compiler flags
MYCFLAGS=$(DEBUG) $(CPPFLAGS) $(CFLAGS) $(YASCC) $(CCOPT)
MYLDFLAGS=$(LDFLAGS) $(YASLD) $(LDOPT)
all: libyacli.a libyacli.so yacli.pc
yacli.o: yacli.c yacli.h
$(CC) $(MYCFLAGS) -o $@ -c $<
yaclitest.o: yaclitest.c yacli.h
$(CC) $(MYCFLAGS) -o $@ -c $<
yaclitest: yaclitest.o yacli.o
$(CC) $(MYCFLAGS) -o $@ $^ $(STLINK)
libyacli.a: yacli.o
$(AR) r $@ $^
$(RANLIB) $@
libyacli.so: libyacli.so.$(SOVERM)
ln -sf $^ $@
libyacli.so.$(SOVERM): libyacli.so.$(SOVERF)
ln -sf $^ $@
libyacli.so.$(SOVERF): yacli.c yacli.h
$(CC) $(MYCFLAGS) -o $@ $< -fPIC -shared -Wl,--version-script,yacli.vers -Wl,-soname,libyacli.so.$(SOVERM) $(MYLDFLAGS)
yacli.pc: yacli.pc.in
sed \
-e 's|YACLIVERSION|$(VER)|' \
-e 's|YACLIPREFIX|$(PREFIX)|' \
-e 's|YACLILIBDIR|$(PREFIX)$(LIBDIR)|' \
-e 's|YACLIINCDIR|$(PREFIX)$(INCDIR)|' \
< $< > $@
install: libyacli.a libyacli.so yacli.pc
$(INSTALL) -Ds -m 644 -t $(DESTDIR)$(PREFIX)$(LIBDIR) libyacli.a
$(INSTALL) -D -m 644 -t $(DESTDIR)$(PREFIX)$(LIBDIR)/pkgconfig/ yacli.pc
ln -fs libyacli.so.$(SOVERF) $(DESTDIR)$(PREFIX)$(LIBDIR)libyacli.so.$(SOVERM)
ln -fs libyacli.so.$(SOVERM) $(DESTDIR)$(PREFIX)$(LIBDIR)libyacli.so
$(INSTALL) -Ds -m 644 -s -t $(DESTDIR)$(PREFIX)$(LIBDIR) libyacli.so.$(SOVERF)
$(INSTALL) -D -m 644 -t $(DESTDIR)$(PREFIX)$(INCDIR) yacli.h
-#$(INSTALL) -TDs -m 0644 yacli.3 $(DESTDIR)$(PREFIX)/share/man/man3/yacli.3
clean:
rm -f yaclitest yaclitest.shared yaclitest.o yacli.o libyacli.a libyacli.so libyacli.so.$(SOVERM) libyacli.so.$(SOVERF) yacli.pc
rebuild:
$(MAKE) clean
$(MAKE) -j all
mkotar:
$(MAKE) clean
-dh_clean
#$(MAKE) yacli.3
tar \
--xform 's,^[.],yacli-$(VER),' \
--exclude ./.git \
--exclude ./.gitignore \
--exclude ./.cvsignore \
--exclude ./CVS \
--exclude ./debian \
-Jcvf ../yacli_$(VER).orig.tar.xz .
-rm -f ../yacli_$(VER).orig.tar.xz.asc
gpg -a --detach-sign ../yacli_$(VER).orig.tar.xz
cp -fa ../yacli_$(VER).orig.tar.xz ../yacli-$(VER).tar.xz
cp -fa ../yacli_$(VER).orig.tar.xz.asc ../yacli-$(VER).tar.xz.asc
.PHONY: install clean rebuild all