Debian Codegraph @

Makefile

raw ◀ ▶
2 Debian patches touch this file
1 LUA ?= lua
2 LUA_VERSION ?= $(shell $(LUA) -e 'v=_VERSION:gsub("^Lua *","");print(v)')
3 DESTDIR ?=
4 PREFIX ?= /usr/local
5 BIN_DIR ?= $(PREFIX)/bin
6 LUA_LIB_DIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)
7 MAN_DIR ?= $(PREFIX)/share
8
9 MAKEFLAGS += --no-print-directory
10
11 CORE_SRC=src/fennel.fnl src/fennel/parser.fnl src/fennel/specials.fnl \
12 src/fennel/utils.fnl src/fennel/compiler.fnl src/fennel/macros.fnl \
13 src/fennel/match.fnl
14
15 LIB_SRC=$(CORE_SRC) src/fennel/friend.fnl src/fennel/view.fnl src/fennel/repl.fnl
16
17 SRC=$(LIB_SRC) src/launcher.fnl src/fennel/binary.fnl
18
19 PRECOMPILED=bootstrap/view.lua bootstrap/macros.lua bootstrap/match.lua
20
21 MAN_PANDOC = pandoc -f gfm -t man -s --lua-filter=build/manfilter.lua \
22 --metadata author="Fennel Maintainers" \
23 --variable footer="fennel $(shell ./fennel -e '(. (require :fennel) :version)')"
24
25 unexport NO_COLOR # this causes test failures
26 unexport FENNEL_PATH FENNEL_MACRO_PATH # ensure isolation
27
28 build: fennel fennel.lua
29
30 test: fennel.lua fennel test/faith.lua
31 @LUA_PATH=?.lua $(LUA) test/init.lua $(TESTS)
32 @echo
33
34 testall: export FNL_TESTALL=yes
35 testall: fennel test/faith.lua # recursive make considered not really a big deal
36 $(MAKE) test LUA=lua5.1
37 $(MAKE) test LUA=lua5.2
38 $(MAKE) test LUA=lua5.3
39 $(MAKE) test LUA=lua5.4
40 $(MAKE) test LUA=luajit
41
42 fuzz: fennel ; $(MAKE) test TESTS=test.fuzz
43
44 count: ; cloc $(CORE_SRC); cloc $(LIB_SRC) ; cloc $(SRC)
45
46 # install https://git.sr.ht/~technomancy/fnlfmt manually for this:
47 format: ; for f in $(SRC); do fnlfmt --fix $$f ; done
48
49 # All-in-one pure-lua script:
50 fennel: src/launcher.fnl $(SRC) bootstrap/aot.lua $(PRECOMPILED)
51 @echo "#!/usr/bin/env $(LUA)" > $@
52 @echo "-- SPDX-License-Identifier: MIT" >> $@
53 @echo "-- SPDX-FileCopyrightText: Calvin Rose and contributors" >> $@
54 FENNEL_PATH=src/?.fnl $(LUA) bootstrap/aot.lua $< --require-as-include >> $@
55 @chmod 755 $@
56
57 # Library file
58 fennel.lua: $(SRC) bootstrap/aot.lua $(PRECOMPILED)
59 @echo "-- SPDX-License-Identifier: MIT" > $@
60 @echo "-- SPDX-FileCopyrightText: Calvin Rose and contributors" >> $@
61 FENNEL_PATH=src/?.fnl $(LUA) bootstrap/aot.lua $< --require-as-include >> $@
62
63 bootstrap/macros.lua: src/fennel/macros.fnl; $(LUA) bootstrap/aot.lua $< --macro > $@
64 bootstrap/match.lua: src/fennel/match.fnl; $(LUA) bootstrap/aot.lua $< --macro > $@
65 bootstrap/view.lua: src/fennel/view.fnl
66 FENNEL_PATH=src/?.fnl $(LUA) bootstrap/aot.lua $< > $@
67
68 test/faith.lua: test/faith.fnl
69 $(LUA) bootstrap/aot.lua $< > $@
70
71 lint:
72 fennel-ls --lint $(SRC)
73
•74 ci: testall fuzz fennel #fennel-bin
75 # ./fennel-bin --eval '(print "binary works!")'
76
77 clean:
78 rm -f fennel.lua fennel fennel-bin fennel.exe \
79 *_binary.c luacov.* $(PRECOMPILED) \
80 test/faith.lua build/manfilter.lua fennel-bin-luajit
81 $(MAKE) -C $(BIN_LUA_DIR) clean || true # this dir might not exist
82 $(MAKE) -C $(BIN_LUAJIT_DIR) clean || true # this dir might not exist
83 rm -f $(NATIVE_LUA_LIB) $(NATIVE_LUAJIT_LIB)
84
85 coverage: fennel
86 $(LUA) -lluacov test/init.lua
87 @echo "generated luacov.report.out"
88
89 ## Binaries
90
91 BIN_LUA_DIR ?= lua
92 BIN_LUAJIT_DIR ?= luajit
93 NATIVE_LUA_LIB ?= $(BIN_LUA_DIR)/src/liblua.a
94 NATIVE_LUAJIT_LIB ?= $(BIN_LUAJIT_DIR)/src/libluajit.a
95 LUA_INCLUDE_DIR ?= $(BIN_LUA_DIR)/src
96 LUAJIT_INCLUDE_DIR ?= $(BIN_LUAJIT_DIR)/src
97
98 COMPILE_ARGS=FENNEL_PATH=src/?.fnl FENNEL_MACRO_PATH=src/?.fnl CC_OPTS=-static
99 LUAJIT_COMPILE_ARGS=FENNEL_PATH=src/?.fnl FENNEL_MACRO_PATH=src/?.fnl
100
•101 #$(LUA_INCLUDE_DIR): ; git submodule update --init
102 #$(LUAJIT_INCLUDE_DIR): ; git submodule update --init
103
104 # Native binary for whatever platform you're currently on
105 fennel-bin: src/launcher.fnl $(BIN_LUA_DIR)/src/lua $(NATIVE_LUA_LIB) fennel
106 $(COMPILE_ARGS) $(BIN_LUA_DIR)/src/lua fennel \
107 --no-compiler-sandbox --compile-binary \
108 $< $@ $(NATIVE_LUA_LIB) $(LUA_INCLUDE_DIR)
109
110 fennel-bin-luajit: src/launcher.fnl $(NATIVE_LUAJIT_LIB) fennel
111 $(LUAJIT_COMPILE_ARGS) $(BIN_LUAJIT_DIR)/src/luajit fennel \
112 --no-compiler-sandbox --compile-binary \
113 $< $@ $(NATIVE_LUAJIT_LIB) $(LUAJIT_INCLUDE_DIR)
114
115 $(BIN_LUA_DIR)/src/lua: $(LUA_INCLUDE_DIR) ; make -C $(BIN_LUA_DIR)
116 $(NATIVE_LUA_LIB): $(LUA_INCLUDE_DIR) ; $(MAKE) -C $(BIN_LUA_DIR)/src liblua.a
117 $(NATIVE_LUAJIT_LIB): $(LUAJIT_INCLUDE_DIR)
118 $(MAKE) -C $(BIN_LUAJIT_DIR) BUILDMODE=static
119
120 fennel.exe: src/launcher.fnl fennel $(LUA_INCLUDE_DIR)/liblua-mingw.a
121 $(COMPILE_ARGS) ./fennel --no-compiler-sandbox \
122 --compile-binary $< fennel-bin \
123 $(LUA_INCLUDE_DIR)/liblua-mingw.a $(LUA_INCLUDE_DIR)
124 mv fennel-bin.exe $@
125
126 $(BIN_LUA_DIR)/src/liblua-mingw.a: $(LUA_INCLUDE_DIR)
127 $(MAKE) -C $(BIN_LUA_DIR)/src clean mingw CC=x86_64-w64-mingw32-gcc
128 mv $(BIN_LUA_DIR)/src/liblua.a $@
129 $(MAKE) -C $(BIN_LUA_DIR)/src clean
130
131 ## Install-related tasks:
132
133 MAN_DOCS := man/man1/fennel.1 man/man3/fennel-api.3 man/man5/fennel-reference.5\
134 man/man7/fennel-tutorial.7
135
136 # The empty line in maninst is necessary for it to emit distinct commands
137 define maninst =
138 mkdir -p $(dir $(2)) && cp $(1) $(2)
139
140 endef
141
142 install: fennel fennel.lua
143 mkdir -p $(DESTDIR)$(BIN_DIR) && cp fennel $(DESTDIR)$(BIN_DIR)/
144 mkdir -p $(DESTDIR)$(LUA_LIB_DIR) && cp fennel.lua $(DESTDIR)$(LUA_LIB_DIR)/
145 $(foreach doc,$(MAN_DOCS),\
146 $(call maninst,$(doc),$(DESTDIR)$(MAN_DIR)/$(doc)))
147
148 uninstall:
149 rm -f $(DESTDIR)$(BIN_DIR)/fennel
150 rm -f $(DESTDIR)$(LUA_LIB_DIR)/fennel.lua
151 rm -f $(addprefix $(DESTDIR)$(MAN_DIR)/,$(MAN_DOCS))
152
153 build/manfilter.lua: build/manfilter.fnl fennel.lua fennel
154 ./fennel --correlate --compile $< > $@
155
156 man: $(dir $(MAN_DOCS)) $(MAN_DOCS)
157 man/man%/: ; mkdir -p $@
158 man/man3/fennel-%.3: %.md build/manfilter.lua
159 $(MAN_PANDOC) $< -o $@
160 sed -i.tmp 's/\\f\[C\]/\\f[CR]/g' $@ # work around pandoc 2.x bug
161 man/man5/fennel-%.5: %.md build/manfilter.lua
162 $(MAN_PANDOC) $< -o $@
163 sed -i.tmp 's/\\f\[C\]/\\f[CR]/g' $@ # work around pandoc 2.x bug
164 man/man7/fennel-%.7: %.md build/manfilter.lua
165 $(MAN_PANDOC) $< -o $@
166 sed -i.tmp 's/\\f\[C\]/\\f[CR]/g' $@ # work around pandoc 2.x bug
167
168 ## Release-related tasks:
169
170 SSH_KEY ?= ~/.ssh/id_ed25519.pub
171
172 test-builds: fennel test/faith.lua
173 ./fennel --metadata --eval "(require :test.init)"
174 $(MAKE) install PREFIX=/tmp/opt
175
176 upload: fennel fennel.lua fennel-bin
177 $(MAKE) fennel.exe CC=x86_64-w64-mingw32-gcc
178 mkdir -p downloads/
179 mv fennel downloads/fennel-$(VERSION)
180 mv fennel.lua downloads/fennel-$(VERSION).lua
181 mv fennel-bin downloads/fennel-$(VERSION)-x86_64
182 mv fennel.exe downloads/fennel-$(VERSION).exe
183 gpg -ab downloads/fennel-$(VERSION)
184 gpg -ab downloads/fennel-$(VERSION).lua
185 gpg -ab downloads/fennel-$(VERSION)-x86_64
186 gpg -ab downloads/fennel-$(VERSION).exe
187 ssh-keygen -Y sign -f $(SSH_KEY) -n file downloads/fennel-$(VERSION)
188 ssh-keygen -Y sign -f $(SSH_KEY) -n file downloads/fennel-$(VERSION).lua
189 ssh-keygen -Y sign -f $(SSH_KEY) -n file downloads/fennel-$(VERSION)-x86_64
190 ssh-keygen -Y sign -f $(SSH_KEY) -n file downloads/fennel-$(VERSION).exe
191 rsync -rtAv downloads/fennel-$(VERSION)* \
192 [email protected]:fennel-lang.org/downloads/
193
194 release: guard-VERSION upload
195 git tag -v $(VERSION) # created by prerelease target
196 git push
197 git push --tags
198 @echo "* Update the submodule in the fennel-lang.org repository."
199 @echo "* Announce the release on the mailing list."
200 @echo "* Bump the version in src/fennel/utils.fnl to the next dev version."
201 @echo "* Add a stub for the next version in changelog.md"
202
203 prerelease: guard-VERSION ci test-builds
204 @echo "Did you look for changes that need to be mentioned in help/man text?"
205 sed -i.tmp s/$(VERSION)-dev/$(VERSION)/ src/fennel/utils.fnl
206 $(MAKE) man
207 grep "$(VERSION)" setup.md > /dev/null
208 ! grep "???" changelog.md
209 git commit -a -m "Release $(VERSION)"
210 git tag -s $(VERSION) -m $(VERSION)
211
212 guard-%:
213 @ if [ "${${*}}" = "" ]; then \
214 echo "Environment variable $* not set"; \
215 exit 1; \
216 fi
217
218 .PHONY: build test testall fuzz count format ci clean coverage install \
219 man upload prerelease release guard-VERSION test-builds lint
220
221 # Steps to release a new Fennel version
222
223 # The `make release` command should be run on a system with the lowest
224 # available glibc for maximum compatibility.
225
226 # 1. Check for changes which need to be mentioned in help text or man page
227 # 2. Date `changelog.md` and update download links in `setup.md`
228 # 3. Run `make prerelease VERSION=$VERSION`
229 # 4. Update fennel-lang.org's fennel submodule and `make html` there
230 # 5. Run `make release VERSION=$VERSION`
231 # 6. Run `make upload` in fennel-lang.org.
232 # 7. Announce on the mailing list