-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.in
83 lines (68 loc) · 1.9 KB
/
Makefile.in
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
src = $(wildcard src/*.c)
hdr = src/track.h src/anim.h src/config.h
obj = $(src:.c=.o)
dep = $(obj:.o=.d)
lib_a = lib$(name).a
abi = 1
rev = 0
sys := $(shell uname -s | sed 's/MINGW.*/mingw/')
ifeq ($(sys), Darwin)
lib_so = lib$(name).dylib
shared = -dynamiclib
sodir = lib
else ifeq ($(sys), mingw)
lib_so = lib$(name).dll
shared = -shared
sodir = bin
else
soname = lib$(name).so.$(abi)
lib_so = lib$(name).so.$(abi).$(rev)
ldname = lib$(name).so
shared = -shared -Wl,-soname,$(soname)
pic = -fPIC
sodir = lib
endif
CFLAGS = -pedantic -Wall $(opt) $(dbg) $(pic)
LDFLAGS = -lm $(pthr)
.PHONY: all
all: $(lib_a) $(lib_so) $(soname) $(ldname)
$(lib_a): $(obj)
$(AR) rcs $@ $(obj)
$(lib_so): $(obj)
$(CC) $(shared) -o $@ $(obj) $(LDFLAGS)
$(soname): $(lib_so)
rm -f $@
ln -s $< $@
$(ldname): $(soname)
rm -f $@
ln -s $< $@
-include $(dep)
%.d: %.c
@echo "generating depfile $< -> $@"
@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
.PHONY: install
install: $(lib_a) $(lib_so)
mkdir -p $(DESTDIR)$(PREFIX)/lib
mkdir -p $(DESTDIR)$(PREFIX)/$(sodir)
mkdir -p $(DESTDIR)$(PREFIX)/include/$(name)
cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
cp $(lib_so) $(DESTDIR)$(PREFIX)/$(sodir)/$(lib_so)
[ -n "$(ldname)" ] && \
cd $(DESTDIR)$(PREFIX)/$(sodir) && rm -f $(soname) $(ldname) && \
ln -s $(lib_so) $(soname) && \
ln -s $(soname) $(ldname) || true
cp $(hdr) $(DESTDIR)$(PREFIX)/include/$(name)/
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(lib_so)
[ -n "$(ldname)" ] && \
rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(soname) && \
rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(ldname) || true
rm -f $(DESTDIR)$(PREFIX)/include/$(name)/track.h
rm -f $(DESTDIR)$(PREFIX)/include/$(name)/anim.h
rm -f $(DESTDIR)$(PREFIX)/include/$(name)/config.h
rmdir $(DESTDIR)$(PREFIX)/include/$(name)
.PHONY: clean
clean:
rm -f $(obj) $(lib_so) $(lib_a) $(soname) $(ldname)