blob: bde589b86912e0f02433f8219dee3b8b602b7c02 (
plain) (
blame)
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
|
.POSIX:
CONFIGFILE = config.mk
include $(CONFIGFILE)
SO_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
OBJ =\
float.o\
double.o\
long-double.o
HDR =\
libcolour.h
TEMPLATES =\
convert-template.c\
libcolour-template.c
all: libcolour.a libcolour.so.$(SO_VERSION) test
float.o: float.c $(TEMPLATES) $(HDR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ float.c
double.o: double.c $(TEMPLATES) $(HDR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ double.c
long-double.o: long-double.c $(TEMPLATES) $(HDR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ long-double.c
float.pic.o: float.c $(TEMPLATES) $(HDR)
$(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ float.c
double.pic.o: double.c $(TEMPLATES) $(HDR)
$(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ double.c
long-double.pic.o: long-double.c $(TEMPLATES) $(HDR)
$(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ long-double.c
libcolour.a: $(OBJ)
$(AR) rc $@ $?
$(AR) -s $@
libcolour.so.$(SO_VERSION): $(OBJ:.o=.pic.o)
$(CC) -shared -Wl,-soname,libcolour.so.$(VERSION_MAJOR) -o $@ $(LDFLAGS) $^
test.o: test.c libcolour.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ test.c
test: test.o libcolour.a
$(CC) -o $@ $^ $(LDFLAGS)
install:
mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
cp -- libcolour.h "$(DESTDIR)$(PREFIX)/include/libcolour.h"
chmod -- 644 "$(DESTDIR)$(PREFIX)/include/libcolour.h"
cp -- libcolour.a "$(DESTDIR)$(PREFIX)/lib/libcolour.a"
chmod -- 644 "$(DESTDIR)$(PREFIX)/lib/libcolour.a"
cp -- libcolour.so.$(SO_VERSION) "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(SO_VERSION)"
chmod -- 755 "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(SO_VERSION)"
ln -sf -- libcolour.so.$(SO_VERSION) "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(VERSION_MAJOR)"
ln -sf -- libcolour.so.$(SO_VERSION) "$(DESTDIR)$(PREFIX)/lib/libcolour.so"
uninstall:
-rm -- "$(DESTDIR)$(PREFIX)/include/libcolour.h"
-rm -- "$(DESTDIR)$(PREFIX)/lib/libcolour.a"
-rm -- "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(SO_VERSION)"
-rm -- "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(VERSION_MAJOR)"
-rm -- "$(DESTDIR)$(PREFIX)/lib/libcolour.so"
check: test
./test
clean:
-rm -- *.o *.a *.so *.so.* test
.PHONY: all clean check install uninstall
|