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))$(filter %clean, $(MAKECMDGOALS))
25 config.make:=.config.make
26 include $(config.make)
28 ./configure --prefix=$(prefix)
33 ${top_builddest}src/mes\
70 .PHONY: $(PHONY_TARGETS)
83 build-aux/build-cc32.sh
87 CC32=$(TCC) build-aux/build-cc32.sh
90 $(warning skipping mes-tcc: no tcc)
94 build-aux/build-mes.sh
99 # Mes does not cache anything on the file system; therefore clean
102 maintainer-clean: clean
105 etags lib/*.c lib/*/*.c src/*.c include/*.h include/sys/*.h
108 build-aux/build-guile.sh
111 rm -f $(shell find . -name '*.go')
116 # Mes does not feature post-install checks yet, so we're great!
120 install: ${top_builddest}src/mes
126 $(config.make): configure
128 seed: all-go mes-gcc mes-tcc
130 cd $(TINYCC_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
132 cd $(MES_SEED) && git reset --hard HEAD
133 MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
134 cd $(MES_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
135 MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
136 cp lib/x86-mes/elf32-header.hex2\
138 lib/x86-mes/libc+tcc.S\
141 lib/x86-mes/libgetopt.S\
142 $(MESCC_TOOLS_SEED)/libs
143 cd $(MESCC_TOOLS_SEED) && MES_PREFIX=$(PWD) ./bootstrap.sh
145 ${top_builddest}doc/version.texi: doc/mes.texi GNUmakefile
147 (set `LANG= date -r $< +'%d %B %Y'`;\
148 echo "@set UPDATED $$1 $$2 $$3"; \
149 echo "@set UPDATED-MONTH $$2 $$3"; \
150 echo "@set EDITION $(VERSION)"; \
151 echo "@set VERSION $(VERSION)") > $@
153 doc: ${top_builddest}doc/version.texi
157 $(warning skipping info: no makeinfo)
163 $(warning skipping man: no help2man)
166 info: ${top_builddest}doc/mes.info
168 ${top_builddest}doc/mes.info: doc/mes.texi ${top_builddest}doc/version.texi doc/images/gcc-mesboot-graph.dot GNUmakefile
169 $(MAKEINFO) -o $@ -I ${top_builddest}doc -I doc $<
171 ${top_builddest}doc/images/gcc-mesboot-graph.png: doc/images/gcc-mesboot-graph.dot
173 $(DOT) -T png $< > $@
176 $(warning info: graphvis missing: no images)
179 man: ${top_builddest}doc/mes.1 ${top_builddest}doc/mescc.1
181 ${top_builddest}src/mes: build
183 ${top_builddest}doc/mes.1: ${top_builddest}src/mes
184 MES_ARENA=10000000 ${top_builddir}/pre-inst-env $(HELP2MAN) $(<F) > $@
186 ${top_builddest}doc/mescc.1: ${top_builddest}src/mes ${top_builddest}scripts/mescc
187 MES_ARENA=10000000 ${top_builddir}/pre-inst-env $(HELP2MAN) $(<F) > $@
189 html: ${top_builddest}doc/html/index.html
191 ${top_builddest}doc/html/index.html: doc/mes.texi ${top_builddest}doc/version.texi ${top_builddest}doc/images/gcc-mesboot-graph.png
192 $(MAKEINFO) --html -o $(@D) -I ${top_builddest}doc -I doc $<
194 dvi: ${top_builddest}doc/mes.dvi
196 ${top_builddest}doc/mes.dvi: doc/mes.texi
197 $(MAKEINFO) --dvi -I ${top_builddest}/doc -I doc -o doc/mes.dvi $<
199 pdf: ${top_builddest}doc/mes.pdf
201 ${top_builddest}doc/mes.pdf: doc/mes.texi
202 $(MAKEINFO) --pdf -I ${top_builddest}/doc -I doc -o doc/mes.pdf $<
204 ps: ${top_builddest}doc/mes.ps
206 ${top_builddest}doc/mes.ps: doc/mes.texi
207 $(MAKEINFO) --ps -I ${top_builddest}/doc -I doc -o doc/mes.ps $<
210 COMMIT=$(shell test -d .git && (git describe --dirty 2>/dev/null) || cat .tarball-version)
211 TARBALL_VERSION=$(COMMIT:v%=%)
212 TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
213 TARBALL:=${top_builddest}$(TARBALL_DIR).tar.gz
215 ${top_builddest}.tarball-version:
218 GIT_ARCHIVE_HEAD:=git archive HEAD --
219 GIT_LS_FILES:=git ls-files
220 ifeq ($(wildcard .git),)
221 GIT_ARCHIVE_HEAD:=tar -cf-
228 test ! -d .git || git diff --exit-code > /dev/null
229 test ! -d .git || git diff --cached --exit-code > /dev/null
230 @echo commit:$(COMMIT)
233 $(PERL) build-aux/gitlog-to-changelog --srcdir=${srcdir} > ChangeLog
235 $(TARBALL): ${top_builddest}.tarball-version | generate-ChangeLog
237 --exclude=$(TARBALL_DIR);\
238 echo $^ | tr ' ' '\n')\
239 | GZIP=-n tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner\
240 --transform=s,^,$(TARBALL_DIR)/,S -T- -czf $@
241 git checkout ChangeLog
244 update-hash: $(TARBALL)
245 $(GUIX) download file://$(PWD)/$<
246 sed -i -e 's,(base32 #!mes!# "[^"]*"),(base32 #!mes!# "$(shell $(GUIX) hash $<)"),' guix/git/mes.scm
249 $(warning update-hash: no guix)
253 ./pre-inst-env $(GUIX) build mes@$(VERSION) --with-source=$(TARBALL)
255 installdirs: mkinstalldirs
258 $(DESTDIR)$(datadir)\
260 $(DESTDIR)$(infodir)\
264 mkdir -p $(DESTDIR)${docdir}
265 cp ${top_builddest}doc/mes.dvi $(DESTDIR)${docdir}
268 mkdir -p $(DESTDIR)${docdir}
269 tar -cf- -C ${top_builddest}doc html | tar -xf- -C $(DESTDIR)${docdir}
272 mkdir -p $(DESTDIR)${docdir}
273 cp ${top_builddest}doc/mes.pdf $(DESTDIR)${docdir}
276 mkdir -p $(DESTDIR)${docdir}
277 cp ${top_builddest}doc/mes.ps $(DESTDIR)${docdir}
279 # We do not strip binaries, binutils' strip corrupts M1+hex2-generated ELFs
280 install-strip: install
284 Usage: make [OPTION]... [TARGET]...
286 Main and non-standard targets:
287 all update everything
288 all-go update .go files
289 gcc update src/mes.gcc-out
290 dist update $(TARBALL)
291 doc update documentation
292 mes-gcc update src/mes.mes-gcc-out
293 mes-tcc update src/mes.mes-tcc-out
296 clean run git clean -dfx
297 clean-go clean .go files
298 info update info documentation
299 install install in $(prefix)
300 install-info install info docs in $(prefix)/share/info
302 seed update mes-seed in $(MES_SEED)
303 uninstall uninstall from $(prefix)
309 include build-aux/export.make