branch: master commit 2c94f6f256fea850448106d4d492e22bf189b06f Author: Stephen Leake <stephen_le...@stephe-leake.org> Commit: Stephen Leake <stephen_le...@stephe-leake.org>
Add ada-ref-man/build directory for the Makefile * packages/ada-ref-man/build/: New directory. --- packages/ada-ref-man/.elpaignore | 3 +- packages/ada-ref-man/README | 3 + packages/ada-ref-man/build/Makefile | 211 +++++++++++++++++++++++ packages/ada-ref-man/build/arm_info.gpr | 108 ++++++++++++ packages/ada-ref-man/build/arm_info.prj | 3 + packages/ada-ref-man/build/download.py | 144 ++++++++++++++++ packages/ada-ref-man/build/emacs_case_exceptions | 2 + 7 files changed, 473 insertions(+), 1 deletion(-) diff --git a/packages/ada-ref-man/.elpaignore b/packages/ada-ref-man/.elpaignore index 4c65740..1f5e996 100755 --- a/packages/ada-ref-man/.elpaignore +++ b/packages/ada-ref-man/.elpaignore @@ -1,2 +1,3 @@ -source_2012 +build progs +source_2012 diff --git a/packages/ada-ref-man/README b/packages/ada-ref-man/README index f33558c..02ce58c 100644 --- a/packages/ada-ref-man/README +++ b/packages/ada-ref-man/README @@ -8,4 +8,7 @@ in the ada-france monotone repository; access information is given at http://stephe-leake.org/ada/arm.html. ELPA git copy in packages/ada-ref-man/progs. +packages/ada-ref-man/build/Makefile will compile the program and +produce the .info files. + diff --git a/packages/ada-ref-man/build/Makefile b/packages/ada-ref-man/build/Makefile new file mode 100755 index 0000000..ab564ed --- /dev/null +++ b/packages/ada-ref-man/build/Makefile @@ -0,0 +1,211 @@ +# Compilation of the Scribe formatter written for the Ada Reference +# Manual, translating .ms[ms] files into various formats. Also build +# tar.gz for the web page. + +# Copyright (c) 2010, 2013 Stephen Leake <stephen_le...@stephe-leake.org> +# Copyright (c) 2013 Nicolas Boulenguez <nico...@debian.org> + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Specific targets generate every $document$year.$format combination. +# Ex: make arm2012.pdf +AVAILABLE_DOCUMENTS := aarm arm +AVAILABLE_YEARS := 2005 2012 +AVAILABLE_FORMATS := html info texinfo txt pdf + +# 'all' builds all versions except pdf; to build a subset, override these on the command line. +DOCUMENTS := $(AVAILABLE_DOCUMENTS) +YEARS := $(AVAILABLE_YEARS) +FORMATS := $(filter-out pdf texinfo, $(AVAILABLE_FORMATS)) +# Texinfo is an intermediate, and is built as necessary. +# Pdf requires installation of many huge formatting tools; we assume they are not installed. + +# see ../README.txt for list of things to change when Scribe or Ada source changes. +# +# Cygwin texi2dvi (GNU Texinfo 4.13) 1.135 fails silently! + +# Debian standard build flags for Ada projects +BUILDER_OPTIONS := -k +ADAFLAGS := +LDFLAGS := +# arm_info.gpr sets its own flags, then appends these variables so +# that they take precedence. The intent is that you may configure the +# build with a simple variable override. + +.PHONY: all clean publish + +all: $(foreach d,$(DOCUMENTS),\ + $(foreach y,$(YEARS),\ + $(foreach f,$(FORMATS),\ + $(d)$(y).$(f)))) + +# We have been unable to get rid of all the section ref violations, so we +# specify --no-validate. Delete that to see the errors. +TEXI_INFO_OPTS := --no-split --no-number-sections --no-validate +TEXI_PDF_OPTS := --quiet + +SOURCE_DIR_2005 := ../source_2005 +SOURCE_DIR_2012 := ../source_2012 + +# See progs/command.txt. +CHANGES := New-Only +# See arm_form.exe help for possible values +VERSION_2005 := 2 +VERSION_2012 := 4 + +# Mapping from document acronyms to Randy's file names +MASTER_arm := rm.msm +MASTER_aarm := aarm.msm + +# Rough dependency, but Scribe files should not change often. +SOURCES_2005 := $(wildcard $(SOURCE_DIR_2005)/*.ms[ms]) +SOURCES_2012 := $(wildcard $(SOURCE_DIR_2012)/*.ms[ms]) +define doc_year_build + + # Non-unique intermediate paths would create a race condition, so we + # store the temporary result into the versioned source directory. + $(d)$(y).texinfo: arm_form.exe $(SOURCES_$(y)) + cd $(SOURCE_DIR_$(y)); \ + $(CURDIR)/$$< $(MASTER_$(d)) info $(CHANGES) $(VERSION_$(y)) $(VERSION_$(y)) ./; \ + mv `sed -ne '/^@FilePrefix{\(.*\)}/{s//\L\1/p;q}' $(MASTER_$(d))`.texinfo $(CURDIR)/$$@ + clean:: + rm -f $(d)$(y).texinfo + + $(d)$(y).html: arm_form.exe $(SOURCES_$(y)) + rm -f -r $$@ + mkdir --parents $$@ + cd $(SOURCE_DIR_$(y)); \ + $(CURDIR)/$$< $(MASTER_$(d)) HTML $(CHANGES) $(VERSION_$(y)) $(VERSION_$(y)) $(CURDIR)/$$@/ + clean:: + rm -f -r $(d)$(y).html + + $(d)$(y).txt: arm_form.exe $(SOURCES_$(y)) + rm -f -r $$@ + mkdir --parents $$@ + cd $(SOURCE_DIR_$(y)); \ + $(CURDIR)/$$< $(MASTER_$(d)) Text $(CHANGES) $(VERSION_$(y)) $(VERSION_$(y)) $(CURDIR)/$$@/ + clean:: + rm -f -r $(d)$(y).txt + +# texi2any is from texinfo 5 + $(d)$(y).info: $(d)$(y).texinfo + texi2any --info $(TEXI_INFO_OPTS) $$< -o $$@ + clean:: + rm -f $(d)$(y).info + + $(d)$(y).pdf: $(d)$(y).texinfo + texi2any --pdf $(TEXI_PDF_OPTS) $$< -o $$@ + clean:: + rm -f $(d)$(y).log $(d)$(y).pdf $(d)$(y).toc + +endef +$(foreach d,$(AVAILABLE_DOCUMENTS),\ +$(foreach y,$(AVAILABLE_YEARS),\ +$(eval $(doc_year_build)))) + +arm_form.exe : force + gnatmake -p $(BUILDER_OPTIONS) -P arm_info.gpr $(foreach var,ADAFLAGS LDFLAGS,"-X$(var)=$($(var))") +clean:: + rm -f arm_form.exe + rm -f -r objects + +trace : + addr2line -e arm_form.exe 0x5c12e7 0x5c598e 0x43e05b 0x446c5b 0x448369 0x545205 0x4e9221 0x4e3b1a 0x5831a1 0x5ad295 0x5adee9 0x4cb3f5 0x401850 0x401235 0x401286 0x7c817075 + +# year is latest standard; bump trailing digit for any change. +ZIP_VERSION := $(lastword $(AVAILABLE_YEARS)).3 + +INFO_ARCHIVE := arm_info-$(ZIP_VERSION).tar.gz +SOURCE_ARCHIVE := arm_info-$(ZIP_VERSION)-src.tar.gz +publish: $(INFO_ARCHIVE) $(SOURCE_ARCHIVE) + +# --no-name eliminates time stamps, which helps make the tarball reproducible +# --best gives higher compression than the default; we can afford the time here. +GZIP := --no-name --best + +$(INFO_ARCHIVE): $(foreach d,$(DOCUMENTS),\ + $(foreach y,$(YEARS),\ + $(d)$(y).info)) + tar cf - $^ | gzip $(GZIP) -c > $@ +clean:: + rm -f $(INFO_ARCHIVE) + +ZIP_EXCLUDES := *~ *.dvi *.gz *.info *.log *.pdf *.ps *.texinfo *.toc \ + *.stamp *.zip arm_form.exe _MTN .mtn-ignore .dvc-exclude aarm2005.html \ + aarm2005.txt aarm2012.html aarm2012.txt arm2005.html arm2005.txt arm2012.html \ + arm2012.txt objects +$(SOURCE_ARCHIVE): + tar cf - -C ../.. $(foreach e,$(ZIP_EXCLUDES),--exclude="$(e)") org.adaic.arm_form | gzip $(GZIP) -c > $@ +clean:: + rm -f $(SOURCE_ARCHIVE) + +update_upstream : source_ada.clean source_ada.stamp +update_upstream : source_scribe_2005.clean source_scribe_2005.stamp +update_upstream : source_scribe_2012.clean source_scribe_2012.stamp + +# download.py does not convert to unix line endings here to minimize +# the diff with upstream; the Ada compiler can handle DOS line endings +# on Unix. download.py does convert file names to lower case here, for +# consistency. +source_ada.stamp : + rm -rf ../../org.adaic.arm_form.upstream/progs + cd ../../org.adaic.arm_form.upstream; python3 ../org.adaic.arm_form/build/download.py progs + touch source_ada.stamp + +source_ada.clean : + rm -f source_ada.stamp + +# This retrieves the CVS tag for the year given on the command line +# commit to mtn: (dvc-status "../../org.adaic.arm_form.upstream") +# +# download.py converts to unix line endings here, because the scribe +# processor insists on uniform formatting; this works for both Windows +# and Debian. download.py also converts all file names to lowercase, +# and arm_form does as well; upstream only runs on Windows, which +# ignores case in filenames, so the file names in the sources are not +# consistently cased. +source_scribe_%.stamp : + rm -rf ../../org.adaic.arm_form.upstream/source_$* + cd ../../org.adaic.arm_form.upstream; python3 ../org.adaic.arm_form/build/download.py $* + mv ../../org.adaic.arm_form.upstream/source ../../org.adaic.arm_form.upstream/source_$* + touch source_scribe_$*.stamp + +source_scribe_%.clean : + rm -f source_scribe_$*.stamp + +# These sources do not match the correpsonding CVS tag, although they are close. +ARM_SRC.ZIP ARM_FORM.ZIP ARM_FSRC.ZIP 2005-SRC.zip 2012-SRC.zip : + wget http://www.ada-auth.org/arm-files/$@ + +# delete everything back to mtn checkout +# +# Note that additional 'clean' targets are specified after every +# target that builds something. +clean :: + rm -f *.stamp *.zip + +info-clean : + rm -f *.info* + +.PHONY : force + +VPATH = ../source_2005 ../source_2012 ../progs + +#Local Variables: +#eval: (delete '("\\.mss\\'" . scribe-mode) auto-mode-alist) +#eval: (ada-parse-prj-file "arm_info.prj") +#eval: (ada-select-prj-file "arm_info.prj") +#End: +# end of file diff --git a/packages/ada-ref-man/build/arm_info.gpr b/packages/ada-ref-man/build/arm_info.gpr new file mode 100755 index 0000000..82f9342 --- /dev/null +++ b/packages/ada-ref-man/build/arm_info.gpr @@ -0,0 +1,108 @@ +project ARM_Info is + for Source_Dirs use + ("../progs"); + + for Main use ("arm_form.ada"); + + for Object_Dir use "objects"; + for Exec_Dir use "."; + + package Naming is + for Spec ("ARM_Contents") use "arm_cont.ads"; + for Body ("ARM_Contents") use "arm_cont.adb"; + + for Spec ("ARM_Corr") use "arm_corr.ads"; + for Body ("ARM_Corr") use "arm_corr.adb"; + + for Spec ("ARM_Database") use "arm_db.ads"; + for Body ("ARM_Database") use "arm_db.adb"; + + for Spec ("ARM_File") use "arm_file.ads"; + for Body ("ARM_File") use "arm_file.adb"; + + for Spec ("ARM_Format") use "arm_frm.ads"; + for Body ("ARM_Format") use "arm_frm.adb"; + + for Spec ("ARM_Format.Data") use "arm_frmd.ads"; + for Body ("ARM_Format.Data") use "arm_frmd.adb"; + + for Body ("ARM_Format.Scan") use "arm_frms.adb"; + + for body ("ARM_Formatter") use "arm_form.ada"; + + for spec ("ARM_HTML") use "arm_html.ads"; + for Body ("ARM_HTML") use "arm_html.adb"; + + for Spec ("ARM_Index") use "arm_indx.ads"; + for Body ("ARM_Index") use "arm_indx.adb"; + + for Spec ("ARM_Input") use "arm_inp.ads"; + for Body ("ARM_Input") use "arm_inp.adb"; + + for Spec ("ARM_Master") use "arm_mast.ads"; + for Body ("ARM_Master") use "arm_mast.adb"; + + for Spec ("ARM_Output") use "arm_out.ads"; + + for spec ("ARM_RTF") use "arm_rtf.ads"; + for Body ("ARM_RTF") use "arm_rtf.adb"; + + for Spec ("ARM_String") use "arm_str.ads"; + for Body ("ARM_String") use "arm_str.adb"; + + for Spec ("ARM_Subindex") use "arm_sub.ads"; + for Body ("ARM_Subindex") use "arm_sub.adb"; + + for Spec ("ARM_Syntax") use "arm_syn.ads"; + for Body ("ARM_Syntax") use "arm_syn.adb"; + + for Spec ("ARM_Text") use "arm_text.ads"; + for Body ("ARM_Text") use "arm_text.adb"; + + for Spec ("ARM_Texinfo") use "arm_texi.ads"; + for Body ("ARM_Texinfo") use "arm_texi.adb"; + + end Naming; + + package Compiler is + -- upstream wants Ada 2005 syntax, no GNAT-specific pragmas. + -- We disable some warnings to minimize source diff with upstream. + -- We append ADAFLAGS so the Makefile can add or override options. + Switches := + ("-g", + "-O0", + "-gnat2005", + "-gnatfoqQ", + "-gnatVa", + "-gnatwaCeFKLMP", + "-fstack-check", + "-gnatybefp") + & External_As_List ("ADAFLAGS", " "); + + for Default_Switches ("Ada") use Switches; + + -- arm_frm has code that passes the same object via two 'in out' + -- params; GNAT 4.8 warns about that, so we suppress the warning + -- here. + for Switches ("arm_frm.adb") use Switches & ("-gnatw.I"); + + end Compiler; + + package Binder is + for Default_Switches ("Ada") use ("-E"); + end Binder; + + package Builder is + for Default_Switches ("Ada") use ("-C"); + + -- We use ".exe" extension even on non-Windows, to simplify the makefiles. + for Executable_Suffix use ".exe"; + + for Executable ("ARM_FORM.ADA") use "arm_form.exe"; + end Builder; + + package Linker is + for Default_Switches ("Ada") use External_As_List ("LDFLAGS", " "); + end Linker; + +end ARM_Info; diff --git a/packages/ada-ref-man/build/arm_info.prj b/packages/ada-ref-man/build/arm_info.prj new file mode 100755 index 0000000..1629a87 --- /dev/null +++ b/packages/ada-ref-man/build/arm_info.prj @@ -0,0 +1,3 @@ +gpr_file=arm_info.gpr + +casing=emacs_case_exceptions diff --git a/packages/ada-ref-man/build/download.py b/packages/ada-ref-man/build/download.py new file mode 100755 index 0000000..ec4feee --- /dev/null +++ b/packages/ada-ref-man/build/download.py @@ -0,0 +1,144 @@ +#!/usr/bin/python3 + +# Script to download the Ada Reference Manual and its formatting tool. + +# Copyright (c) 2010, 2012 Stephen Leake <stephen_le...@stephe-leake.org> +# Copyright (c) 2013 Nicolas Boulenguez <nico...@debian.org> + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import os.path +import re +import urllib.request +import sys + +USE_EXISTING_FILES = True + +###################################################################### +class CVSWeb (): + + def __init__ (self, hostname, top_directory): + # Instantiation requires distant root. + + self._host = 'http://' + hostname + self._cgi = '/cgi-bin/cvsweb.cgi/' + top_directory + '/' + + def files_in_directory (self, path): + # List text files in the head revision of a directory. + + # I did not find a way to list a tagged revision, except a + # direct tag list for each file. + + cgi = self._cgi + str.lower (path) + '/' + with urllib.request.urlopen (self._host + cgi) as f: + contents = f.read () + # Refuse directory names (with a trailing slash). + # Ignore case of the displayed file name. + pattern = '<a href="' + re.escape (cgi) + '([^"/]+)">(\\1)</a><br>' + matches = re.finditer (str.encode (pattern), contents, re.IGNORECASE) + return (bytes.decode (m.group (2)) for m in matches) + + def download_file (self, path, + tag = None): # None means the head revision. + # Return the contents of the tagged revision of path, as bytes. + # If tag is provided, but no revision of this file carries it, + # None is returned. + + cgi = self._cgi + str.lower (path) + if tag != None: + with urllib.request.urlopen (self._host + cgi) as f: + contents = f.read () + pattern = '<a href="' + re.escape (cgi) \ + + '\?rev=([0-9.]+)">\\1</a></b></span><br>\r\n' \ + + 'Modified <i>[^<]*</i>\r\n' \ + + 'by <i>[^<]*</i>( with line changes <i>[^<]*</i>)?<br>\r\n' \ + + 'CVS Tags: <b>[^<]*' + re.escape (tag) + '[^<]*</b><br>' + match = re.search (str.encode (pattern), contents) + if not match: + return None + cgi += '?rev=' + bytes.decode (match.group (1)) + else: + cgi += '?rev=HEAD' + with urllib.request.urlopen (self._host + cgi) as f: + contents = f.read () + return contents + +###################################################################### +def download_subdir (cvsweb, subdir, + tag = None, # None means the head revision. + rename_lowercase = False, + strip_carriage_returns = False): + + def fmt (a, b): + print ('{:<30} : {}'.format (a, b)) + + fmt ('Subdirectory', subdir) + if tag: + fmt ('Revision', tag) + else: + fmt ('Revision', 'latest') + fmt ('Renaming files to lowercase', rename_lowercase) + fmt ('Stripping carriage returns', strip_carriage_returns) + + try: + os.mkdir (subdir) # Fails if the directory exists. + except FileExistsError: + if not USE_EXISTING_FILES: + raise + + for basename in cvsweb.files_in_directory (subdir): + src = subdir + '/' + basename + if rename_lowercase: + basename = str.lower (basename) + dst = os.path.join (subdir, basename) # Local path join. + if USE_EXISTING_FILES and os.path.exists (dst): + fmt (dst, 'using existing file') + continue + contents = cvsweb.download_file (src, tag) + if not contents: + fmt (dst, 'no such tag') + continue + if strip_carriage_returns: + contents = re.sub (b'\r\n', b'\n', contents) + with open (dst, 'bw') as o: + o.write (contents) + fmt (dst, 'downloaded') + +###################################################################### + +cvsweb = CVSWeb (hostname = 'www.ada-auth.org', + top_directory = 'arm') +tags = { '1995':'Final_TC1', + '2005':'Amend_Final', + '2012':'Ada2012_TC1' } + +if len (sys.argv) == 2 and sys.argv [1] == 'progs': + download_subdir (cvsweb, 'progs', + rename_lowercase = True) + print (""" +No certification or signature used for downloaded code sources. +Hint: diff -rN --ignore-file-name-case --strip-trailing-cr old/ progs/ +""") + +elif len (sys.argv) == 2 and sys.argv [1] in tags: + download_subdir (cvsweb, 'source', + tag = tags [sys.argv [1]], + rename_lowercase = True, + strip_carriage_returns = True) + +else: + print ('Usage: {} [progs | {}]'.format ( + sys.argv [0], + str.join (' | ', sorted ([str (year) for year in tags.keys ()])))) diff --git a/packages/ada-ref-man/build/emacs_case_exceptions b/packages/ada-ref-man/build/emacs_case_exceptions new file mode 100755 index 0000000..68cdb71 --- /dev/null +++ b/packages/ada-ref-man/build/emacs_case_exceptions @@ -0,0 +1,2 @@ +*ARM +*LaTeX