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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
ifeq ($(shell uname),Darwin)
LIBTOOL ?= glibtool
else
LIBTOOL ?= libtool
endif
ifneq ($(VERBOSE),1)
LIBTOOL +=--quiet
endif
CFLAGS +=-Wall -std=c99
ifeq ($(DEBUG),1)
CFLAGS +=-ggdb -DDEBUG
endif
ifeq ($(PROFILE),1)
CFLAGS +=-pg
LDFLAGS+=-pg
endif
ifeq ($(shell pkg-config --atleast-version=0.1.0 unibilium && echo 1),1)
CFLAGS +=$(shell pkg-config --cflags unibilium) -DHAVE_UNIBILIUM
LDFLAGS+=$(shell pkg-config --libs unibilium)
else ifeq ($(shell pkg-config ncursesw && echo 1),1)
CFLAGS +=$(shell pkg-config --cflags ncursesw)
LDFLAGS+=$(shell pkg-config --libs ncursesw)
else
LDFLAGS+=-lncurses
endif
OBJECTS=termkey.lo driver-csi.lo driver-ti.lo
LIBRARY=libtermkey.la
DEMOS=demo demo-async
ifeq ($(shell pkg-config glib-2.0 && echo 1),1)
DEMOS+=demo-glib
endif
DEMO_OBJECTS=$(DEMOS:=.lo)
TESTSOURCES=$(wildcard t/[0-9]*.c)
TESTFILES=$(TESTSOURCES:.c=.t)
VERSION_MAJOR=0
VERSION_MINOR=16
VERSION_CURRENT=11
VERSION_REVISION=0
VERSION_AGE=10
PREFIX=/usr/local
LIBDIR=$(PREFIX)/lib
INCDIR=$(PREFIX)/include
MANDIR=$(PREFIX)/share/man
MAN3DIR=$(MANDIR)/man3
MAN7DIR=$(MANDIR)/man7
all: $(LIBRARY) $(DEMOS)
%.lo: %.c termkey.h termkey-internal.h
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $<
$(LIBRARY): $(OBJECTS)
$(LIBTOOL) --mode=link --tag=CC $(CC) -rpath $(LIBDIR) -version-info $(VERSION_CURRENT):$(VERSION_REVISION):$(VERSION_AGE) $(LDFLAGS) -o $@ $^
demo: $(LIBRARY) demo.lo
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
demo-async: $(LIBRARY) demo-async.lo
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
demo-glib.lo: demo-glib.c termkey.h
$(LIBTOOL) --mode=compile --tag=CC $(CC) -o $@ -c $< $(shell pkg-config glib-2.0 --cflags)
demo-glib: $(LIBRARY) demo-glib.lo
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^ $(shell pkg-config glib-2.0 --libs)
t/%.t: t/%.c $(LIBRARY) t/taplib.lo
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
t/taplib.lo: t/taplib.c
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $^
.PHONY: test
test: $(TESTFILES)
prove -e ""
.PHONY: clean-test
clean-test:
$(LIBTOOL) --mode=clean rm -f $(TESTFILES) t/taplib.lo
.PHONY: clean
clean: clean-test
$(LIBTOOL) --mode=clean rm -f $(OBJECTS) $(DEMO_OBJECTS)
$(LIBTOOL) --mode=clean rm -f $(LIBRARY)
$(LIBTOOL) --mode=clean rm -rf $(DEMOS)
.PHONY: install
install: install-inc install-lib install-man
$(LIBTOOL) --mode=finish $(DESTDIR)$(LIBDIR)
install-inc: termkey.h
install -d $(DESTDIR)$(INCDIR)
install -m644 termkey.h $(DESTDIR)$(INCDIR)
install -d $(DESTDIR)$(LIBDIR)/pkgconfig
sed "s,@LIBDIR@,$(LIBDIR),;s,@INCDIR@,$(INCDIR)," <termkey.pc.in >$(DESTDIR)$(LIBDIR)/pkgconfig/termkey.pc
install-lib: $(LIBRARY)
install -d $(DESTDIR)$(LIBDIR)
$(LIBTOOL) --mode=install install libtermkey.la $(DESTDIR)$(LIBDIR)/libtermkey.la
install-man:
install -d $(DESTDIR)$(MAN3DIR)
install -d $(DESTDIR)$(MAN7DIR)
for F in man/*.3; do \
gzip <$$F >$(DESTDIR)$(MAN3DIR)/$${F#man/}.gz; \
done
for F in man/*.7; do \
gzip <$$F >$(DESTDIR)$(MAN7DIR)/$${F#man/}.gz; \
done
while read FROM EQ TO; do \
echo ln -sf $$TO.gz $(DESTDIR)$(MAN3DIR)/$$FROM.gz; \
done < man/also
# DIST CUT
MANSOURCE=$(wildcard man/*.3.sh)
BUILTMAN=$(MANSOURCE:.3.sh=.3)
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
all: doc
doc: $(BUILTMAN)
%.3: %.3.sh
sh $< >$@
clean: clean-built
clean-built:
rm -f $(BUILTMAN) termkey.h
termkey.h: termkey.h.in Makefile
rm -f $@
sed -e 's/@@VERSION_MAJOR@@/$(VERSION_MAJOR)/g' \
-e 's/@@VERSION_MINOR@@/$(VERSION_MINOR)/g' \
$< >$@
chmod a-w $@
DISTDIR=libtermkey-$(VERSION)
distdir: all
mkdir __distdir
cp *.c *.h LICENSE __distdir
mkdir __distdir/t
cp t/*.c t/*.h __distdir/t
mkdir __distdir/man
cp man/*.[37] man/also __distdir/man
sed "s,@VERSION@,$(VERSION)," <termkey.pc.in >__distdir/termkey.pc.in
sed "/^# DIST CUT/Q" <Makefile >__distdir/Makefile
mv __distdir $(DISTDIR)
TARBALL=$(DISTDIR).tar.gz
dist: distdir
tar -czf $(TARBALL) $(DISTDIR)
rm -rf $(DISTDIR)
HTMLDIR=html
htmldocs: $(BUILTMAN)
perl $(HOME)/src/perl/Parse-Man/examples/man-to-html.pl -O $(HTMLDIR) --file-extension tmpl --link-extension html --template home_lou.tt2 --also man/also man/*.3 man/*.7 --index index.tmpl
|