1 # GNU Mes --- Maxwell Equations of Software
2 # Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
4 # This file is part of GNU Mes.
6 # GNU Mes is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or (at
9 # your option) any later version.
11 # GNU Mes is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
19 GUILE_FLAGS:=--no-auto-compile -L . -L module -C . -C module
21 cleaning_p:=$(filter clean%, $(MAKECMDGOALS))
25 config.make:=.config.make
26 include $(config.make)
28 ./configure --prefix=$(prefix)
32 PHONY_TARGETS:= all all-go build check clean clean-go default dist doc help install\
33 install-info man gcc mes ${top_builddest}src/mes mes-gcc mes-tcc generate-ChangeLog\
36 .PHONY: $(PHONY_TARGETS)
49 build-aux/build-cc32.sh
53 CC32=$(TCC) build-aux/build-cc32.sh
56 $(warning skipping mes-tcc: no tcc)
60 build-aux/build-mes.sh
66 build-aux/build-guile.sh
69 rm -f $(shell find . -name '*.go')
74 install: ${top_builddest}src/mes
80 $(config.make): configure
82 seed: all-go mes-gcc mes-tcc
84 cd $(TINYCC_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
86 cd $(MES_SEED) && git reset --hard HEAD
87 MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
88 cd $(MES_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
89 MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
90 cp lib/x86-mes/elf32-header.hex2\
92 lib/x86-mes/libc+tcc.S\
95 lib/x86-mes/libgetopt.S\
96 $(MESCC_TOOLS_SEED)/libs
97 cd $(MESCC_TOOLS_SEED) && MES_PREFIX=$(PWD) ./bootstrap.sh
99 ${top_builddest}doc/version.texi: doc/mes.texi GNUmakefile
101 (set `LANG= date -r $< +'%d %B %Y'`;\
102 echo "@set UPDATED $$1 $$2 $$3"; \
103 echo "@set UPDATED-MONTH $$2 $$3"; \
104 echo "@set EDITION $(VERSION)"; \
105 echo "@set VERSION $(VERSION)") > $@
107 doc: ${top_builddest}doc/version.texi
111 $(warning skipping info: no makeinfo)
117 $(warning skipping man: no help2man)
120 info: ${top_builddest}doc/mes.info
122 ${top_builddest}doc/mes.info: doc/mes.texi ${top_builddest}doc/version.texi doc/images/gcc-mesboot-graph.dot GNUmakefile
123 $(MAKEINFO) -o $@ -I ${top_builddest}doc -I doc $<
125 ${top_builddest}doc/images/gcc-mesboot-graph.png: doc/images/gcc-mesboot-graph.dot
127 $(DOT) -T png $< > $@
130 $(warning info: graphvis missing: no images)
135 man: ${top_builddest}doc/mes.1 ${top_builddest}doc/mescc.1
137 ${top_builddest}src/mes: build
139 ${top_builddest}doc/mes.1: ${top_builddest}src/mes
140 MES_ARENA=10000000 ${top_builddir}/pre-inst-env $(HELP2MAN) $(<F) > $@
142 ${top_builddest}doc/mescc.1: ${top_builddest}src/mes ${top_builddest}scripts/mescc
143 MES_ARENA=10000000 ${top_builddir}/pre-inst-env $(HELP2MAN) $(<F) > $@
145 html: ${top_builddest}mes/index.html
147 ${top_builddest}mes/index.html: doc/mes.texi ${top_builddest}doc/images/gcc-mesboot-graph.png
148 $(MAKEINFO) --html -o ${top_builddest}doc/mes $<
150 pdf: ${top_builddest}doc/mes.pdf
152 ${top_builddest}doc/mes.pdf: doc/mes.texi
153 $(MAKEINFO) --pdf -I ${top_builddest}/doc -o doc/mes.pdf $<
156 COMMIT=$(shell test -d .git && (git describe --dirty 2>/dev/null) || cat .tarball-version)
157 TARBALL_VERSION=$(COMMIT:v%=%)
158 TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
159 TARBALL:=${top_builddest}$(TARBALL_DIR).tar.gz
161 ${top_builddest}.tarball-version:
164 GIT_ARCHIVE_HEAD:=git archive HEAD --
165 GIT_LS_FILES:=git ls-files
166 ifeq ($(wildcard .git),)
167 GIT_ARCHIVE_HEAD:=tar -cf-
174 test ! -d .git || git diff --exit-code > /dev/null
175 test ! -d .git || git diff --cached --exit-code > /dev/null
176 @echo commit:$(COMMIT)
179 $(PERL) build-aux/gitlog-to-changelog --srcdir=${srcdir} > ChangeLog
181 $(TARBALL): ${top_builddest}.tarball-version | generate-ChangeLog
183 --exclude=$(TARBALL_DIR);\
184 echo $^ | tr ' ' '\n')\
185 | GZIP=-n tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner\
186 --transform=s,^,$(TARBALL_DIR)/,S -T- -czf $@
187 git checkout ChangeLog
190 update-hash: $(TARBALL)
191 $(GUIX) download file://$(PWD)/$<
192 sed -i -e 's,(base32 #!mes!# "[^"]*"),(base32 #!mes!# "$(shell $(GUIX) hash $<)"),' guix/git/mes.scm
195 $(warning update-hash: no guix)
199 ./pre-inst-env $(GUIX) build mes@$(VERSION) --with-source=$(TARBALL)
202 Usage: make [OPTION]... [TARGET]...
205 all update everything
206 all-go update .go files
207 gcc update src/mes.gcc-out
208 dist update $(TARBALL)
209 doc update documentation
210 mes-gcc update src/mes.mes-gcc-out
211 mes-tcc update src/mes.mes-tcc-out
214 clean run git clean -dfx
215 clean-go clean .go files
216 info update info documentation
217 install install in $(prefix)
218 install-info install info docs in $(prefix)/share/info
219 seed update mes-seed in $(MES_SEED)
220 uninstall uninstall from $(prefix)
226 include build-aux/export.make