-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
154 lines (118 loc) · 4.23 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
ifeq ($(shell uname),Darwin)
LIBTOOL ?= glibtool
else
LIBTOOL ?= libtool
endif
ifneq ($(VERBOSE),1)
LIBTOOL +=--quiet
endif
override CFLAGS +=-Wall -Iinclude -Isrc -std=c99
ifeq ($(DEBUG),1)
override CFLAGS +=-ggdb -DDEBUG
endif
ifeq ($(PROFILE),1)
override CFLAGS +=-pg
override LDFLAGS+=-pg
endif
ifeq ($(shell pkg-config --atleast-version=1.1.0 unibilium && echo 1),1)
override CFLAGS +=$(shell pkg-config --cflags unibilium) -DHAVE_UNIBILIUM
override LDFLAGS+=$(shell pkg-config --libs unibilium)
else ifeq ($(shell pkg-config ncursesw && echo 1),1)
override CFLAGS +=$(shell pkg-config --cflags ncursesw)
override LDFLAGS+=$(shell pkg-config --libs ncursesw)
else
override LDFLAGS+=-lncurses
endif
override CFLAGS +=$(shell pkg-config --cflags termkey)
override LDFLAGS+=$(shell pkg-config --libs termkey)
CFILES=$(sort $(wildcard src/*.c))
HFILES=$(sort $(wildcard include/*.h))
OBJECTS=$(CFILES:.c=.lo)
LIBRARY=libtickit.la
HFILES_INT=$(sort $(wildcard src/*.h)) $(HFILES)
TESTSOURCES=$(sort $(wildcard t/[0-9]*.c))
TESTFILES=$(TESTSOURCES:.c=.t)
EXAMPLESOURCES=$(sort $(wildcard examples/*.c))
VERSION_CURRENT=3
VERSION_REVISION=0
VERSION_AGE=0
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
LIBDIR=$(PREFIX)/lib
INCDIR=$(PREFIX)/include
MANDIR=$(PREFIX)/share/man
MAN3DIR=$(MANDIR)/man3
MAN7DIR=$(MANDIR)/man7
all: $(LIBRARY)
$(LIBRARY): $(OBJECTS)
$(LIBTOOL) --mode=link --tag=CC $(CC) -rpath $(LIBDIR) -version-info $(VERSION_CURRENT):$(VERSION_REVISION):$(VERSION_AGE) -o $@ $^ $(LDFLAGS)
src/%.lo: src/%.c $(HFILES_INT)
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $<
src/term.lo: src/xterm-palette.inc
src/xterm-palette.inc: src/xterm-palette.inc.PL
perl $^ > $@
src/renderbuffer.lo: src/linechars.inc
src/linechars.inc: src/linechars.inc.PL
perl $^ > $@
src/utf8.lo: src/fullwidth.inc
src/fullwidth.inc: src/fullwidth.inc.PL
perl $^ > $@
t/%.t: t/%.lo $(LIBRARY) t/taplib.lo t/mockterm.lo t/taplib-tickit.lo
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^ $(LDFLAGS)
t/%.lo: t/%.c
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $^
.PHONY: test
test: $(TESTFILES)
$(LIBTOOL) --mode=execute prove -e ""
.PHONY: clean-test
clean-test:
$(LIBTOOL) --mode=clean rm -f $(TESTFILES) t/taplib.lo t/mockterm.lo
.PHONY: clean
clean: clean-test
$(LIBTOOL) --mode=clean rm -f $(OBJECTS)
$(LIBTOOL) --mode=clean rm -f $(LIBRARY)
ifneq ($(shell pkg-config glib-2.0 && echo 1),1)
EXAMPLESOURCES:=$(filter-out examples/evloop-glib.c, $(EXAMPLESOURCES))
endif
examples/evloop-glib.lo: CFLAGS +=$(shell pkg-config --cflags glib-2.0)
examples/evloop-glib: LDFLAGS+=$(shell pkg-config --libs glib-2.0)
ifneq ($(shell pkg-config libuv && echo 1),1)
EXAMPLESOURCES:=$(filter-out examples/evloop-libuv.c, $(EXAMPLESOURCES))
endif
examples/evloop-libuv.lo: CFLAGS +=$(shell pkg-config --cflags libuv)
examples/evloop-libuv: LDFLAGS+=$(shell pkg-config --libs libuv)
.PHONY: examples
examples: $(EXAMPLESOURCES:.c=)
examples/%.lo: examples/%.c $(HFILES)
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $<
examples/%: examples/%.lo $(LIBRARY)
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^ $(LDFLAGS)
.PHONY: install
install: install-inc install-lib install-man
$(LIBTOOL) --mode=finish $(DESTDIR)$(LIBDIR)
install-inc: $(HFILES)
install -d $(DESTDIR)$(INCDIR)
install -m644 $(HFILES) $(DESTDIR)$(INCDIR)
install -d $(DESTDIR)$(LIBDIR)/pkgconfig
LIBDIR=$(LIBDIR) INCDIR=$(INCDIR) sh tickit.pc.sh >$(DESTDIR)$(LIBDIR)/pkgconfig/tickit.pc
# rm the old binary first in case it's still in use
install-lib: $(LIBRARY)
install -d $(DESTDIR)$(LIBDIR)
$(LIBTOOL) --mode=install install $(LIBRARY) $(DESTDIR)$(LIBDIR)/
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 \
if [ -n "$$FROM" ]; then \
ln -sf $$TO.gz $(DESTDIR)$(MAN3DIR)/$$FROM.gz; \
fi; \
done < man/also
HTMLDIR=html
htmldocs:
perl $(HOME)/src/perl/Parse-Man/examples/man-to-html.pl -O $(HTMLDIR) --file-extension html --link-extension html --template home_lou.tt2 --also man/also man/*.3 man/*.7 --index html/index.html