From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1499) id 7BC4D384D1A5; Fri, 21 Oct 2022 15:38:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BC4D384D1A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666366702; bh=KtphzgI3EKGM99NyNzroFisBruWRTWZqeHhHU+hLKFU=; h=From:To:Subject:Date:From; b=CsPRJo9l37xW5rk0yiT1wr704IzStNmJZxhGX/Na0kZHA/Myru5OFz0AKjw8rswo+ aF1SjrAolStLgQSIBoQPADFmIktT3OZQF2Du6w+VRl2sZyYQ2x3IybV6CMocK3+lYM M6LrnUb+WIzG8LN3o+Fm1ucKuhT+u7X/zbl3/2Ko= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Gaius Mulley To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/modula-2] gcc/m2/tools-src/def2doc.py rewritten to use argparse X-Act-Checkin: gcc X-Git-Author: Gaius Mulley X-Git-Refname: refs/heads/devel/modula-2 X-Git-Oldrev: 4a7481c6ed5f698e7cc3f62d1cdc3202f68c4143 X-Git-Newrev: f7b2d2d0ab28744763540ffe2f3b5001fbf3e211 Message-Id: <20221021153822.7BC4D384D1A5@sourceware.org> Date: Fri, 21 Oct 2022 15:38:22 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f7b2d2d0ab28744763540ffe2f3b5001fbf3e211 commit f7b2d2d0ab28744763540ffe2f3b5001fbf3e211 Author: Gaius Mulley Date: Fri Oct 21 16:37:26 2022 +0100 gcc/m2/tools-src/def2doc.py rewritten to use argparse gcc/m2/tools-src/def2texi.py renamed to gcc/m2/tools-src/def2doc.py. It has been rewritten to use argparse and now has additional options -x (partial sphinx output at present), -t texinfo output and -o output filename. It has been reformatted to conform to flake8. The gcc/configure.ac has been extended to check for the existance of python3. gcc/m2/Make-lang.in checks HAVE_PYTHON before invoking python3. gcc/ChangeLog: * configure.ac (HAVE_PYTHON): New test added. (PYTHON) New test added. * doc/gm2.texi (Copying): Menu item moved between Contributing and Licence. gcc/m2/ChangeLog: * tools-src/def2doc.py (Renamed from def2texi.py): Rewritten to use argparse rather than getopt. New options introduced -t texinfo and -x for sphinx output. New option -o output file introduced. Code reformatted to conform to flake8. * m2/Make-lang.in: Only build texi files with def2texi.py if HAVE_PYTHON allows. * m2/config-make.in (HAVE_PYTHON): Added. (PYTHON) Added. * m2/configure : Rebuilt. * m2/configure.ac: Remove check for flex as it is checked in gcc/configure.ac. * gm2-libs-pim/README.texi: Remove local menu and use 3 links instead. Signed-off-by: Gaius Mulley Diff: --- gcc/configure | 90 +++++++- gcc/configure.ac | 5 +- gcc/doc/gm2.texi | 11 +- gcc/m2/Make-lang.in | 39 +++- gcc/m2/config-make.in | 4 + gcc/m2/configure | 47 ----- gcc/m2/configure.ac | 5 - gcc/m2/gm2-libs-pim/README.texi | 16 +- gcc/m2/tools-src/def2doc.py | 444 ++++++++++++++++++++++++++++++++++++++++ gcc/m2/tools-src/def2texi.py | 423 -------------------------------------- libgm2/configure | 52 ++++- 11 files changed, 632 insertions(+), 504 deletions(-) diff --git a/gcc/configure b/gcc/configure index 99ba76522d6..f8b96b64b56 100755 --- a/gcc/configure +++ b/gcc/configure @@ -805,6 +805,8 @@ am__leading_dot doc_build_sys AR NM +PYTHON +HAVE_PYTHON BISON FLEX GENERATED_MANPAGES @@ -8902,6 +8904,89 @@ done test -n "$BISON" || BISON="$MISSING bison" +# Python3? +# Extract the first word of "python3", so it can be a program name with args. +set dummy python3; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_HAVE_PYTHON+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$HAVE_PYTHON"; then + ac_cv_prog_HAVE_PYTHON="$HAVE_PYTHON" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_HAVE_PYTHON=""yes"" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_HAVE_PYTHON" && ac_cv_prog_HAVE_PYTHON=""no"" +fi +fi +HAVE_PYTHON=$ac_cv_prog_HAVE_PYTHON +if test -n "$HAVE_PYTHON"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_PYTHON" >&5 +$as_echo "$HAVE_PYTHON" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +for ac_prog in python3 +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PYTHON+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PYTHON"; then + ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PYTHON="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PYTHON=$ac_cv_prog_PYTHON +if test -n "$PYTHON"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 +$as_echo "$PYTHON" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$PYTHON" && break +done +test -n "$PYTHON" || PYTHON="$MISSING python3" + + # Binutils are not build modules, unlike bison/flex/makeinfo. So we # check for build == host before using them. @@ -19713,7 +19798,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19716 "configure" +#line 19801 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19819,7 +19904,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19822 "configure" +#line 19907 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -33900,4 +33985,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi - diff --git a/gcc/configure.ac b/gcc/configure.ac index e48fcbfe18e..dc181c854ad 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1269,6 +1269,10 @@ AC_CHECK_PROGS([FLEX], flex, [$MISSING flex]) # Bison? AC_CHECK_PROGS([BISON], bison, [$MISSING bison]) +# Python3? +AC_CHECK_PROG(HAVE_PYTHON, python3, "yes", "no") +AC_CHECK_PROGS([PYTHON], python3, [$MISSING python3]) + # Binutils are not build modules, unlike bison/flex/makeinfo. So we # check for build == host before using them. @@ -7654,4 +7658,3 @@ done ], [subdirs='$subdirs']) AC_OUTPUT - diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi index 897de6ead10..fdecabc01ab 100644 --- a/gcc/doc/gm2.texi +++ b/gcc/doc/gm2.texi @@ -72,11 +72,11 @@ Boston, MA 02110-1301, USA@* @menu * Overview:: What is GNU Modula-2. * Using:: Using GNU Modula-2. -* Licence:: Licence of GNU Modula-2. -* Contributing:: Contributing to GNU Modula-2. +* Licence:: Licence of GNU Modula-2 +* Copying:: GNU Public Licence V3. +* Contributing:: Contributing to GNU Modula-2 * Internals:: GNU Modula-2 internals. * EBNF:: EBNF of GNU Modula-2 -* Copying:: GNU Public Licence V3. * Libraries:: PIM and ISO library definitions. * Indices:: Document and function indices. @end menu @@ -2826,7 +2826,7 @@ There are also a variety of fixed sized @code{INTEGER} and @code{CARDINAL} types. The variety of the fixed sized types will depend upon the target architecture. -@node Licence, Contributing, The ISO system module, Top +@node Licence, Copying, The ISO system module, Top @section Licence of GNU Modula-2 GNU Modula-2 is free software, the compiler is held under the GPL v3 @@ -2846,9 +2846,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see More information on how these licences work is available @uref{http://www.gnu.org/licenses/licenses.html} on the GNU web site. +@c Copying node is inside the gpl_v3.texi @include gpl_v3.texi -@node Contributing, Internals, Licence, Top +@node Contributing, Internals, Copying, Top @section Contributing to GNU Modula-2 Please do. But also please read the GNU Emacs info under diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index f785834029e..dc32a4d607a 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -18,8 +18,6 @@ #along with GCC; see the file COPYING3. If not see #. -GM2_MAKE_DEBUG= - # Actual names to use when installing a native compiler. GM2_INSTALL_NAME = $(shell echo gm2|sed '$(program_transform_name)') GM2_TARGET_INSTALL_NAME = $(target_noncanonical)-$(shell echo gm2|sed '$(program_transform_name)') @@ -53,6 +51,7 @@ m2.serial = cc1gm2$(exeext) GM2_PROG_DEP=gm2$(exeext) xgcc$(exeext) cc1gm2$(exeext) include m2/config-make + LIBSTDCXX=../$(TARGET_SUBDIR)/libstdc++-v3/src/.libs/libstdc++.a PGE=m2/pge$(exeext) @@ -138,10 +137,16 @@ $(objdir)/m2/images/gnu.eps: $(srcdir)/m2/images/gnupng m2/gm2-libs.texi: gm2-libs.texi-check; @true -gm2-libs.texi-check: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/Builtins.texi \ - $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def m2/gm2-ebnf.texi - python3 $(srcdir)/m2/tools-src/def2texi.py -uLibraries -s$(srcdir)/m2 -b$(objdir)/m2 > $(objdir)/m2/gm2-libs.texi +ifeq ($(HAVE_PYTHON),yes) +gm2-libs.texi-check: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/Builtins.texi \ + $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def m2/gm2-ebnf.texi + $(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -uLibraries -s$(srcdir)/m2 -b$(objdir)/m2 -o $(objdir)/m2/gm2-libs.texi $(STAMP) gm2-libs.texi-check +else +gm2-libs.texi-check: + echo "not building gm2-libs.texi as python3 has not been found" + touch $(objdir)/m2/gm2-libs.texi +endif m2/gm2-ebnf.texi: gm2-ebnf.texi-check; @true @@ -151,21 +156,39 @@ gm2-ebnf.texi-check: $(PGE) $(srcdir)/m2/gm2-compiler/P0SyntaxCheck.bnf m2/SYSTEM-pim.texi: SYSTEM-pim-texi-check; @true +ifeq ($(HAVE_PYTHON),yes) SYSTEM-pim-texi-check: $(objdir)/m2/gm2-libs/SYSTEM.def - python3 $(srcdir)/m2/tools-src/def2texi.py -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs/SYSTEM.def > $(objdir)/m2/SYSTEM-pim.texi + $(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs/SYSTEM.def -o $(objdir)/m2/SYSTEM-pim.texi $(STAMP) SYSTEM-pim-texi-check +else +SYSTEM-pim-texi-check: $(objdir)/m2/gm2-libs/SYSTEM.def + echo "not building SYSTEM-pim.texi as python3 has not been found" + touch $(objdir)/m2/SYSTEM-pim.texi +endif m2/SYSTEM-iso.texi: SYSTEM-iso.texi-check; @true +ifeq ($(HAVE_PYTHON),yes) SYSTEM-iso.texi-check: $(objdir)/m2/gm2-libs-iso/SYSTEM.def - python3 $(srcdir)/m2/tools-src/def2texi.py -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs-iso/SYSTEM.def > $(objdir)/m2/SYSTEM-iso.texi + $(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs-iso/SYSTEM.def -o $(objdir)/m2/SYSTEM-iso.texi $(STAMP) SYSTEM-iso.texi-check +else +SYSTEM-iso.texi-check: $(objdir)/m2/gm2-libs-iso/SYSTEM.def + echo "not building SYSTEM-iso.texi as python3 has not been found" + touch $(objdir)/m2/SYSTEM-iso.texi +endif m2/Builtins.texi: Builtins.texi-check; @true +ifeq ($(HAVE_PYTHON),yes) Builtins.texi-check: m2/gm2-libs/Builtins.def - python3 $(srcdir)/m2/tools-src/def2texi.py -b./ -f$(srcdir)/m2/gm2-libs/Builtins.def > $(objdir)/m2/Builtins.texi + $(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -b./ -f$(srcdir)/m2/gm2-libs/Builtins.def -o $(objdir)/m2/Builtins.texi $(STAMP) Builtins.texi-check +else +Builtins.texi-check: m2/gm2-libs/Builtins.def + echo "not building SYSTEM-iso.texi as python3 has not been found" + touch $(objdir)/m2/Builtins.texi +endif $(objdir)/m2/gm2-compiler-boot: test -d $@ || mkdir $@ diff --git a/gcc/m2/config-make.in b/gcc/m2/config-make.in index c7d8641b4c7..fb25ef44c33 100644 --- a/gcc/m2/config-make.in +++ b/gcc/m2/config-make.in @@ -1,2 +1,6 @@ # Target libraries are put under this directory: TARGET_SUBDIR = @target_subdir@ +# Python3 executable name if it exists +PYTHON = @PYTHON@ +# Does Python3 exist? (yes/no). +HAVE_PYTHON = @HAVE_PYTHON@ \ No newline at end of file diff --git a/gcc/m2/configure b/gcc/m2/configure index 13d9f1f3d6f..db1ca3d1f9b 100755 --- a/gcc/m2/configure +++ b/gcc/m2/configure @@ -631,7 +631,6 @@ LDFLAGS CFLAGS CC regex_realpath -regex_flex target_os target_vendor target_cpu @@ -2236,52 +2235,6 @@ test -n "$target_alias" && NONENONEs,x,x, && program_prefix=${target_alias}- -for ac_prog in flex -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_regex_flex+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$regex_flex"; then - ac_cv_prog_regex_flex="$regex_flex" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_regex_flex="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -regex_flex=$ac_cv_prog_regex_flex -if test -n "$regex_flex"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $regex_flex" >&5 -$as_echo "$regex_flex" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$regex_flex" && break -done - -if test x$regex_flex = "x" ; then - as_fn_error $? "flex is required to build GNU Modula-2 (hint install flex)." "$LINENO" 5 -fi - for ac_prog in realpath do # Extract the first word of "$ac_prog", so it can be a program name with args. diff --git a/gcc/m2/configure.ac b/gcc/m2/configure.ac index 1c5c9f66a3c..756e01c4321 100644 --- a/gcc/m2/configure.ac +++ b/gcc/m2/configure.ac @@ -24,11 +24,6 @@ AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET -AC_CHECK_PROGS(regex_flex, flex) -if test x$regex_flex = "x" ; then - AC_MSG_ERROR([flex is required to build GNU Modula-2 (hint install flex).]) -fi - AC_CHECK_PROGS(regex_realpath, realpath) if test x$regex_realpath = "x" ; then AC_MSG_ERROR([realpath is required to build GNU Modula-2 (hint install coreutils).]) diff --git a/gcc/m2/gm2-libs-pim/README.texi b/gcc/m2/gm2-libs-pim/README.texi index 84c1d332b7e..8bf4d7b3843 100644 --- a/gcc/m2/gm2-libs-pim/README.texi +++ b/gcc/m2/gm2-libs-pim/README.texi @@ -34,11 +34,11 @@ routines are provided. Access to DOSCALL, graphics, time and date are not as these were constrained by the limitations of MS-DOS. The following libraries are contained within the base GNU Modula-2 -libraries but are also Logitech-3.0 compatible: ASCII, Storage -and MathLib0. - -@menu -* gm2-libs/ASCII::ASCII.def -* gm2-libs/Storage::Storage.def -* gm2-libs/MathLib0::MathLib0.def -@end menu +libraries and are also Logitech-3.0 compatible: @xref{gm2-libs/ASCII}, +@xref{gm2-libs/Storage} and @xref{gm2-libs/MathLib0}. These libraries +are always available for any dialect of the language (although their +implementation and behaviour might differ, for example Storage ISO and +PIM). + +The following libraries are Logitech-3.0 compatible but fall outside +the base GNU Modula-2 libraries. diff --git a/gcc/m2/tools-src/def2doc.py b/gcc/m2/tools-src/def2doc.py new file mode 100755 index 00000000000..6f8f934ee62 --- /dev/null +++ b/gcc/m2/tools-src/def2doc.py @@ -0,0 +1,444 @@ +#!/usr/bin/env python3 + +# def2texi.py creates texi library documentation for all exported procedures. +# Contributed by Gaius Mulley . + +# Copyright (C) 2000-2022 Free Software Foundation, Inc. +# This file is part of GNU Modula-2. +# +# GNU Modula-2 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, or (at your option) +# any later version. +# +# GNU Modula-2 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 GNU Modula-2; see the file COPYING. If not, write to the +# Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# + +import argparse +import os +import sys + +BaseLibs = ["gm2-libs", "Base libraries", "Basic M2F compatible libraries"] + +PIMLogDesc = "PIM and Logitech 3.0 compatible libraries" +PIMLog = ["gm2-libs-pim", "PIM and Logitech 3.0 Compatible", PIMLogDesc] +PIMCorDesc = "PIM compatible process support" +PIMCor = ["gm2-libs-coroutines", "PIM coroutine support", PIMCorDesc] +ISOLibs = ["gm2-libs-iso", "M2 ISO Libraries", "ISO defined libraries"] + +libraryClassifications = [BaseLibs, PIMLog, PIMCor, ISOLibs] + + +def initState(): + global inVar, inType, inConst + inVar, inType, inConst = False, False, False + + +def emitNode(name, nxt, previous, up): + if args.texinfo: + output.write("@node " + name + ", " + nxt + ", ") + output.write(previous + ", " + up + "\n") + elif args.sphinx: + output.write("@c @node " + name + ", " + nxt + ", ") + output.write(previous + ", " + up + "\n") + + +def emitSection(name): + if args.texinfo: + output.write("@section " + name + "\n") + elif args.sphinx: + output.write(name + "\n") + output.write("=" * len(name) + "\n") + + +def emitSubSection(name): + if args.texinfo: + output.write("@subsection " + name + "\n") + elif args.sphinx: + output.write(name + "\n") + output.write("=" * len(name) + "\n") + + +# displayLibraryClass - displays a node for a library directory and invokes +# a routine to summarize each module. + +def displayLibraryClass(): + global args + previous = "" + + nxt = libraryClassifications[1][1] + i = 0 + lib = libraryClassifications[i] + + while True: + emitNode(lib[1], nxt, previous, args.up) + emitSection(lib[1]) + output.write("\n") + displayModules(lib[1], lib[0], args.builddir, args.sourcedir) + output.write("\n") + output.write("@c " + "-" * 60 + "\n") + previous = lib[1] + i += 1 + if i == len(libraryClassifications): + break + lib = libraryClassifications[i] + if i+1 == len(libraryClassifications): + nxt = "" + else: + nxt = libraryClassifications[i+1][1] + + +# displayMenu - displays the top level menu for library documentation. + +def displayMenu(): + output.write("@menu\n") + for lib in libraryClassifications: + output.write("* " + lib[1] + "::" + lib[2] + "\n") + output.write("@end menu\n") + + output.write("\n") + output.write("@c " + "=" * 60 + "\n") + output.write("\n") + + +# removeInitialComments - removes any (* *) at the top +# of the definition module. + +def removeInitialComments(file, line): + while (str.find(line, "*)") == -1): + line = file.readline() + + +# removeableField - returns True if a comment field should be removed +# from the definition module. + +def removeableField(line): + field_list = ["Author", "Last edit", "LastEdit", "Last update", + "Date", "Title", "Revision"] + for field in field_list: + if (str.find(line, field) != -1) and (str.find(line, ":") != -1): + return True + ignore_list = ["System", "SYSTEM"] + for ignore_field in ignore_list: + if str.find(line, ignore_field) != -1: + if str.find(line, ":") != -1: + if str.find(line, "Description:") == -1: + return True + return False + + +# removeFields - removes Author/Date/Last edit/SYSTEM/Revision +# fields from a comment within the start of a +# definition module. + +def removeFields(file, line): + while (str.find(line, "*)") == -1): + if not removeableField(line): + output.write(str.replace(str.replace(str.rstrip(line), + "{", "@{"), "}", "@}") + "\n") + line = file.readline() + output.write(str.rstrip(line) + "\n") + + +# checkIndex - create an index entry for a PROCEDURE, TYPE, CONST or VAR. + +def checkIndex(line): + global inVar, inType, inConst + + words = str.split(line) + procedure = "" + if (len(words) > 1) and (words[0] == "PROCEDURE"): + inConst = False + inType = False + inVar = False + if (words[1] == "__BUILTIN__") and (len(words) > 2): + procedure = words[2] + else: + procedure = words[1] + + if (len(line) > 1) and (line[0:2] == "(*"): + inConst = False + inType = False + inVar = False + elif line == "VAR": + inConst = False + inVar = True + inType = False + return + elif line == "TYPE": + inConst = False + inType = True + inVar = False + return + elif line == "CONST": + inConst = True + inType = False + inVar = False + if inVar: + words = str.split(line, ",") + for word in words: + word = str.lstrip(word) + if word != "": + if str.find(word, ":") == -1: + output.write("@findex " + word + " (var)\n") + elif len(word) > 0: + var = str.split(word, ":") + if len(var) > 0: + output.write("@findex " + var[0] + " (var)\n") + + if inType: + words = str.lstrip(line) + if str.find(words, "=") != -1: + word = str.split(words, "=") + if (len(word[0]) > 0) and (word[0][0] != "_"): + output.write("@findex " + str.rstrip(word[0]) + " (type)\n") + else: + word = str.split(words) + if (len(word) > 1) and (word[1] == ";"): + # hidden type + if (len(word[0]) > 0) and (word[0][0] != "_"): + output.write("@findex " + str.rstrip(word[0])) + output.write(" (type)\n") + + if inConst: + words = str.split(line, ";") + for word in words: + word = str.lstrip(word) + if word != "": + if str.find(word, "=") != -1: + var = str.split(word, "=") + if len(var) > 0: + output.write("@findex " + var[0] + " (const)\n") + + if procedure != "": + name = str.split(procedure, "(") + if name[0] != "": + proc = name[0] + if proc[-1] == ";": + proc = proc[:-1] + if proc != "": + output.write("@findex " + proc + "\n") + + +# parseDefinition - reads a definition module and creates +# indices for procedures, constants, +# variables and types. + +def parseDefinition(dir, source, build, file, needPage): + output.write("\n") + f = open(findFile(dir, build, source, file), "r") + initState() + line = f.readline() + while (str.find(line, "(*") != -1): + removeInitialComments(f, line) + line = f.readline() + + while (str.find(line, "DEFINITION") == -1): + line = f.readline() + + output.write("@example\n") + output.write(str.rstrip(line) + "\n") + line = f.readline() + if len(str.rstrip(line)) == 0: + output.write(str.replace(str.replace(str.rstrip(line), + "{", "@{"), "}", "@}") + "\n") + line = f.readline() + if (str.find(line, "(*") != -1): + removeFields(f, line) + else: + output.write(str.rstrip(line) + "\n") + else: + output.write(str.rstrip(line) + "\n") + + line = f.readline() + while line: + line = str.rstrip(line) + checkIndex(line) + output.write(str.replace(str.replace(line, "{", "@{"), "}", "@}")) + output.write("\n") + line = f.readline() + output.write("@end example\n") + if needPage: + output.write("@page\n") + f.close() + + +def parseModules(up, dir, build, source, listOfModules): + previous = "" + i = 0 + if len(listOfModules) > 1: + nxt = dir + "/" + listOfModules[1][:-4] + else: + nxt = "" + while i < len(listOfModules): + emitNode(dir + "/" + listOfModules[i][:-4], nxt, previous, up) + emitSubSection(dir + "/" + listOfModules[i][:-4]) + parseDefinition(dir, source, build, listOfModules[i], True) + output.write("\n") + previous = dir + "/" + listOfModules[i][:-4] + i = i + 1 + if i+1 < len(listOfModules): + nxt = dir + "/" + listOfModules[i+1][:-4] + else: + nxt = "" + + +# doCat - displays the contents of file, name, to stdout + +def doCat(name): + file = open(name, "r") + line = file.readline() + while line: + output.write(str.rstrip(line) + "\n") + line = file.readline() + file.close() + + +# moduleMenu - generates a simple menu for all definition modules +# in dir + +def moduleMenu(dir, build, source): + output.write("@menu\n") + listOfFiles = [] + if os.path.exists(os.path.join(source, dir)): + listOfFiles += os.listdir(os.path.join(source, dir)) + if os.path.exists(os.path.join(source, dir)): + listOfFiles += os.listdir(os.path.join(build, dir)) + listOfFiles = list(dict.fromkeys(listOfFiles).keys()) + listOfFiles.sort() + for file in listOfFiles: + if foundFile(dir, build, source, file): + if (len(file) > 4) and (file[-4:] == ".def"): + output.write("* " + dir + "/" + file[:-4] + "::" + file + "\n") + output.write("@end menu\n") + output.write("\n") + + +# checkDirectory - returns True if dir exists in either build or source. + +def checkDirectory(dir, build, source): + if os.path.isdir(build) and os.path.exists(os.path.join(build, dir)): + return True + elif os.path.isdir(source) and os.path.exists(os.path.join(source, dir)): + return True + else: + return False + + +# foundFile - return True if file is found in build/dir/file or +# source/dir/file. + +def foundFile(dir, build, source, file): + name = os.path.join(os.path.join(build, dir), file) + if os.path.exists(name): + return True + name = os.path.join(os.path.join(source, dir), file) + if os.path.exists(name): + return True + return False + + +# findFile - return the path to file searching in build/dir/file +# first then source/dir/file. + +def findFile(dir, build, source, file): + name1 = os.path.join(os.path.join(build, dir), file) + if os.path.exists(name1): + return name1 + name2 = os.path.join(os.path.join(source, dir), file) + if os.path.exists(name2): + return name2 + sys.stderr.write("file cannot be found in either " + name1) + sys.stderr.write(" or " + name2 + "\n") + os.sys.exit(1) + + +# displayModules - walks though the files in dir and parses +# definition modules and includes README.texi + +def displayModules(up, dir, build, source): + if checkDirectory(dir, build, source): + if foundFile(dir, build, source, "README.texi"): + doCat(findFile(dir, build, source, "README.texi")) + + moduleMenu(dir, build, source) + listOfFiles = [] + if os.path.exists(os.path.join(source, dir)): + listOfFiles += os.listdir(os.path.join(source, dir)) + if os.path.exists(os.path.join(source, dir)): + listOfFiles += os.listdir(os.path.join(build, dir)) + listOfFiles = list(dict.fromkeys(listOfFiles).keys()) + listOfFiles.sort() + listOfModules = [] + for file in listOfFiles: + if foundFile(dir, build, source, file): + if (len(file) > 4) and (file[-4:] == ".def"): + listOfModules += [file] + listOfModules.sort() + parseModules(up, dir, build, source, listOfModules) + else: + line = "directory " + dir + " not found in either " + line += build + " or " + source + sys.stderr.write(line + "\n") + + +def displayCopyright(): + output.write("@c Copyright (C) 2000-2022 Free Software Foundation, Inc.\n") + output.write("@c This file is part of GNU Modula-2.\n") + output.write(""" +@c Permission is granted to copy, distribute and/or modify this document +@c under the terms of the GNU Free Documentation License, Version 1.2 or +@c any later version published by the Free Software Foundation. +""") + + +def collectArgs(): + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--verbose", help="generate progress messages", + action="store_true") + parser.add_argument("-b", "--builddir", help="set the build directory", + default=".", action="store") + parser.add_argument("-f", "--inputfile", help="set the input file", + default=None, action="store") + parser.add_argument("-o", "--outputfile", help="set the output file", + default=None, action="store") + parser.add_argument("-s", "--sourcedir", help="set the source directory", + default=".", action="store") + parser.add_argument("-t", "--texinfo", + help="generate texinfo documentation", + default=False, action="store_true") + parser.add_argument("-u", "--up", help="set the up node", + default="", action="store") + parser.add_argument("-x", "--sphinx", help="generate sphinx documentation", + default=False, action="store_true") + args = parser.parse_args() + return args + + +def main(): + global args, output + args = collectArgs() + if args.outputfile is None: + output = sys.stdout + else: + output = open(args.outputfile, "w") + if args.inputfile is None: + displayCopyright() + displayMenu() + displayLibraryClass() + else: + parseDefinition(".", args.sourcedir, args.builddir, + args.inputfile, False) + if not (args.outputfile is None): + output.close() + + +main() diff --git a/gcc/m2/tools-src/def2texi.py b/gcc/m2/tools-src/def2texi.py deleted file mode 100755 index 1d1040f5006..00000000000 --- a/gcc/m2/tools-src/def2texi.py +++ /dev/null @@ -1,423 +0,0 @@ -#!/usr/bin/env python3 - -# def2texi.py creates texi library documentation for all exported procedures. -# Contributed by Gaius Mulley . - -# Copyright (C) 2000-2022 Free Software Foundation, Inc. -# This file is part of GNU Modula-2. -# -# GNU Modula-2 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, or (at your option) -# any later version. -# -# GNU Modula-2 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 GNU Modula-2; see the file COPYING. If not, write to the -# Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. -# - -import sys -import os -import glob -import getopt - -libraryClassifications = [['gm2-libs','Base libraries', - 'Basic M2F compatible libraries'], - ['gm2-libs-pim','PIM and Logitech 3.0 Compatible', - 'PIM and Logitech 3.0 compatible libraries'], - ['gm2-libs-coroutines','PIM coroutine support', - 'PIM compatible process support'], - ['gm2-libs-iso','M2 ISO Libraries', - 'ISO defined libraries']] - -def initState (): - global inVar, inType, inConst - inVar, inType, inConst = False, False, False - - -# -# displayLibraryClass - displays a node for a library directory and invokes -# a routine to summarize each module -# - -def displayLibraryClass(): - global buildDir, up - previous = "" - - next=libraryClassifications[1][1] - i = 0 - l = libraryClassifications[i] - - while True: - print("@node " + l[1] + ", " + next + ", " + previous + ", " + up) - print("@section " + l[1]) - print("") - displayModules(l[1], l[0], buildDir, sourceDir) - print("") - print("@c ---------------------------------------------------------------------") - previous = l[1] - i += 1 - if i == len(libraryClassifications): - break - l = libraryClassifications[i] - if i+1 == len(libraryClassifications): - next = "" - else: - next = libraryClassifications[i+1][1] - -# -# displayMenu - displays the top level menu for library documentation -# - -def displayMenu(): - print("@menu") - for l in libraryClassifications: - print("* " + l[1] + "::" + l[2]) - print("@end menu") - - print("\n") - print("@c =====================================================================") - print("\n") - - -# -# removeInitialComments - removes any (* *) at the top of the definition module -# - -def removeInitialComments (file, line): - while (str.find(line, "*)") == -1): - line = file.readline() - -# -# removeFields - removes Author/Date/Last edit/SYSTEM/Revision fields from a comment within the start -# of a definition module -# - -def removeFields (file, line): - while (str.find(line, "*)") == -1): - if (str.find(line, "Author") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "Last edit") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "LastEdit") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "Last update") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "Date") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "Title") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "Revision") != -1) and (str.find(line, ":") != -1): - line = file.readline() - elif (str.find(line, "System") != -1) and (str.find(line, ":") != -1) and (str.find(line, "Description:") == -1): - line = file.readline() - elif (str.find(line, "SYSTEM") != -1) and (str.find(line, ":") != -1) and (str.find(line, "Description:") == -1): - line = file.readline() - else: - print(str.replace(str.replace(str.rstrip(line), - "{", "@{"), "}", "@}")) - line = file.readline() - print(str.rstrip(line)) - - -# -# checkIndex -# - -def checkIndex (line): - global inVar, inType, inConst - - words = str.split(line) - procedure = "" - if (len(words)>1) and (words[0] == "PROCEDURE"): - inConst = False - inType = False - inVar = False - if (words[1] == "__BUILTIN__") and (len(words)>2): - procedure = words[2] - else: - procedure = words[1] - - if (len(line)>1) and (line[0:2] == '(*'): - inConst = False - inType = False - inVar = False - elif line == "VAR": - inConst = False - inVar = True - inType = False - return - elif line == "TYPE": - inConst = False - inType = True - inVar = False - return - elif line == "CONST": - inConst = True - inType = False - inVar = False - - if inVar: - words = str.split(line, ',') - for word in words: - word = str.lstrip(word) - if word != "": - if str.find(word, ':') == -1: - print("@findex " + word + " (var)") - elif len(word)>0: - var = str.split(word, ':') - if len(var)>0: - print("@findex " + var[0] + " (var)") - - if inType: - words = str.lstrip(line) - if str.find(words, '=') != -1: - word = str.split(words, "=") - if (len(word[0])>0) and (word[0][0] != '_'): - print("@findex " + str.rstrip(word[0]) + " (type)") - else: - word = str.split(words) - if (len(word)>1) and (word[1] == ';'): - # hidden type - if (len(word[0])>0) and (word[0][0] != '_'): - print("@findex " + str.rstrip(word[0]) + " (type)") - - if inConst: - words = str.split(line, ';') - for word in words: - word = str.lstrip(word) - if word != "": - if str.find(word, '=') != -1: - var = str.split(word, '=') - if len(var)>0: - print("@findex " + var[0] + " (const)") - - if procedure != "": - name = str.split(procedure, "(") - if name[0] != "": - proc = name[0] - if proc[-1] == ";": - proc = proc[:-1] - if proc != "": - print("@findex " + proc) - - -# -# parseDefinition -# - -def parseDefinition (dir, source, build, file, needPage): - print("") - f = open(findFile(dir, build, source, file), 'r') - initState() - line = f.readline() -# while (str.find(line, "(*") != -1): - while (str.find(line, "(*") != -1): - removeInitialComments(f, line) - line = f.readline() - - while (str.find(line, "DEFINITION") == -1): - line = f.readline() - - print("@example") - print(str.rstrip(line)) - line = f.readline() - if len(str.rstrip(line)) == 0: - print(str.replace(str.replace(str.rstrip(line), - "{", "@{"), "}", "@}")) - line = f.readline() - if (str.find(line, "(*") != -1): - removeFields(f, line) - else: - print(str.rstrip(line)) - else: - print(str.rstrip(line)) - - line = f.readline() - while line: - line = str.rstrip(line) - checkIndex(line) - print(str.replace(str.replace(line, "{", "@{"), "}", "@}")) - line = f.readline() - print("@end example") - if needPage: - print("@page") - f.close() - -def parseModules (up, dir, build, source, listOfModules): - previous = "" - i = 0 - if len(listOfModules)>1: - next = dir + "/" + listOfModules[1][:-4] - else: - next = "" - - while i4) and (file[-4:] == '.def'): - print("* " + dir + "/" + file[:-4] + "::" + file) - print("@end menu") - print("\n") - - -# -# checkDirectory - returns True if dir exists in either build or source. -# - -def checkDirectory (dir, build, source): - if os.path.isdir(build) and os.path.exists(os.path.join(build, dir)): - return True - elif os.path.isdir(source) and os.path.exists(os.path.join(source, dir)): - return True - else: - return False - - -# -# foundFile - return True if file is found in build/dir/file or source/dir/file. -# - -def foundFile (dir, build, source, file): - name = os.path.join(os.path.join(build, dir), file) - if os.path.exists(name): - return True - name = os.path.join(os.path.join(source, dir), file) - if os.path.exists(name): - return True - return False - - -# -# findFile - return the path to file searching in build/dir/file first then source/dir/file. -# - -def findFile (dir, build, source, file): - name1 = os.path.join(os.path.join(build, dir), file) - if os.path.exists(name1): - return name1 - name2 = os.path.join(os.path.join(source, dir), file) - if os.path.exists(name2): - return name2 - print("file cannot be found in either " + name1 + " or " + name2) - os.sys.exit(1) - - -# -# displayModules - walks though the files in dir and parses -# definition modules and includes README.texi -# - -def displayModules(up, dir, build, source): - if checkDirectory(dir, build, source): - if foundFile(dir, build, source, "README.texi"): - doCat(findFile(dir, build, source, "README.texi")) - - moduleMenu(dir, build, source) - listOfFiles = [] - if os.path.exists(os.path.join(source, dir)): - listOfFiles += os.listdir(os.path.join(source, dir)) - if os.path.exists(os.path.join(source, dir)): - listOfFiles += os.listdir(os.path.join(build, dir)) - listOfFiles = list(dict.fromkeys(listOfFiles).keys()) - listOfFiles.sort() - listOfModules = [] - for file in listOfFiles: - if foundFile(dir, build, source, file): - if (len(file)>4) and (file[-4:] == '.def'): - listOfModules += [file] - listOfModules.sort() - parseModules(up, dir, build, source, listOfModules) - else: - print("directory " + dir + " not found in either " + build + " or " + source) - - -def displayCopyright (): - print("@c Copyright (C) 2000-2022 Free Software Foundation, Inc.") - print("@c This file is part of GNU Modula-2.") - print(""" -@c Permission is granted to copy, distribute and/or modify this document -@c under the terms of the GNU Free Documentation License, Version 1.2 or -@c any later version published by the Free Software Foundation. -""") - -def Usage(): - print("def2texi.py [-h][-bbuilddir][-uupnode][-ffilename]") - -def collectArgs(): - buildDir="." - sourceDir="." - filename="" - up="" - try: - optlist, list = getopt.getopt(sys.argv[1:],':hb:f:s:u:') - except getopt.GetoptError: - Usage() - os.sys.exit(1) - for opt in optlist: - if opt[0] == '-h': - Usage() - if opt[0] == '-b': - buildDir = opt[1] - if opt[0] == '-f': - filename = opt[1] - if opt[0] == '-s': - sourceDir = opt[1] - if opt[0] == '-u': - up = opt[1] - return buildDir, sourceDir, filename, up - - -buildDir, sourceDir, filename, up = collectArgs() - -if filename == "": - displayCopyright() - displayMenu() - displayLibraryClass() -else: - parseDefinition('.', sourceDir, buildDir, filename, False) diff --git a/libgm2/configure b/libgm2/configure index 5949e87eb4e..889c0926a15 100755 --- a/libgm2/configure +++ b/libgm2/configure @@ -7687,6 +7687,11 @@ sysv4 | sysv4.3*) tpf*) lt_cv_deplibs_check_method=pass_all ;; +vxworks*) + # Assume VxWorks cross toolchains are built on Linux, possibly + # as canadian for Windows hosts. + lt_cv_deplibs_check_method=pass_all + ;; esac fi @@ -12218,6 +12223,25 @@ uts4*) shlibpath_var=LD_LIBRARY_PATH ;; +# Shared libraries for VwWorks, >= 7 only at this stage +# and (fpic) still incompatible with "large" code models +# in a few configurations. Only for RTP mode in any case, +# and upon explicit request at configure time. +vxworks7*) + dynamic_linker=no + case ${with_multisubdir}-${enable_shared} in + *large*) + ;; + *mrtp*-yes) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker="$host_os module_loader" + ;; + esac + ;; *) dynamic_linker=no ;; @@ -12674,7 +12698,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12677 "configure" +#line 12701 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12780,7 +12804,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12783 "configure" +#line 12807 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14345,8 +14369,9 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ;; vxworks*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no + # For VxWorks ports, we assume the use of a GNU linker with + # standard elf conventions. + ld_shlibs_CXX=yes ;; *) @@ -15897,6 +15922,25 @@ uts4*) shlibpath_var=LD_LIBRARY_PATH ;; +# Shared libraries for VwWorks, >= 7 only at this stage +# and (fpic) still incompatible with "large" code models +# in a few configurations. Only for RTP mode in any case, +# and upon explicit request at configure time. +vxworks7*) + dynamic_linker=no + case ${with_multisubdir}-${enable_shared} in + *large*) + ;; + *mrtp*-yes) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker="$host_os module_loader" + ;; + esac + ;; *) dynamic_linker=no ;;