aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: c605f13b6baee35cffd789ed96fbc0e0fa7c138b (plain)
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
.PHONY: all clean test \
	check \
	static \
	go_files \
	lcov.info

GUILE := guile
export GUILE

GUILD := guild

GUILE_VERSION=$(shell $(GUILE) -c '(display (version))')

GUILE_SITE_DIR=$(shell $(GUILE) -c "(display (%site-dir))")
GUILE_CCACHE_DIR=$(shell $(GUILE) -c "(display (%site-ccache-dir))")

scm_files = \
	base64 \
	c/ast \
	c/compiler \
	c/cpp-environment \
	c/cpp-types \
	c/cpp-util \
	c/eval-basic \
	c/eval2 \
	c/flatten-begin \
	c/lex2 \
	c/line-fold \
	c/old/cpp \
	c/old/lex \
	c/old/operators \
	c/old/parse \
	c/parse2 \
	c/preprocessor2 \
	c/to-token \
	c/trigraph \
	c/unlex \
	calp \
	calp/benchmark/parse \
	calp/config-base \
	calp/entry-points/benchmark \
	calp/entry-points/convert \
	calp/entry-points/html \
	calp/entry-points/ical \
	calp/entry-points/import \
	calp/entry-points/server \
	calp/entry-points/terminal \
	calp/entry-points/text \
	calp/entry-points/tidsrapport \
	calp/entry-points/update-zoneinfo \
	calp/html/caltable \
	calp/html/components \
	calp/html/config \
	calp/html/filter \
	calp/html/util \
	calp/html/vcomponent \
	calp/html/view/calendar \
	calp/html/view/calendar/month \
	calp/html/view/calendar/shared \
	calp/html/view/calendar/week \
	calp/html/view/search \
	calp/html/view/small-calendar \
	calp/main \
	calp/repl \
	calp/server/routes \
	calp/server/server \
	calp/terminal \
	calp/translation \
	calp/util/config \
	calp/util/exceptions \
	calp/util/hooks \
	calp/util/time \
	crypto \
	datetime \
	datetime/instance \
	datetime/timespec \
	datetime/zic \
	glob \
	hnh/util \
	hnh/util/env \
	hnh/util/exceptions \
	hnh/util/graph \
	hnh/util/io \
	hnh/util/language \
	hnh/util/lens \
	hnh/util/object \
	hnh/util/options \
	hnh/util/path \
	hnh/util/tree \
	hnh/util/type \
	hnh/util/uuid \
	hnh/util/values \
	srfi/srfi-41/util \
	srfi/srfi-64/test-error \
	srfi/srfi-64/util \
	sxml/html \
	sxml/namespace \
	sxml/transformations \
	text/flow \
	text/markup \
	text/numbers \
	text/numbers/en \
	text/numbers/sv \
	text/util \
	vcomponent \
	vcomponent/base \
	vcomponent/config \
	vcomponent/control \
	vcomponent/datetime \
	vcomponent/datetime/output \
	vcomponent/duration \
	vcomponent/formats/common/types \
	vcomponent/formats/ical/output \
	vcomponent/formats/ical/parse \
	vcomponent/formats/ical/types \
	vcomponent/formats/vdir/parse \
	vcomponent/formats/vdir/save-delete \
	vcomponent/formats/xcal/output \
	vcomponent/formats/xcal/parse \
	vcomponent/formats/xcal/types \
	vcomponent/geo \
	vcomponent/recurrence \
	vcomponent/recurrence/display \
	vcomponent/recurrence/display/common \
	vcomponent/recurrence/display/en \
	vcomponent/recurrence/display/sv \
	vcomponent/recurrence/generate \
	vcomponent/recurrence/internal \
	vcomponent/recurrence/parse \
	vcomponent/util/control \
	vcomponent/util/describe \
	vcomponent/util/group \
	vcomponent/util/instance \
	vcomponent/util/instance/methods \
	vcomponent/util/parse-cal-path \
	vcomponent/util/search \
	vulgar \
	vulgar/color \
	vulgar/components \
	vulgar/info \
	vulgar/termios \
	web/http/make-routes \
	web/query \
	web/uri-query \
	xdg/basedir


