| 1 |
# Compilation of the Scribe formatter written for the Ada Reference |
| 2 |
# Manual, translating .ms[ms] files into various formats. Also build |
| 3 |
# tar.gz for the web page. |
| 4 |
|
| 5 |
# Copyright (c) 2010, 2013 Stephen Leake <[email protected]> |
| 6 |
# Copyright (c) 2013 Nicolas Boulenguez <[email protected]> |
| 7 |
|
| 8 |
# This program is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 3 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
|
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with this program; if not, write to the Free Software |
| 20 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 |
|
| 22 |
# Specific targets generate every $document$year.$format combination. |
| 23 |
# Ex: make arm2012.pdf |
| 24 |
AVAILABLE_DOCUMENTS := aarm arm |
| 25 |
AVAILABLE_YEARS := 2005 2012 2020 |
| 26 |
AVAILABLE_FORMATS := html info texinfo txt pdf |
| 27 |
|
| 28 |
# 'all' builds all versions except pdf; to build a subset, override these on the command line. |
| 29 |
DOCUMENTS := $(AVAILABLE_DOCUMENTS) |
| 30 |
YEARS := $(AVAILABLE_YEARS) |
| 31 |
FORMATS := $(filter-out pdf texinfo, $(AVAILABLE_FORMATS)) |
| 32 |
# Texinfo is an intermediate, and is built as necessary. |
| 33 |
# Pdf requires installation of many huge formatting tools; we assume they are not installed. |
| 34 |
|
| 35 |
# see ../README.txt for list of things to change when Scribe or Ada source changes. |
| 36 |
# |
| 37 |
# Cygwin texi2dvi (GNU Texinfo 4.13) 1.135 fails silently! |
| 38 |
|
| 39 |
# Debian standard build flags for Ada projects |
| 40 |
BUILDER_OPTIONS := -k |
| 41 |
ADAFLAGS := |
| 42 |
LDFLAGS := |
| 43 |
# arm_info.gpr sets its own flags, then appends these variables so |
| 44 |
# that they take precedence. The intent is that you may configure the |
| 45 |
# build with a simple variable override. |
| 46 |
|
| 47 |
PYTHON ?= python3 |
| 48 |
EMACS_EXE ?= emacs |
| 49 |
|
| 50 |
.PHONY: all clean publish |
| 51 |
|
| 52 |
all: $(foreach d,$(DOCUMENTS),\ |
| 53 |
$(foreach y,$(YEARS),\ |
| 54 |
$(foreach f,$(FORMATS),\ |
| 55 |
$(d)$(y).$(f)))) |
| 56 |
|
| 57 |
|
| 58 |
create-dir : force |
| 59 |
for file in *.info; do install-info $$file dir; done |
| 60 |
|
| 61 |
# We have been unable to get rid of all the section ref violations, so we |
| 62 |
# specify --no-validate. Delete that to see the errors. |
| 63 |
TEXI_INFO_OPTS := --no-split --no-number-sections --no-validate |
| 64 |
TEXI_PDF_OPTS := --quiet |
| 65 |
|
| 66 |
SOURCE_DIR_2005 := ../source_2005 |
| 67 |
SOURCE_DIR_2012 := ../source_2012 |
| 68 |
SOURCE_DIR_2020 := ../source_2020 |
| 69 |
|
| 70 |
# See progs/command.txt. |
| 71 |
CHANGES := New-Only |
| 72 |
# See arm_form.ada comment before Get_Commands for possible values |
| 73 |
VERSION_2005 := 2 |
| 74 |
VERSION_2012 := 4 |
| 75 |
VERSION_2020 := 5 |
| 76 |
|
| 77 |
# Mapping from document acronyms to Randy's file names |
| 78 |
MASTER_arm := rm.msm |
| 79 |
MASTER_aarm := aarm.msm |
| 80 |
|
| 81 |
# Rough dependency, but Scribe files should not change often. |
| 82 |
SOURCES_2005 := $(wildcard $(SOURCE_DIR_2005)/*.ms[ms]) |
| 83 |
SOURCES_2012 := $(wildcard $(SOURCE_DIR_2012)/*.ms[ms]) |
| 84 |
SOURCES_2020 := $(wildcard $(SOURCE_DIR_2020)/*.ms[ms]) |
| 85 |
define doc_year_build |
| 86 |
|
| 87 |
# Non-unique intermediate paths would create a race condition, so we |
| 88 |
# store the temporary result into the versioned source directory. |
| 89 |
$(d)$(y).texinfo: arm_form.exe $(SOURCES_$(y)) |
| 90 |
cd $(SOURCE_DIR_$(y)); \ |
| 91 |
$(CURDIR)/$$< $(MASTER_$(d)) info $(CHANGES) $(VERSION_$(y)) $(VERSION_$(y)) ./; \ |
| 92 |
mv `sed -ne '/^@FilePrefix{\(.*\)}/{s//\L\1/p;q}' $(MASTER_$(d))`.texinfo $(CURDIR)/$$@ |
| 93 |
clean:: |
| 94 |
rm -f $(d)$(y).texinfo |
| 95 |
|
| 96 |
$(d)$(y).html: arm_form.exe $(SOURCES_$(y)) |
| 97 |
rm -f -r $$@ |
| 98 |
mkdir --parents $$@ |
| 99 |
cd $(SOURCE_DIR_$(y)); \ |
| 100 |
$(CURDIR)/$$< $(MASTER_$(d)) HTML $(CHANGES) $(VERSION_$(y)) $(VERSION_$(y)) $(CURDIR)/$$@/ |
| 101 |
clean:: |
| 102 |
rm -f -r $(d)$(y).html |
| 103 |
|
| 104 |
$(d)$(y).txt: arm_form.exe $(SOURCES_$(y)) |
| 105 |
rm -f -r $$@ |
| 106 |
mkdir --parents $$@ |
| 107 |
cd $(SOURCE_DIR_$(y)); \ |
| 108 |
$(CURDIR)/$$< $(MASTER_$(d)) Text $(CHANGES) $(VERSION_$(y)) $(VERSION_$(y)) $(CURDIR)/$$@/ |
| 109 |
for i in $$@/*; do \ |
| 110 |
iconv --from-code=iso8859-1 --to-code=utf-8 > $$@/tmp $$$$i && mv $$@/tmp $$$$i; \ |
| 111 |
done |
| 112 |
clean:: |
| 113 |
rm -f -r $(d)$(y).txt |
| 114 |
|
| 115 |
# ../progs/arm-texi-index.el adds texinfo index entries. |
| 116 |
$(d)$(y).texinfo-index: $(d)$(y).texinfo |
| 117 |
$(EMACS_EXE) -Q -batch -L ../progs -l arm-texi-index.el --eval '(progn(do-index "$$<")(kill-emacs))' |
| 118 |
touch $$@ |
| 119 |
clean:: |
| 120 |
rm -f $(d)$(y).texinfo-index |
| 121 |
|
| 122 |
# texi2any is from texinfo 5 |
| 123 |
$(d)$(y).info: $(d)$(y).texinfo-index |
| 124 |
texi2any --info $(TEXI_INFO_OPTS) $(d)$(y).texinfo -o $$@ |
| 125 |
clean:: |
| 126 |
rm -f $(d)$(y).info |
| 127 |
|
| 128 |
$(d)$(y).pdf: $(d)$(y).texinfo |
| 129 |
texi2any --pdf $(TEXI_PDF_OPTS) $$< -o $$@ |
| 130 |
clean:: |
| 131 |
rm -f $(d)$(y).aux $(d)$(y).cp $(d)$(y).cps $(d)$(y).log $(d)$(y).pdf $(d)$(y).toc |
| 132 |
|
| 133 |
endef |
| 134 |
$(foreach d,$(AVAILABLE_DOCUMENTS),\ |
| 135 |
$(foreach y,$(AVAILABLE_YEARS),\ |
| 136 |
$(eval $(doc_year_build)))) |
| 137 |
|
| 138 |
arm_form.exe : force |
| 139 |
gnatmake -p $(BUILDER_OPTIONS) -P arm_info.gpr $(foreach var,ADAFLAGS LDFLAGS,"-X$(var)=$($(var))") |
| 140 |
clean:: |
| 141 |
rm -f arm_form.exe |
| 142 |
rm -f -r objects __pycache__ |
| 143 |
|
| 144 |
trace : |
| 145 |
addr2line -e arm_form.exe 0x52f218 0x54d4de 0x402123 0x405c6e 0x401393 0x4014f9 0x7ffd98271410 0x7ffd990454f2 |
| 146 |
|
| 147 |
# year is latest standard; bump trailing digit for any change. |
| 148 |
ZIP_VERSION := $(lastword $(AVAILABLE_YEARS)).1 |
| 149 |
|
| 150 |
INFO_ARCHIVE := arm_info-$(ZIP_VERSION).tar.gz |
| 151 |
SOURCE_ARCHIVE := arm_info-$(ZIP_VERSION)-src.tar.gz |
| 152 |
publish: $(INFO_ARCHIVE) $(SOURCE_ARCHIVE) |
| 153 |
|
| 154 |
# --no-name eliminates time stamps, which helps make the tarball reproducible |
| 155 |
# --best gives higher compression than the default; we can afford the time here. |
| 156 |
GZIP := --no-name --best |
| 157 |
|
| 158 |
$(INFO_ARCHIVE): $(foreach d,$(DOCUMENTS),\ |
| 159 |
$(foreach y,$(YEARS),\ |
| 160 |
$(d)$(y).info)) |
| 161 |
tar cf - $^ | gzip $(GZIP) -c > $@ |
| 162 |
clean:: |
| 163 |
rm -f $(INFO_ARCHIVE) |
| 164 |
|
| 165 |
$(SOURCE_ARCHIVE): force |
| 166 |
(cd .. && git archive --prefix=arm_info-$(ZIP_VERSION)-src/ org.adaic.arm_form *) | gzip $(GZIP) -c > $@ |
| 167 |
|
| 168 |
clean:: |
| 169 |
rm -f $(SOURCE_ARCHIVE) |
| 170 |
|
| 171 |
update_upstream : source_ada.clean source_ada.stamp |
| 172 |
update_upstream : source_scribe_2005.clean source_scribe_2005.stamp |
| 173 |
update_upstream : source_scribe_2012.clean source_scribe_2012.stamp |
| 174 |
update_upstream : source_scribe_2020.clean source_scribe_2020.stamp |
| 175 |
|
| 176 |
# download.py does not convert to unix line endings here to minimize |
| 177 |
# the diff with upstream; the Ada compiler can handle DOS line endings |
| 178 |
# on Unix. download.py does convert file names to lower case here, for |
| 179 |
# consistency. |
| 180 |
source_ada.stamp : |
| 181 |
rm -rf ../../org.adaic.arm_form.upstream/progs |
| 182 |
cd ../../org.adaic.arm_form.upstream; $(PYTHON) ../org.adaic.arm_form/build/download.py progs |
| 183 |
touch source_ada.stamp |
| 184 |
|
| 185 |
source_ada.clean : |
| 186 |
rm -f source_ada.stamp |
| 187 |
|
| 188 |
# This retrieves the CVS tag for the year given on the command line |
| 189 |
# commit to mtn: (dvc-status "../../org.adaic.arm_form.upstream") |
| 190 |
# |
| 191 |
# download.py converts to unix line endings here, because the scribe |
| 192 |
# processor insists on uniform formatting; this works for both Windows |
| 193 |
# and Debian. download.py also converts all file names to lowercase, |
| 194 |
# and arm_form does as well; upstream only runs on Windows, which |
| 195 |
# ignores case in filenames, so the file names in the sources are not |
| 196 |
# consistently cased. |
| 197 |
source_scribe_%_downloaded.stamp : |
| 198 |
rm -rf ../../org.adaic.arm_form.upstream/source_$* |
| 199 |
cd ../../org.adaic.arm_form.upstream; $(PYTHON) ../org.adaic.arm_form/build/download.py $* |
| 200 |
|
| 201 |
# download.py often times out, so we need to run it multiple times, |
| 202 |
# then manually mark it done. Then make source_scribe_%.stamp |
| 203 |
mark_%_downloaded : |
| 204 |
touch source_scribe_$*_downloaded.stamp |
| 205 |
|
| 206 |
source_scribe_%.stamp : source_scribe_%_downloaded.stamp |
| 207 |
mv ../../org.adaic.arm_form.upstream/source ../../org.adaic.arm_form.upstream/source_$* |
| 208 |
touch source_scribe_$*.stamp |
| 209 |
|
| 210 |
source_scribe_%.clean : |
| 211 |
rm -f source_scribe_$*.stamp |
| 212 |
|
| 213 |
# These sources do not match the corresponding CVS tag, although they are close. |
| 214 |
ARM_SRC.ZIP ARM_FORM.ZIP ARM_FSRC.ZIP 2005-SRC.zip 2012-SRC.zip : |
| 215 |
wget http://www.ada-auth.org/arm-files/$@ |
| 216 |
|
| 217 |
# delete everything back to mtn checkout |
| 218 |
# |
| 219 |
# Note that additional 'clean' targets are specified after every |
| 220 |
# target that builds something. |
| 221 |
clean :: |
| 222 |
rm -f *.stamp *.zip |
| 223 |
|
| 224 |
info-clean : |
| 225 |
rm -f *.info* |
| 226 |
|
| 227 |
.PHONY : force |
| 228 |
|
| 229 |
VPATH = ../source_2005 ../source_2012 ../source_2020 ../progs |
| 230 |
|
| 231 |
#Local Variables: |
| 232 |
#eval: (delete '("\\.mss\\'" . scribe-mode) auto-mode-alist) |
| 233 |
#eval: (ada-parse-prj-file "arm_info.prj") |
| 234 |
#eval: (ada-select-prj-file "arm_info.prj") |
| 235 |
#End: |
| 236 |
# end of file |