-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (52 loc) · 1.76 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
CC=gcc
CFLAGS=-pedantic -Wall -O2 -s -Iinclude -fPIC
DESTDIR=
PREFIX=usr/local
PKGCONFIG=$(DESTDIR)/$(PREFIX)/lib/pkgconfig
.PHONY: all clean demos
OBJS=src/common.o src/buffer.o src/draw.o src/unix.o src/unix_input.o src/unix_hints.o
all: library
library: static-library dynamic-library
static-library: lib/libhexes.a
dynamic-library: lib/libhexes.so.0 lib/libhexes.so
# (Un)install.
install: library include/hexes.h
mkdir -p $(DESTDIR)/$(PREFIX)/include
mkdir -p $(DESTDIR)/$(PREFIX)/lib
mkdir -p $(PKGCONFIG)
cp -P lib/libhexes.a lib/libhexes.so* $(DESTDIR)/$(PREFIX)/lib
cp include/hexes.h $(DESTDIR)/$(PREFIX)/include
@echo "prefix=/$(PREFIX)" > $(PKGCONFIG)/hexes.pc
@echo 'exec_prefix=$${prefix}' >> $(PKGCONFIG)/hexes.pc
@echo 'libdir=$${exec_prefix}/lib' >> $(PKGCONFIG)/hexes.pc
@echo 'includedir=$${prefix}/include' >> $(PKGCONFIG)/hexes.pc
@echo '' >> $(PKGCONFIG)/hexes.pc
@echo 'Name: hexes' >> $(PKGCONFIG)/hexes.pc
@echo 'Version:' $$(cat VERSION) >> $(PKGCONFIG)/hexes.pc
@echo 'Description: A low-level terminal control library, including optimization.' >> $(PKGCONFIG)/hexes.pc
@echo '' >> $(PKGCONFIG)/hexes.pc
@echo 'Libs: -L$${libdir} -lhexes' >> $(PKGCONFIG)/hexes.pc
@echo 'Cflags: -I$${includedir}' >> $(PKGCONFIG)/hexes.pc
uninstall:
rm -f $(DESTDIR)/$(PREFIX)/lib/libhexes.a
rm -f $(DESTDIR)/$(PREFIX)/lib/libhexes.so*
rm -f $(DESTDIR)/$(PREFIX)/include/hexes.h
rm -f $(PKGCONFIG)/hexes.pc
# Libraries
lib/libhexes.a: $(OBJS)
@mkdir -p $(@D)
ar cr $@ $(OBJS)
lib/libhexes.so: lib/libhexes.so.0
ln -s libhexes.so.0 $@
lib/libhexes.so.0: $(OBJS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -shared -o $@ $(OBJS)
# Demos
demos:
$(MAKE) -C demos
# Common
.c.o: include/hexes.h
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf lib/ $(OBJS)
$(MAKE) -C demos clean