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
|
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
PREFIX ?= /usr
BIN ?= /bin
LIB ?= /lib
DATA ?= /share
BINDIR ?= $(PREFIX)$(BIN)
LIBDIR ?= $(PREFIX)$(LIB)
DATADIR ?= $(PREFIX)$(DATA)
DOCDIR ?= $(DATADIR)/doc
LICENSEDIR ?= $(DATADIR)/licenses
INFODIR ?= $(INFODIR)/info
SHEBANG ?= /usr/bin/python3
COMMAND ?= blueshift
PKGNAME ?= blueshift
PKGCONFIG ?= pkg-config
OPTIMISE ?= -Og -g
WARN = -Wall -Wextra -pedantic
LIBS = xcb-randr python3
STD = c99
FLAGS = $$($(PKGCONFIG) --cflags --libs $(LIBS)) -std=$(STD) $(WARN) $(OPTIMISE) -fPIC
DATAFILES = 2deg 10deg redshift redshift_old
PYFILES = __main__.py colour.py curve.py monitor.py solar.py
EXAMPLES = comprehensive
.PHONY: default
default: command info
.PHONY: all
all: command doc
.PHONY: doc
doc: info pdf dvi ps
.PHONY: info
info: blueshift.info
.PHONY: pdf
pdf: blueshift.pdf
.PHONY: dvi
dvi: blueshift.dvi
.PHONY: ps
ps: blueshift.ps
.PHONY: command
command: bin/blueshift_randr.so bin/blueshift
bin/blueshift: obj/blueshift.zip
echo '#!/usr/bin/python3' > $@
cat $< >> $@
chmod a+x $@
obj/blueshift.zip: $(foreach F,$(PYFILES),obj/$(F))
@mkdir -p bin
cd obj && zip ../$@ $(foreach F,$(PYFILES),$(F))
obj/%.py: src/%.py
cp $< $@
sed -i '/^DATADIR *= /s#^.*$$#DATADIR = '\''$(DATADIR)/$(PKGNAME)'\''#' $@
sed -i '/^LIBDIR *= /s#^.*$$#LIBDIR = '\''$(LIBDIR)'\''#' $@
bin/blueshift_randr.so: obj/blueshift_randr.o obj/blueshift_randr_c.o
@mkdir -p bin
$(CC) $(FLAGS) -shared -o $@ $^
obj/%.o: src/%.c
@mkdir -p obj
$(CC) $(FLAGS) -c -o $@ $<
obj/%.o: obj/%.c
@mkdir -p obj
$(CC) $(FLAGS) -c -o $@ $<
obj/blueshift_randr.c: src/blueshift_randr.pyx
@mkdir -p obj
if ! cython -3 -v $<; then src/blueshift_randr.c ; false ; fi
mv src/blueshift_randr.c $@
%.info: info/%.texinfo
makeinfo "$<"
%.pdf: info/%.texinfo
@mkdir -p obj
cd obj ; yes X | texi2pdf ../$<
mv obj/$@ $@
%.dvi: info/%.texinfo
@mkdir -p obj
cd obj ; yes X | $(TEXI2DVI) ../$<
mv obj/$@ $@
%.ps: info/%.texinfo
@mkdir -p obj
cd obj ; yes X | texi2pdf --ps ../$<
mv obj/$@ $@
.PHONY: install
install: install-base install-info install-examples
.PHONY: install
install: install-base install-doc
.PHONY: install-base
install-base: install-command install-license
.PHONY: install-command
install-command: bin/blueshift_randr.so bin/blueshift $(foreach D,$(DATAFILES),res/$(D))
install -dm755 -- "$(DESTDIR)$(BINDIR)"
install -m755 bin/blueshift -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"
install -dm755 -- "$(DESTDIR)$(LIBDIR)"
install -m755 bin/blueshift_randr.so -- "$(DESTDIR)$(LIBDIR)/blueshift_randr.so"
install -dm755 -- "$(DESTDIR)$(DATADIR)/$(PKGNAME)"
install -m644 -- $(foreach D,$(DATAFILES),res/$(D)) "$(DESTDIR)$(DATADIR)/$(PKGNAME)"
.PHONY: install-license
install-license:
install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
install -m644 COPYING LICENSE -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
.PHONY: install-doc
install-doc: install-info install-examples
.PHONY: install-examples
install-examples: $(foreach E,$(EXAMPLES),examples/$(E))
install -dm755 -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples"
install -m644 $^ -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples"
.PHONY: install-info
install-info: blueshift.info
install -dm755 -- "$(DESTDIR)$(INFODIR)"
install -m644 $< -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
.PHONY: uninstall
uninstall:
-rm --"$(DESTDIR)$(BINDIR)/$(COMMAND)"
-rm --"$(DESTDIR)$(LIBDIR)/blueshift_randr.so"
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
-rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-rm -- $(foreach F,$(DATAFILES),"$(DESTDIR)$(DATADIR)/$(PKGNAME)/$(F)")
-rmdir -- "$(DESTDIR)$(DATADIR)/$(PKGNAME)"
-rm -- $(foreach E,$(EXAMPLES),"$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples/$(E)")
-rmdir -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME)/examples"
-rm -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
.PHONY: all
clean:
-rm -r bin obj src/blueshift_randr.c
|