aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 866caf0e538f7d8a52eaccbb9239099f43640709 (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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

SO_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)

OBJ =\
	float.o\
	double.o\
	long-double.o

HDR =\
	libcolour.h\
	common.h\
	conversions.h\
	conversion-matrices.h

TEMPLATES =\
	en_masse-template.c\
	libcolour-template.c

MAN7 =\
	libcolour.7\
	LIBCOLOUR_RGB.7\
	LIBCOLOUR_SRGB.7\
	LIBCOLOUR_CIEXYY.7\
	LIBCOLOUR_CIEXYZ.7\
	LIBCOLOUR_CIELAB.7\
	LIBCOLOUR_CIELUV.7\
	LIBCOLOUR_CIELCHUV.7\
	LIBCOLOUR_YIQ.7\
	LIBCOLOUR_YDBDR.7\
	LIBCOLOUR_YUV.7\
	LIBCOLOUR_YPBPR.7\
	LIBCOLOUR_YCGCO.7\
	LIBCOLOUR_CIE1960UCS.7\
	LIBCOLOUR_CIEUVW.7\
	LIBCOLOUR_YES.7

MAN3 =\
	libcolour_convert.3\
	libcolour_srgb_encode.3\
	libcolour_srgb_decode.3\
	libcolour_delta_e.3\
	libcolour_proper.3\
	libcolour_get_rgb_colour_space.3\
	libcolour_marshal.3\
	libcolour_unmarshal.3\
	libcolour_convert_en_masse.3

MAN3_SYMLINKS =\
	libcolour_convert_f.3\
	libcolour_convert_lf.3\
	libcolour_convert_llf.3\
	libcolour_srgb_encode_f.3\
	libcolour_srgb_encode_lf.3\
	libcolour_srgb_encode_llf.3\
	libcolour_srgb_decode_f.3\
	libcolour_srgb_decode_lf.3\
	libcolour_srgb_decode_llf.3\
	libcolour_delta_e_f.3\
	libcolour_delta_e_lf.3\
	libcolour_delta_e_llf.3\
	libcolour_proper_f.3\
	libcolour_proper_lf.3\
	libcolour_proper_llf.3\
	libcolour_get_rgb_colour_space_f.3\
	libcolour_get_rgb_colour_space_lf.3\
	libcolour_get_rgb_colour_space_llf.3\
	libcolour_marshal_f.3\
	libcolour_marshal_lf.3\
	libcolour_marshal_llf.3\
	libcolour_unmarshal_f.3\
	libcolour_unmarshal_lf.3\
	libcolour_unmarshal_llf.3\
	libcolour_convert_en_masse_f.3\
	libcolour_convert_en_masse_lf.3\
	libcolour_convert_en_masse_llf.3


all: libcolour.a libcolour.so.$(SO_VERSION) test


conversion-matrices.h: matrices.py
	printf '/* This file is generated! */\n' > conversion-matrices.h
	./matrices.py >> conversion-matrices.h


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: libcolour.a libcolour.so.$(SO_VERSION)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	cp -- libcolour.h "$(DESTDIR)$(PREFIX)/include/libcolour.h"
	chmod -- 644 "$(DESTDIR)$(PREFIX)/include/libcolour.h"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	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"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
	cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7/"
	cd -- "$(DESTDIR)$(MANPREFIX)/man7" && chmod -- 644 $(MAN7)
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
	cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3/"
	cd -- "$(DESTDIR)$(MANPREFIX)/man3" && chmod -- 644 $(MAN3)
	ln -sf -- libcolour_convert.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_convert_f.3"
	ln -sf -- libcolour_convert.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_convert_lf.3"
	ln -sf -- libcolour_convert.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_convert_llf.3"
	ln -sf -- libcolour_srgb_encode.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_srgb_encode_f.3"
	ln -sf -- libcolour_srgb_encode.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_srgb_encode_lf.3"
	ln -sf -- libcolour_srgb_encode.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_srgb_encode_llf.3"
	ln -sf -- libcolour_srgb_decode.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_srgb_decode_f.3"
	ln -sf -- libcolour_srgb_decode.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_srgb_decode_lf.3"
	ln -sf -- libcolour_srgb_decode.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_srgb_decode_llf.3"
	ln -sf -- libcolour_delta_e.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_delta_e_f.3"
	ln -sf -- libcolour_delta_e.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_delta_e_lf.3"
	ln -sf -- libcolour_delta_e.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_delta_e_llf.3"
	ln -sf -- libcolour_proper.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_proper_f.3"
	ln -sf -- libcolour_proper.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_proper_lf.3"
	ln -sf -- libcolour_proper.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_proper_llf.3"
	ln -sf -- libcolour_get_rgb_colour_space.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_get_rgb_colour_space_f.3"
	ln -sf -- libcolour_get_rgb_colour_space.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_get_rgb_colour_space_lf.3"
	ln -sf -- libcolour_get_rgb_colour_space.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_get_rgb_colour_space_llf.3"
	ln -sf -- libcolour_marshal.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_marshal_f.3"
	ln -sf -- libcolour_marshal.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_marshal_lf.3"
	ln -sf -- libcolour_marshal.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_marshal_llf.3"
	ln -sf -- libcolour_unmarshal.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_unmarshal_f.3"
	ln -sf -- libcolour_unmarshal.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_unmarshal_lf.3"
	ln -sf -- libcolour_unmarshal.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_unmarshal_llf.3"
	ln -sf -- libcolour_convert_en_masse.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_convert_en_masse_f.3"
	ln -sf -- libcolour_convert_en_masse.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_convert_en_masse_lf.3"
	ln -sf -- libcolour_convert_en_masse.3 "$(DESTDIR)$(MANPREFIX)/man3/libcolour_convert_en_masse_llf.3"


uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libcolour.h"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcolour.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(SO_VERSION)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcolour.so.$(VERSION_MAJOR)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcolour.so"
	-cd -- "$(DESTDIR)$(MANPREFIX)/man7" && rm -f -- $(MAN7)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man3" && rm -f -- $(MAN3) $(MAN3_SYMLINKS)


check: test
	./test

clean:
	-rm -f -- *.o *.a *.so *.so.* test conversion-matrices.h
	-rm -rf -- __pycache__/

.PHONY: all clean check install uninstall