SCM_FILES = $(scm_files:%=module/%.scm)

GO_FILES = $(SCM_FILES:module/%.scm=obj-$(GUILE_VERSION)/%.go)

GUILE_ENV = GUILE_LOAD_PATH=$(PWD)/module \
			GUILE_LOAD_COMPILED_PATH=$(PWD)/obj-$(GUILE_VERSION)

GUILE_C_FLAGS = -Lmodule \
				-Wshadowed-toplevel -Wunbound-variable \
				-Wmacro-use-before-definition -Warity-mismatch \
				-Wduplicate-case-datum -Wbad-case-datum

# All po-files inside po/, except new.po, and hidden files
PO_FILES = $(shell find po -type f -name \*.po -and -not -name new.po -and -not -name .\*)
LOCALIZATIONS = $(PO_FILES:po/%.po=localization/%/LC_MESSAGES/calp.mo)

# Limit test to these files
LIMIT_FILES=$(LIMIT:%=--only %)
# Skip these files when testing
SKIP=--skip $(PWD)/tests/test/web-server.scm

all: go_files README static $(LOCALIZATIONS)
	$(MAKE) -C doc/ref

XGETTEXT_FLAGS = --from-code=UTF-8 --add-comments --indent -k_

static:
	$(MAKE) -C static

obj-$(GUILE_VERSION)/%.go: module/%.scm
	@echo $(GUILD) $(GUILE_VERSION) compile $<
	@env $(GUILE_ENV) $(GUILD) compile $(GUILE_C_FLAGS) -o $@ $< >/dev/null

# Phony target used by test/run-tests.scm and main to
# automatically compile everything before they run.
go_files: $(GO_FILES)

po/%.po: $(SCM_FILES)
	xgettext $(XGETTEXT_FLAGS) --output $@ -L scheme $^ --join-existing --omit-header --no-location

po/new.po: $(SCM_FILES)
	xgettext $(XGETTEXT_FLAGS) --output $@ -L scheme $^

localization/%/LC_MESSAGES/calp.mo: po/%.po
	-@mkdir -p $(shell dirname $@)
	msgfmt --check -o $@ $<

clean:
	-$(MAKE) -C static clean
	-rm -r obj-*

install: all
	install -d $(DESTDIR)$(GUILE_SITE_DIR)  $(DESTDIR)$(GUILE_CCACHE_DIR)
	rsync -a module/ $(DESTDIR)$(GUILE_SITE_DIR)
	rsync -a obj-$(GUILE_VERSION)/ $(DESTDIR)$(GUILE_CCACHE_DIR)
	install -d $(DESTDIR)/usr/share/calp/www
	$(MAKE) -C static install
	$(MAKE) -C system install
	$(MAKE) -C doc/ref install
	install -m 644 -D -t $(DESTDIR)/usr/share/doc/calp README
	install -m 755 -D -t $(DESTDIR)/usr/lib/calp/ scripts/tzget
	install -m755 -D production-main $(DESTDIR)/usr/bin/calp

README: README.in
	./main text < README.in | sed "s/<<today>>/`date -I`/" > README

lcov.info: $(GO_FILES)
	env DEBUG=0 tests/run-tests.scm --coverage=$@ $(if $(VERBOSE),--verbose) $(SKIP) $(LIMIT_FILES)

test: coverage

GENHTML_FLAGS=--show-details \
			  --prefix $(shell pwd)/module \
			  --no-function-coverage \
			  --quiet

coverage: lcov.info
	genhtml $(GENHTML_FLAGS) --output-directory $@ $<

check:
	tests/run-tests.scm $(if $(VERBOSE),--verbose) $(SKIP) $(LIMIT_FILES)