diff options
Diffstat (limited to 'REORG.TODO/scripts')
47 files changed, 9393 insertions, 0 deletions
diff --git a/REORG.TODO/scripts/abi-versions.awk b/REORG.TODO/scripts/abi-versions.awk new file mode 100644 index 0000000000..c369793459 --- /dev/null +++ b/REORG.TODO/scripts/abi-versions.awk @@ -0,0 +1,46 @@ +# Script to generate <abi-versions.h> header file from Versions.all list. +# See include/shlib-compat.h comments for explanation. + +BEGIN { + print "/* This file is automatically generated by abi-versions.awk."; + print " It defines symbols used by shlib-compat.h, which see. */"; + print "\n#ifndef _ABI_VERSIONS_H\n#define _ABI_VERSIONS_H"; +} + +NF == 2 && $2 == "{" { + thislib = $1; + gsub(/[^A-Za-z0-9_ ]/, "_"); libid = $1; + printf "\n/* start %s */\n", thislib; + n = 0; + start = 0; + next; +} +$1 == "}" { + printf "/* end %s */\n", thislib; + next; +} + +$2 == "=" { + old = $1; new = $3; + gsub(/[^A-Za-z0-9_ ]/, "_"); + oldid = $1; newid = $3; + + printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid; + printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new; + + next; +} + +{ + vers = $1; + gsub(/[^A-Za-z0-9_ ]/, "_"); + versid = $1; + + printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers; + printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers; + next; +} + +END { + print "\n#endif /* abi-versions.h */"; +} diff --git a/REORG.TODO/scripts/abilist.awk b/REORG.TODO/scripts/abilist.awk new file mode 100644 index 0000000000..bd740d4693 --- /dev/null +++ b/REORG.TODO/scripts/abilist.awk @@ -0,0 +1,146 @@ +# This awk script processes the output of objdump --dynamic-syms +# into a simple format that should not change when the ABI is not changing. + +BEGIN { + if (combine_fullname) + combine = 1; + if (combine) + parse_names = 1; +} + +# Per-file header. +/[^ :]+\.so\.[0-9.]+:[ ]+.file format .*$/ { + emit(0); + + seen_opd = 0; + + sofullname = $1; + sub(/:$/, "", sofullname); + soname = sofullname; + sub(/^.*\//, "", soname); + sub(/\.so\.[0-9.]+$/, "", soname); + + suppress = ((filename_regexp != "" && sofullname !~ filename_regexp) \ + || (libname_regexp != "" && soname !~ libname_regexp)); + + next +} + +suppress { next } + +# Normalize columns. +/^[0-9a-fA-F]+ / { sub(/ /, " - ") } + +# Skip undefineds. +$4 == "*UND*" { next } + +# Skip locals. +$2 == "l" { next } + +# If the target uses ST_OTHER, it will be output before the symbol name. +$2 == "g" || $2 == "w" && (NF == 7 || NF == 8) { + weak = $2; + type = $3; + size = $5; + sub(/^0*/, "", size); + size = " 0x" size; + version = $6; + symbol = $NF; + gsub(/[()]/, "", version); + + # binutils versions up through at least 2.23 have some bugs that + # caused STV_HIDDEN symbols to appear in .dynsym, though that is useless. + if (NF > 7 && $7 == ".hidden") next; + + if (version == "GLIBC_PRIVATE") next; + + desc = ""; + if (type == "D" && $4 == ".tbss") { + type = "T"; + } + else if (type == "D" && $4 == ".opd") { + type = "F"; + size = ""; + if (seen_opd < 0) + type = "O"; + seen_opd = 1; + } + else if (type == "D" && NF == 8 && $7 == "0x80") { + # Alpha functions avoiding plt entry in users + type = "F"; + size = ""; + seen_opd = -1; + } + else if ($4 == "*ABS*") { + type = "A"; + size = ""; + } + else if (type == "DO") { + type = "D"; + } + else if (type == "DF") { + if (symbol ~ /^\./ && seen_opd >= 0) + next; + seen_opd = -1; + type = "F"; + size = ""; + } + else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) { + # Indirect functions. + type = "F"; + size = ""; + } + else { + desc = symbol " " version " " weak " ? " type " " $4 " " $5; + } + if (size == " 0x") { + desc = symbol " " version " " weak " ? " type " " $4 " " $5; + } + + # Disabled -- weakness should not matter to shared library ABIs any more. + #if (weak == "w") type = tolower(type); + if (desc == "") + desc = symbol " " type size; + + if (combine) + version = soname " " version (combine_fullname ? " " sofullname : ""); + + # Append to the string which collects the results. + descs = descs version " " desc "\n"; + next; +} + +# Header crapola. +NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next } + +{ + print "Don't grok this line:", $0 +} + +function emit(end) { + if (!end && (combine || ! parse_names || soname == "")) + return; + tofile = parse_names && !combine; + + if (tofile) { + out = prefix soname ".symlist"; + if (soname in outfiles) + out = out "." ++outfiles[soname]; + else + outfiles[soname] = 1; + outpipe = "LC_ALL=C sort -u > " out; + } else { + outpipe = "LC_ALL=C sort -u"; + } + + printf "%s", descs | outpipe; + + descs = ""; + + if (tofile) + print "wrote", out, "for", sofullname; +} + +END { + emit(1); +} diff --git a/REORG.TODO/scripts/backport-support.sh b/REORG.TODO/scripts/backport-support.sh new file mode 100644 index 0000000000..2ece7ce575 --- /dev/null +++ b/REORG.TODO/scripts/backport-support.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# Create a patch which backports the support/ subdirectory. +# Copyright (C) 2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# This script does not backport the Makefile tweaks outside the +# support/ directory (which need to be backported separately), or the +# changes to test-skeleton.c (which should not be backported). + +set -e + +export LC_ALL=C +export GIT_CONFIG=/dev/null +export GTT_CONFIG_NOSYSTEM=0 +export GIT_PAGER= + +usage () { + cat >&2 <<EOF +usage: $0 {patch|commit} +EOF + exit 1 +} + +if test $# -ne 1 ; then + usage +fi + +command="$1" + +case "$command" in + patch|commit) + ;; + *) + usage + ;; +esac + +# The upstream branch to work on. +branch=origin/master + +# The commit which added the support/ directory. +initial_commit=c23de0aacbeaa7a091609b35764bed931475a16d + +# We backport the support directory and this script. Directories need +# to end in a /. +patch_targets="support/ scripts/backport-support.sh" + +latest_commit="$(git log --max-count=1 --pretty=format:%H "$branch" -- \ + $patch_targets)" + +# Simplify the branch name somewhat for reporting. +branch_name="$(echo "$branch" | sed s,^origin/,,)" + +command_patch () { + cat <<EOF +This patch creates the contents of the support/ directory up to this +upstream commit on the $branch_name branch: + +EOF + git log --max-count=1 "$latest_commit" + echo + git diff "$initial_commit"^.."$latest_commit" $patch_targets + echo "# Before applying the patch, run this command:" >&2 + echo "# rm -rf $patch_targets" >&2 +} + +command_commit () { + git status --porcelain | while read line ; do + echo "error: working copy is not clean, cannot commit" >&2 + exit 1 + done + for path in $patch_targets; do + echo "# Processing $path" >&2 + case "$path" in + [a-zA-Z0-9]*/) + # Directory. + git rm --cached --ignore-unmatch -r "$path" + rm -rf "$path" + git read-tree --prefix="$path" "$latest_commit":"$path" + git checkout "$path" + ;; + *) + # File. + git show "$latest_commit":"$path" > "$path" + git add "$path" + esac + done + git commit -m "Synchronize support/ infrastructure with $branch_name + +This commit updates the support/ subdirectory to +commit $latest_commit +on the $branch_name branch. +" +} + +command_$command diff --git a/REORG.TODO/scripts/build-many-glibcs.py b/REORG.TODO/scripts/build-many-glibcs.py new file mode 100755 index 0000000000..1a32c82dff --- /dev/null +++ b/REORG.TODO/scripts/build-many-glibcs.py @@ -0,0 +1,1573 @@ +#!/usr/bin/python3 +# Build many configurations of glibc. +# Copyright (C) 2016-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +"""Build many configurations of glibc. + +This script takes as arguments a directory name (containing a src +subdirectory with sources of the relevant toolchain components) and a +description of what to do: 'checkout', to check out sources into that +directory, 'bot-cycle', to run a series of checkout and build steps, +'bot', to run 'bot-cycle' repeatedly, 'host-libraries', to build +libraries required by the toolchain, 'compilers', to build +cross-compilers for various configurations, or 'glibcs', to build +glibc for various configurations and run the compilation parts of the +testsuite. Subsequent arguments name the versions of components to +check out (<component>-<version), for 'checkout', or, for actions +other than 'checkout' and 'bot-cycle', name configurations for which +compilers or glibc are to be built. + +""" + +import argparse +import datetime +import email.mime.text +import email.utils +import json +import os +import re +import shutil +import smtplib +import stat +import subprocess +import sys +import time +import urllib.request + +try: + os.cpu_count +except: + import multiprocessing + os.cpu_count = lambda: multiprocessing.cpu_count() + +try: + re.fullmatch +except: + re.fullmatch = lambda p,s,f=0: re.match(p+"\\Z",s,f) + +try: + subprocess.run +except: + class _CompletedProcess: + def __init__(self, args, returncode, stdout=None, stderr=None): + self.args = args + self.returncode = returncode + self.stdout = stdout + self.stderr = stderr + + def _run(*popenargs, input=None, timeout=None, check=False, **kwargs): + assert(timeout is None) + with subprocess.Popen(*popenargs, **kwargs) as process: + try: + stdout, stderr = process.communicate(input) + except: + process.kill() + process.wait() + raise + returncode = process.poll() + if check and returncode: + raise subprocess.CalledProcessError(returncode, popenargs) + return _CompletedProcess(popenargs, returncode, stdout, stderr) + + subprocess.run = _run + + +class Context(object): + """The global state associated with builds in a given directory.""" + + def __init__(self, topdir, parallelism, keep, replace_sources, strip, + action): + """Initialize the context.""" + self.topdir = topdir + self.parallelism = parallelism + self.keep = keep + self.replace_sources = replace_sources + self.strip = strip + self.srcdir = os.path.join(topdir, 'src') + self.versions_json = os.path.join(self.srcdir, 'versions.json') + self.build_state_json = os.path.join(topdir, 'build-state.json') + self.bot_config_json = os.path.join(topdir, 'bot-config.json') + self.installdir = os.path.join(topdir, 'install') + self.host_libraries_installdir = os.path.join(self.installdir, + 'host-libraries') + self.builddir = os.path.join(topdir, 'build') + self.logsdir = os.path.join(topdir, 'logs') + self.logsdir_old = os.path.join(topdir, 'logs-old') + self.makefile = os.path.join(self.builddir, 'Makefile') + self.wrapper = os.path.join(self.builddir, 'wrapper') + self.save_logs = os.path.join(self.builddir, 'save-logs') + self.script_text = self.get_script_text() + if action != 'checkout': + self.build_triplet = self.get_build_triplet() + self.glibc_version = self.get_glibc_version() + self.configs = {} + self.glibc_configs = {} + self.makefile_pieces = ['.PHONY: all\n'] + self.add_all_configs() + self.load_versions_json() + self.load_build_state_json() + self.status_log_list = [] + self.email_warning = False + + def get_script_text(self): + """Return the text of this script.""" + with open(sys.argv[0], 'r') as f: + return f.read() + + def exec_self(self): + """Re-execute this script with the same arguments.""" + sys.stdout.flush() + os.execv(sys.executable, [sys.executable] + sys.argv) + + def get_build_triplet(self): + """Determine the build triplet with config.guess.""" + config_guess = os.path.join(self.component_srcdir('gcc'), + 'config.guess') + cg_out = subprocess.run([config_guess], stdout=subprocess.PIPE, + check=True, universal_newlines=True).stdout + return cg_out.rstrip() + + def get_glibc_version(self): + """Determine the glibc version number (major.minor).""" + version_h = os.path.join(self.component_srcdir('glibc'), 'version.h') + with open(version_h, 'r') as f: + lines = f.readlines() + starttext = '#define VERSION "' + for l in lines: + if l.startswith(starttext): + l = l[len(starttext):] + l = l.rstrip('"\n') + m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l) + return '%s.%s' % m.group(1, 2) + print('error: could not determine glibc version') + exit(1) + + def add_all_configs(self): + """Add all known glibc build configurations.""" + self.add_config(arch='aarch64', + os_name='linux-gnu') + self.add_config(arch='aarch64_be', + os_name='linux-gnu') + self.add_config(arch='alpha', + os_name='linux-gnu') + self.add_config(arch='arm', + os_name='linux-gnueabi') + self.add_config(arch='armeb', + os_name='linux-gnueabi') + self.add_config(arch='armeb', + os_name='linux-gnueabi', + variant='be8', + gcc_cfg=['--with-arch=armv7-a']) + self.add_config(arch='arm', + os_name='linux-gnueabihf') + self.add_config(arch='armeb', + os_name='linux-gnueabihf') + self.add_config(arch='armeb', + os_name='linux-gnueabihf', + variant='be8', + gcc_cfg=['--with-arch=armv7-a']) + self.add_config(arch='hppa', + os_name='linux-gnu') + self.add_config(arch='ia64', + os_name='linux-gnu', + first_gcc_cfg=['--with-system-libunwind']) + self.add_config(arch='m68k', + os_name='linux-gnu', + gcc_cfg=['--disable-multilib']) + self.add_config(arch='m68k', + os_name='linux-gnu', + variant='coldfire', + gcc_cfg=['--with-arch=cf', '--disable-multilib']) + self.add_config(arch='microblaze', + os_name='linux-gnu', + gcc_cfg=['--disable-multilib']) + self.add_config(arch='microblazeel', + os_name='linux-gnu', + gcc_cfg=['--disable-multilib']) + self.add_config(arch='mips64', + os_name='linux-gnu', + gcc_cfg=['--with-mips-plt'], + glibcs=[{'variant': 'n32'}, + {'arch': 'mips', + 'ccopts': '-mabi=32'}, + {'variant': 'n64', + 'ccopts': '-mabi=64'}]) + self.add_config(arch='mips64', + os_name='linux-gnu', + variant='soft', + gcc_cfg=['--with-mips-plt', '--with-float=soft'], + glibcs=[{'variant': 'n32-soft', + 'cfg': ['--without-fp']}, + {'variant': 'soft', + 'arch': 'mips', + 'ccopts': '-mabi=32', + 'cfg': ['--without-fp']}, + {'variant': 'n64-soft', + 'ccopts': '-mabi=64', + 'cfg': ['--without-fp']}]) + self.add_config(arch='mips64', + os_name='linux-gnu', + variant='nan2008', + gcc_cfg=['--with-mips-plt', '--with-nan=2008', + '--with-arch-64=mips64r2', + '--with-arch-32=mips32r2'], + glibcs=[{'variant': 'n32-nan2008'}, + {'variant': 'nan2008', + 'arch': 'mips', + 'ccopts': '-mabi=32'}, + {'variant': 'n64-nan2008', + 'ccopts': '-mabi=64'}]) + self.add_config(arch='mips64', + os_name='linux-gnu', + variant='nan2008-soft', + gcc_cfg=['--with-mips-plt', '--with-nan=2008', + '--with-arch-64=mips64r2', + '--with-arch-32=mips32r2', + '--with-float=soft'], + glibcs=[{'variant': 'n32-nan2008-soft', + 'cfg': ['--without-fp']}, + {'variant': 'nan2008-soft', + 'arch': 'mips', + 'ccopts': '-mabi=32', + 'cfg': ['--without-fp']}, + {'variant': 'n64-nan2008-soft', + 'ccopts': '-mabi=64', + 'cfg': ['--without-fp']}]) + self.add_config(arch='mips64el', + os_name='linux-gnu', + gcc_cfg=['--with-mips-plt'], + glibcs=[{'variant': 'n32'}, + {'arch': 'mipsel', + 'ccopts': '-mabi=32'}, + {'variant': 'n64', + 'ccopts': '-mabi=64'}]) + self.add_config(arch='mips64el', + os_name='linux-gnu', + variant='soft', + gcc_cfg=['--with-mips-plt', '--with-float=soft'], + glibcs=[{'variant': 'n32-soft', + 'cfg': ['--without-fp']}, + {'variant': 'soft', + 'arch': 'mipsel', + 'ccopts': '-mabi=32', + 'cfg': ['--without-fp']}, + {'variant': 'n64-soft', + 'ccopts': '-mabi=64', + 'cfg': ['--without-fp']}]) + self.add_config(arch='mips64el', + os_name='linux-gnu', + variant='nan2008', + gcc_cfg=['--with-mips-plt', '--with-nan=2008', + '--with-arch-64=mips64r2', + '--with-arch-32=mips32r2'], + glibcs=[{'variant': 'n32-nan2008'}, + {'variant': 'nan2008', + 'arch': 'mipsel', + 'ccopts': '-mabi=32'}, + {'variant': 'n64-nan2008', + 'ccopts': '-mabi=64'}]) + self.add_config(arch='mips64el', + os_name='linux-gnu', + variant='nan2008-soft', + gcc_cfg=['--with-mips-plt', '--with-nan=2008', + '--with-arch-64=mips64r2', + '--with-arch-32=mips32r2', + '--with-float=soft'], + glibcs=[{'variant': 'n32-nan2008-soft', + 'cfg': ['--without-fp']}, + {'variant': 'nan2008-soft', + 'arch': 'mipsel', + 'ccopts': '-mabi=32', + 'cfg': ['--without-fp']}, + {'variant': 'n64-nan2008-soft', + 'ccopts': '-mabi=64', + 'cfg': ['--without-fp']}]) + self.add_config(arch='nios2', + os_name='linux-gnu') + self.add_config(arch='powerpc', + os_name='linux-gnu', + gcc_cfg=['--disable-multilib', '--enable-secureplt'], + extra_glibcs=[{'variant': 'power4', + 'ccopts': '-mcpu=power4', + 'cfg': ['--with-cpu=power4']}]) + self.add_config(arch='powerpc', + os_name='linux-gnu', + variant='soft', + gcc_cfg=['--disable-multilib', '--with-float=soft', + '--enable-secureplt'], + glibcs=[{'variant': 'soft', 'cfg': ['--without-fp']}]) + self.add_config(arch='powerpc64', + os_name='linux-gnu', + gcc_cfg=['--disable-multilib', '--enable-secureplt']) + self.add_config(arch='powerpc64le', + os_name='linux-gnu', + gcc_cfg=['--disable-multilib', '--enable-secureplt']) + self.add_config(arch='powerpc', + os_name='linux-gnuspe', + gcc_cfg=['--disable-multilib', '--enable-secureplt', + '--enable-e500-double'], + glibcs=[{'cfg': ['--without-fp']}]) + self.add_config(arch='powerpc', + os_name='linux-gnuspe', + variant='e500v1', + gcc_cfg=['--disable-multilib', '--enable-secureplt'], + glibcs=[{'variant': 'e500v1', 'cfg': ['--without-fp']}]) + self.add_config(arch='s390x', + os_name='linux-gnu', + glibcs=[{}, + {'arch': 's390', 'ccopts': '-m31'}]) + self.add_config(arch='sh3', + os_name='linux-gnu') + self.add_config(arch='sh3eb', + os_name='linux-gnu') + self.add_config(arch='sh4', + os_name='linux-gnu') + self.add_config(arch='sh4eb', + os_name='linux-gnu') + self.add_config(arch='sh4', + os_name='linux-gnu', + variant='soft', + gcc_cfg=['--without-fp'], + glibcs=[{'variant': 'soft', 'cfg': ['--without-fp']}]) + self.add_config(arch='sh4eb', + os_name='linux-gnu', + variant='soft', + gcc_cfg=['--without-fp'], + glibcs=[{'variant': 'soft', 'cfg': ['--without-fp']}]) + self.add_config(arch='sparc64', + os_name='linux-gnu', + glibcs=[{}, + {'arch': 'sparcv9', + 'ccopts': '-m32 -mlong-double-128'}]) + self.add_config(arch='tilegx', + os_name='linux-gnu', + glibcs=[{}, + {'variant': '32', 'ccopts': '-m32'}]) + self.add_config(arch='tilegxbe', + os_name='linux-gnu', + glibcs=[{}, + {'variant': '32', 'ccopts': '-m32'}]) + self.add_config(arch='tilepro', + os_name='linux-gnu') + self.add_config(arch='x86_64', + os_name='linux-gnu', + gcc_cfg=['--with-multilib-list=m64,m32,mx32'], + glibcs=[{}, + {'variant': 'x32', 'ccopts': '-mx32'}, + {'arch': 'i686', 'ccopts': '-m32 -march=i686'}], + extra_glibcs=[{'variant': 'disable-multi-arch', + 'cfg': ['--disable-multi-arch']}, + {'variant': 'disable-multi-arch', + 'arch': 'i686', + 'ccopts': '-m32 -march=i686', + 'cfg': ['--disable-multi-arch']}, + {'arch': 'i486', + 'ccopts': '-m32 -march=i486'}, + {'arch': 'i586', + 'ccopts': '-m32 -march=i586'}]) + + def add_config(self, **args): + """Add an individual build configuration.""" + cfg = Config(self, **args) + if cfg.name in self.configs: + print('error: duplicate config %s' % cfg.name) + exit(1) + self.configs[cfg.name] = cfg + for c in cfg.all_glibcs: + if c.name in self.glibc_configs: + print('error: duplicate glibc config %s' % c.name) + exit(1) + self.glibc_configs[c.name] = c + + def component_srcdir(self, component): + """Return the source directory for a given component, e.g. gcc.""" + return os.path.join(self.srcdir, component) + + def component_builddir(self, action, config, component, subconfig=None): + """Return the directory to use for a build.""" + if config is None: + # Host libraries. + assert subconfig is None + return os.path.join(self.builddir, action, component) + if subconfig is None: + return os.path.join(self.builddir, action, config, component) + else: + # glibc build as part of compiler build. + return os.path.join(self.builddir, action, config, component, + subconfig) + + def compiler_installdir(self, config): + """Return the directory in which to install a compiler.""" + return os.path.join(self.installdir, 'compilers', config) + + def compiler_bindir(self, config): + """Return the directory in which to find compiler binaries.""" + return os.path.join(self.compiler_installdir(config), 'bin') + + def compiler_sysroot(self, config): + """Return the sysroot directory for a compiler.""" + return os.path.join(self.compiler_installdir(config), 'sysroot') + + def glibc_installdir(self, config): + """Return the directory in which to install glibc.""" + return os.path.join(self.installdir, 'glibcs', config) + + def run_builds(self, action, configs): + """Run the requested builds.""" + if action == 'checkout': + self.checkout(configs) + return + if action == 'bot-cycle': + if configs: + print('error: configurations specified for bot-cycle') + exit(1) + self.bot_cycle() + return + if action == 'bot': + if configs: + print('error: configurations specified for bot') + exit(1) + self.bot() + return + if action == 'host-libraries' and configs: + print('error: configurations specified for host-libraries') + exit(1) + self.clear_last_build_state(action) + build_time = datetime.datetime.utcnow() + if action == 'host-libraries': + build_components = ('gmp', 'mpfr', 'mpc') + old_components = () + old_versions = {} + self.build_host_libraries() + elif action == 'compilers': + build_components = ('binutils', 'gcc', 'glibc', 'linux') + old_components = ('gmp', 'mpfr', 'mpc') + old_versions = self.build_state['host-libraries']['build-versions'] + self.build_compilers(configs) + else: + build_components = ('glibc',) + old_components = ('gmp', 'mpfr', 'mpc', 'binutils', 'gcc', 'linux') + old_versions = self.build_state['compilers']['build-versions'] + self.build_glibcs(configs) + self.write_files() + self.do_build() + if configs: + # Partial build, do not update stored state. + return + build_versions = {} + for k in build_components: + if k in self.versions: + build_versions[k] = {'version': self.versions[k]['version'], + 'revision': self.versions[k]['revision']} + for k in old_components: + if k in old_versions: + build_versions[k] = {'version': old_versions[k]['version'], + 'revision': old_versions[k]['revision']} + self.update_build_state(action, build_time, build_versions) + + @staticmethod + def remove_dirs(*args): + """Remove directories and their contents if they exist.""" + for dir in args: + shutil.rmtree(dir, ignore_errors=True) + + @staticmethod + def remove_recreate_dirs(*args): + """Remove directories if they exist, and create them as empty.""" + Context.remove_dirs(*args) + for dir in args: + os.makedirs(dir, exist_ok=True) + + def add_makefile_cmdlist(self, target, cmdlist, logsdir): + """Add makefile text for a list of commands.""" + commands = cmdlist.makefile_commands(self.wrapper, logsdir) + self.makefile_pieces.append('all: %s\n.PHONY: %s\n%s:\n%s\n' % + (target, target, target, commands)) + self.status_log_list.extend(cmdlist.status_logs(logsdir)) + + def write_files(self): + """Write out the Makefile and wrapper script.""" + mftext = ''.join(self.makefile_pieces) + with open(self.makefile, 'w') as f: + f.write(mftext) + wrapper_text = ( + '#!/bin/sh\n' + 'prev_base=$1\n' + 'this_base=$2\n' + 'desc=$3\n' + 'dir=$4\n' + 'path=$5\n' + 'shift 5\n' + 'prev_status=$prev_base-status.txt\n' + 'this_status=$this_base-status.txt\n' + 'this_log=$this_base-log.txt\n' + 'date > "$this_log"\n' + 'echo >> "$this_log"\n' + 'echo "Description: $desc" >> "$this_log"\n' + 'printf "%s" "Command:" >> "$this_log"\n' + 'for word in "$@"; do\n' + ' if expr "$word" : "[]+,./0-9@A-Z_a-z-]\\\\{1,\\\\}\\$" > /dev/null; then\n' + ' printf " %s" "$word"\n' + ' else\n' + ' printf " \'"\n' + ' printf "%s" "$word" | sed -e "s/\'/\'\\\\\\\\\'\'/"\n' + ' printf "\'"\n' + ' fi\n' + 'done >> "$this_log"\n' + 'echo >> "$this_log"\n' + 'echo "Directory: $dir" >> "$this_log"\n' + 'echo "Path addition: $path" >> "$this_log"\n' + 'echo >> "$this_log"\n' + 'record_status ()\n' + '{\n' + ' echo >> "$this_log"\n' + ' echo "$1: $desc" > "$this_status"\n' + ' echo "$1: $desc" >> "$this_log"\n' + ' echo >> "$this_log"\n' + ' date >> "$this_log"\n' + ' echo "$1: $desc"\n' + ' exit 0\n' + '}\n' + 'check_error ()\n' + '{\n' + ' if [ "$1" != "0" ]; then\n' + ' record_status FAIL\n' + ' fi\n' + '}\n' + 'if [ "$prev_base" ] && ! grep -q "^PASS" "$prev_status"; then\n' + ' record_status UNRESOLVED\n' + 'fi\n' + 'if [ "$dir" ]; then\n' + ' cd "$dir"\n' + ' check_error "$?"\n' + 'fi\n' + 'if [ "$path" ]; then\n' + ' PATH=$path:$PATH\n' + 'fi\n' + '"$@" < /dev/null >> "$this_log" 2>&1\n' + 'check_error "$?"\n' + 'record_status PASS\n') + with open(self.wrapper, 'w') as f: + f.write(wrapper_text) + # Mode 0o755. + mode_exec = (stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP| + stat.S_IROTH|stat.S_IXOTH) + os.chmod(self.wrapper, mode_exec) + save_logs_text = ( + '#!/bin/sh\n' + 'if ! [ -f tests.sum ]; then\n' + ' echo "No test summary available."\n' + ' exit 0\n' + 'fi\n' + 'save_file ()\n' + '{\n' + ' echo "Contents of $1:"\n' + ' echo\n' + ' cat "$1"\n' + ' echo\n' + ' echo "End of contents of $1."\n' + ' echo\n' + '}\n' + 'save_file tests.sum\n' + 'non_pass_tests=$(grep -v "^PASS: " tests.sum | sed -e "s/^PASS: //")\n' + 'for t in $non_pass_tests; do\n' + ' if [ -f "$t.out" ]; then\n' + ' save_file "$t.out"\n' + ' fi\n' + 'done\n') + with open(self.save_logs, 'w') as f: + f.write(save_logs_text) + os.chmod(self.save_logs, mode_exec) + + def do_build(self): + """Do the actual build.""" + cmd = ['make', '-j%d' % self.parallelism] + subprocess.run(cmd, cwd=self.builddir, check=True) + + def build_host_libraries(self): + """Build the host libraries.""" + installdir = self.host_libraries_installdir + builddir = os.path.join(self.builddir, 'host-libraries') + logsdir = os.path.join(self.logsdir, 'host-libraries') + self.remove_recreate_dirs(installdir, builddir, logsdir) + cmdlist = CommandList('host-libraries', self.keep) + self.build_host_library(cmdlist, 'gmp') + self.build_host_library(cmdlist, 'mpfr', + ['--with-gmp=%s' % installdir]) + self.build_host_library(cmdlist, 'mpc', + ['--with-gmp=%s' % installdir, + '--with-mpfr=%s' % installdir]) + cmdlist.add_command('done', ['touch', os.path.join(installdir, 'ok')]) + self.add_makefile_cmdlist('host-libraries', cmdlist, logsdir) + + def build_host_library(self, cmdlist, lib, extra_opts=None): + """Build one host library.""" + srcdir = self.component_srcdir(lib) + builddir = self.component_builddir('host-libraries', None, lib) + installdir = self.host_libraries_installdir + cmdlist.push_subdesc(lib) + cmdlist.create_use_dir(builddir) + cfg_cmd = [os.path.join(srcdir, 'configure'), + '--prefix=%s' % installdir, + '--disable-shared'] + if extra_opts: + cfg_cmd.extend (extra_opts) + cmdlist.add_command('configure', cfg_cmd) + cmdlist.add_command('build', ['make']) + cmdlist.add_command('check', ['make', 'check']) + cmdlist.add_command('install', ['make', 'install']) + cmdlist.cleanup_dir() + cmdlist.pop_subdesc() + + def build_compilers(self, configs): + """Build the compilers.""" + if not configs: + self.remove_dirs(os.path.join(self.builddir, 'compilers')) + self.remove_dirs(os.path.join(self.installdir, 'compilers')) + self.remove_dirs(os.path.join(self.logsdir, 'compilers')) + configs = sorted(self.configs.keys()) + for c in configs: + self.configs[c].build() + + def build_glibcs(self, configs): + """Build the glibcs.""" + if not configs: + self.remove_dirs(os.path.join(self.builddir, 'glibcs')) + self.remove_dirs(os.path.join(self.installdir, 'glibcs')) + self.remove_dirs(os.path.join(self.logsdir, 'glibcs')) + configs = sorted(self.glibc_configs.keys()) + for c in configs: + self.glibc_configs[c].build() + + def load_versions_json(self): + """Load information about source directory versions.""" + if not os.access(self.versions_json, os.F_OK): + self.versions = {} + return + with open(self.versions_json, 'r') as f: + self.versions = json.load(f) + + def store_json(self, data, filename): + """Store information in a JSON file.""" + filename_tmp = filename + '.tmp' + with open(filename_tmp, 'w') as f: + json.dump(data, f, indent=2, sort_keys=True) + os.rename(filename_tmp, filename) + + def store_versions_json(self): + """Store information about source directory versions.""" + self.store_json(self.versions, self.versions_json) + + def set_component_version(self, component, version, explicit, revision): + """Set the version information for a component.""" + self.versions[component] = {'version': version, + 'explicit': explicit, + 'revision': revision} + self.store_versions_json() + + def checkout(self, versions): + """Check out the desired component versions.""" + default_versions = {'binutils': 'vcs-2.28', + 'gcc': 'vcs-7', + 'glibc': 'vcs-mainline', + 'gmp': '6.1.1', + 'linux': '4.11', + 'mpc': '1.0.3', + 'mpfr': '3.1.5'} + use_versions = {} + explicit_versions = {} + for v in versions: + found_v = False + for k in default_versions.keys(): + kx = k + '-' + if v.startswith(kx): + vx = v[len(kx):] + if k in use_versions: + print('error: multiple versions for %s' % k) + exit(1) + use_versions[k] = vx + explicit_versions[k] = True + found_v = True + break + if not found_v: + print('error: unknown component in %s' % v) + exit(1) + for k in default_versions.keys(): + if k not in use_versions: + if k in self.versions and self.versions[k]['explicit']: + use_versions[k] = self.versions[k]['version'] + explicit_versions[k] = True + else: + use_versions[k] = default_versions[k] + explicit_versions[k] = False + os.makedirs(self.srcdir, exist_ok=True) + for k in sorted(default_versions.keys()): + update = os.access(self.component_srcdir(k), os.F_OK) + v = use_versions[k] + if (update and + k in self.versions and + v != self.versions[k]['version']): + if not self.replace_sources: + print('error: version of %s has changed from %s to %s, ' + 'use --replace-sources to check out again' % + (k, self.versions[k]['version'], v)) + exit(1) + shutil.rmtree(self.component_srcdir(k)) + update = False + if v.startswith('vcs-'): + revision = self.checkout_vcs(k, v[4:], update) + else: + self.checkout_tar(k, v, update) + revision = v + self.set_component_version(k, v, explicit_versions[k], revision) + if self.get_script_text() != self.script_text: + # Rerun the checkout process in case the updated script + # uses different default versions or new components. + self.exec_self() + + def checkout_vcs(self, component, version, update): + """Check out the given version of the given component from version + control. Return a revision identifier.""" + if component == 'binutils': + git_url = 'git://sourceware.org/git/binutils-gdb.git' + if version == 'mainline': + git_branch = 'master' + else: + trans = str.maketrans({'.': '_'}) + git_branch = 'binutils-%s-branch' % version.translate(trans) + return self.git_checkout(component, git_url, git_branch, update) + elif component == 'gcc': + if version == 'mainline': + branch = 'trunk' + else: + trans = str.maketrans({'.': '_'}) + branch = 'branches/gcc-%s-branch' % version.translate(trans) + svn_url = 'svn://gcc.gnu.org/svn/gcc/%s' % branch + return self.gcc_checkout(svn_url, update) + elif component == 'glibc': + git_url = 'git://sourceware.org/git/glibc.git' + if version == 'mainline': + git_branch = 'master' + else: + git_branch = 'release/%s/master' % version + r = self.git_checkout(component, git_url, git_branch, update) + self.fix_glibc_timestamps() + return r + else: + print('error: component %s coming from VCS' % component) + exit(1) + + def git_checkout(self, component, git_url, git_branch, update): + """Check out a component from git. Return a commit identifier.""" + if update: + subprocess.run(['git', 'remote', 'prune', 'origin'], + cwd=self.component_srcdir(component), check=True) + subprocess.run(['git', 'pull', '-q'], + cwd=self.component_srcdir(component), check=True) + else: + subprocess.run(['git', 'clone', '-q', '-b', git_branch, git_url, + self.component_srcdir(component)], check=True) + r = subprocess.run(['git', 'rev-parse', 'HEAD'], + cwd=self.component_srcdir(component), + stdout=subprocess.PIPE, + check=True, universal_newlines=True).stdout + return r.rstrip() + + def fix_glibc_timestamps(self): + """Fix timestamps in a glibc checkout.""" + # Ensure that builds do not try to regenerate generated files + # in the source tree. + srcdir = self.component_srcdir('glibc') + for dirpath, dirnames, filenames in os.walk(srcdir): + for f in filenames: + if (f == 'configure' or + f == 'preconfigure' or + f.endswith('-kw.h')): + to_touch = os.path.join(dirpath, f) + subprocess.run(['touch', to_touch], check=True) + + def gcc_checkout(self, svn_url, update): + """Check out GCC from SVN. Return the revision number.""" + if not update: + subprocess.run(['svn', 'co', '-q', svn_url, + self.component_srcdir('gcc')], check=True) + subprocess.run(['contrib/gcc_update', '--silent'], + cwd=self.component_srcdir('gcc'), check=True) + r = subprocess.run(['svnversion', self.component_srcdir('gcc')], + stdout=subprocess.PIPE, + check=True, universal_newlines=True).stdout + return r.rstrip() + + def checkout_tar(self, component, version, update): + """Check out the given version of the given component from a + tarball.""" + if update: + return + url_map = {'binutils': 'https://ftp.gnu.org/gnu/binutils/binutils-%(version)s.tar.bz2', + 'gcc': 'https://ftp.gnu.org/gnu/gcc/gcc-%(version)s/gcc-%(version)s.tar.bz2', + 'gmp': 'https://ftp.gnu.org/gnu/gmp/gmp-%(version)s.tar.xz', + 'linux': 'https://www.kernel.org/pub/linux/kernel/v4.x/linux-%(version)s.tar.xz', + 'mpc': 'https://ftp.gnu.org/gnu/mpc/mpc-%(version)s.tar.gz', + 'mpfr': 'https://ftp.gnu.org/gnu/mpfr/mpfr-%(version)s.tar.xz'} + if component not in url_map: + print('error: component %s coming from tarball' % component) + exit(1) + url = url_map[component] % {'version': version} + filename = os.path.join(self.srcdir, url.split('/')[-1]) + response = urllib.request.urlopen(url) + data = response.read() + with open(filename, 'wb') as f: + f.write(data) + subprocess.run(['tar', '-C', self.srcdir, '-x', '-f', filename], + check=True) + os.rename(os.path.join(self.srcdir, '%s-%s' % (component, version)), + self.component_srcdir(component)) + os.remove(filename) + + def load_build_state_json(self): + """Load information about the state of previous builds.""" + if os.access(self.build_state_json, os.F_OK): + with open(self.build_state_json, 'r') as f: + self.build_state = json.load(f) + else: + self.build_state = {} + for k in ('host-libraries', 'compilers', 'glibcs'): + if k not in self.build_state: + self.build_state[k] = {} + if 'build-time' not in self.build_state[k]: + self.build_state[k]['build-time'] = '' + if 'build-versions' not in self.build_state[k]: + self.build_state[k]['build-versions'] = {} + if 'build-results' not in self.build_state[k]: + self.build_state[k]['build-results'] = {} + if 'result-changes' not in self.build_state[k]: + self.build_state[k]['result-changes'] = {} + if 'ever-passed' not in self.build_state[k]: + self.build_state[k]['ever-passed'] = [] + + def store_build_state_json(self): + """Store information about the state of previous builds.""" + self.store_json(self.build_state, self.build_state_json) + + def clear_last_build_state(self, action): + """Clear information about the state of part of the build.""" + # We clear the last build time and versions when starting a + # new build. The results of the last build are kept around, + # as comparison is still meaningful if this build is aborted + # and a new one started. + self.build_state[action]['build-time'] = '' + self.build_state[action]['build-versions'] = {} + self.store_build_state_json() + + def update_build_state(self, action, build_time, build_versions): + """Update the build state after a build.""" + build_time = build_time.replace(microsecond=0) + self.build_state[action]['build-time'] = str(build_time) + self.build_state[action]['build-versions'] = build_versions + build_results = {} + for log in self.status_log_list: + with open(log, 'r') as f: + log_text = f.read() + log_text = log_text.rstrip() + m = re.fullmatch('([A-Z]+): (.*)', log_text) + result = m.group(1) + test_name = m.group(2) + assert test_name not in build_results + build_results[test_name] = result + old_build_results = self.build_state[action]['build-results'] + self.build_state[action]['build-results'] = build_results + result_changes = {} + all_tests = set(old_build_results.keys()) | set(build_results.keys()) + for t in all_tests: + if t in old_build_results: + old_res = old_build_results[t] + else: + old_res = '(New test)' + if t in build_results: + new_res = build_results[t] + else: + new_res = '(Test removed)' + if old_res != new_res: + result_changes[t] = '%s -> %s' % (old_res, new_res) + self.build_state[action]['result-changes'] = result_changes + old_ever_passed = {t for t in self.build_state[action]['ever-passed'] + if t in build_results} + new_passes = {t for t in build_results if build_results[t] == 'PASS'} + self.build_state[action]['ever-passed'] = sorted(old_ever_passed | + new_passes) + self.store_build_state_json() + + def load_bot_config_json(self): + """Load bot configuration.""" + with open(self.bot_config_json, 'r') as f: + self.bot_config = json.load(f) + + def part_build_old(self, action, delay): + """Return whether the last build for a given action was at least a + given number of seconds ago, or does not have a time recorded.""" + old_time_str = self.build_state[action]['build-time'] + if not old_time_str: + return True + old_time = datetime.datetime.strptime(old_time_str, + '%Y-%m-%d %H:%M:%S') + new_time = datetime.datetime.utcnow() + delta = new_time - old_time + return delta.total_seconds() >= delay + + def bot_cycle(self): + """Run a single round of checkout and builds.""" + print('Bot cycle starting %s.' % str(datetime.datetime.utcnow())) + self.load_bot_config_json() + actions = ('host-libraries', 'compilers', 'glibcs') + self.bot_run_self(['--replace-sources'], 'checkout') + self.load_versions_json() + if self.get_script_text() != self.script_text: + print('Script changed, re-execing.') + # On script change, all parts of the build should be rerun. + for a in actions: + self.clear_last_build_state(a) + self.exec_self() + check_components = {'host-libraries': ('gmp', 'mpfr', 'mpc'), + 'compilers': ('binutils', 'gcc', 'glibc', 'linux'), + 'glibcs': ('glibc',)} + must_build = {} + for a in actions: + build_vers = self.build_state[a]['build-versions'] + must_build[a] = False + if not self.build_state[a]['build-time']: + must_build[a] = True + old_vers = {} + new_vers = {} + for c in check_components[a]: + if c in build_vers: + old_vers[c] = build_vers[c] + new_vers[c] = {'version': self.versions[c]['version'], + 'revision': self.versions[c]['revision']} + if new_vers == old_vers: + print('Versions for %s unchanged.' % a) + else: + print('Versions changed or rebuild forced for %s.' % a) + if a == 'compilers' and not self.part_build_old( + a, self.bot_config['compilers-rebuild-delay']): + print('Not requiring rebuild of compilers this soon.') + else: + must_build[a] = True + if must_build['host-libraries']: + must_build['compilers'] = True + if must_build['compilers']: + must_build['glibcs'] = True + for a in actions: + if must_build[a]: + print('Must rebuild %s.' % a) + self.clear_last_build_state(a) + else: + print('No need to rebuild %s.' % a) + if os.access(self.logsdir, os.F_OK): + shutil.rmtree(self.logsdir_old, ignore_errors=True) + shutil.copytree(self.logsdir, self.logsdir_old) + for a in actions: + if must_build[a]: + build_time = datetime.datetime.utcnow() + print('Rebuilding %s at %s.' % (a, str(build_time))) + self.bot_run_self([], a) + self.load_build_state_json() + self.bot_build_mail(a, build_time) + print('Bot cycle done at %s.' % str(datetime.datetime.utcnow())) + + def bot_build_mail(self, action, build_time): + """Send email with the results of a build.""" + if not ('email-from' in self.bot_config and + 'email-server' in self.bot_config and + 'email-subject' in self.bot_config and + 'email-to' in self.bot_config): + if not self.email_warning: + print("Email not configured, not sending.") + self.email_warning = True + return + + build_time = build_time.replace(microsecond=0) + subject = (self.bot_config['email-subject'] % + {'action': action, + 'build-time': str(build_time)}) + results = self.build_state[action]['build-results'] + changes = self.build_state[action]['result-changes'] + ever_passed = set(self.build_state[action]['ever-passed']) + versions = self.build_state[action]['build-versions'] + new_regressions = {k for k in changes if changes[k] == 'PASS -> FAIL'} + all_regressions = {k for k in ever_passed if results[k] == 'FAIL'} + all_fails = {k for k in results if results[k] == 'FAIL'} + if new_regressions: + new_reg_list = sorted(['FAIL: %s' % k for k in new_regressions]) + new_reg_text = ('New regressions:\n\n%s\n\n' % + '\n'.join(new_reg_list)) + else: + new_reg_text = '' + if all_regressions: + all_reg_list = sorted(['FAIL: %s' % k for k in all_regressions]) + all_reg_text = ('All regressions:\n\n%s\n\n' % + '\n'.join(all_reg_list)) + else: + all_reg_text = '' + if all_fails: + all_fail_list = sorted(['FAIL: %s' % k for k in all_fails]) + all_fail_text = ('All failures:\n\n%s\n\n' % + '\n'.join(all_fail_list)) + else: + all_fail_text = '' + if changes: + changes_list = sorted(changes.keys()) + changes_list = ['%s: %s' % (changes[k], k) for k in changes_list] + changes_text = ('All changed results:\n\n%s\n\n' % + '\n'.join(changes_list)) + else: + changes_text = '' + results_text = (new_reg_text + all_reg_text + all_fail_text + + changes_text) + if not results_text: + results_text = 'Clean build with unchanged results.\n\n' + versions_list = sorted(versions.keys()) + versions_list = ['%s: %s (%s)' % (k, versions[k]['version'], + versions[k]['revision']) + for k in versions_list] + versions_text = ('Component versions for this build:\n\n%s\n' % + '\n'.join(versions_list)) + body_text = results_text + versions_text + msg = email.mime.text.MIMEText(body_text) + msg['Subject'] = subject + msg['From'] = self.bot_config['email-from'] + msg['To'] = self.bot_config['email-to'] + msg['Message-ID'] = email.utils.make_msgid() + msg['Date'] = email.utils.format_datetime(datetime.datetime.utcnow()) + with smtplib.SMTP(self.bot_config['email-server']) as s: + s.send_message(msg) + + def bot_run_self(self, opts, action, check=True): + """Run a copy of this script with given options.""" + cmd = [sys.executable, sys.argv[0], '--keep=none', + '-j%d' % self.parallelism] + cmd.extend(opts) + cmd.extend([self.topdir, action]) + sys.stdout.flush() + subprocess.run(cmd, check=check) + + def bot(self): + """Run repeated rounds of checkout and builds.""" + while True: + self.load_bot_config_json() + if not self.bot_config['run']: + print('Bot exiting by request.') + exit(0) + self.bot_run_self([], 'bot-cycle', check=False) + self.load_bot_config_json() + if not self.bot_config['run']: + print('Bot exiting by request.') + exit(0) + time.sleep(self.bot_config['delay']) + if self.get_script_text() != self.script_text: + print('Script changed, bot re-execing.') + self.exec_self() + + +class Config(object): + """A configuration for building a compiler and associated libraries.""" + + def __init__(self, ctx, arch, os_name, variant=None, gcc_cfg=None, + first_gcc_cfg=None, glibcs=None, extra_glibcs=None): + """Initialize a Config object.""" + self.ctx = ctx + self.arch = arch + self.os = os_name + self.variant = variant + if variant is None: + self.name = '%s-%s' % (arch, os_name) + else: + self.name = '%s-%s-%s' % (arch, os_name, variant) + self.triplet = '%s-glibc-%s' % (arch, os_name) + if gcc_cfg is None: + self.gcc_cfg = [] + else: + self.gcc_cfg = gcc_cfg + if first_gcc_cfg is None: + self.first_gcc_cfg = [] + else: + self.first_gcc_cfg = first_gcc_cfg + if glibcs is None: + glibcs = [{'variant': variant}] + if extra_glibcs is None: + extra_glibcs = [] + glibcs = [Glibc(self, **g) for g in glibcs] + extra_glibcs = [Glibc(self, **g) for g in extra_glibcs] + self.all_glibcs = glibcs + extra_glibcs + self.compiler_glibcs = glibcs + self.installdir = ctx.compiler_installdir(self.name) + self.bindir = ctx.compiler_bindir(self.name) + self.sysroot = ctx.compiler_sysroot(self.name) + self.builddir = os.path.join(ctx.builddir, 'compilers', self.name) + self.logsdir = os.path.join(ctx.logsdir, 'compilers', self.name) + + def component_builddir(self, component): + """Return the directory to use for a (non-glibc) build.""" + return self.ctx.component_builddir('compilers', self.name, component) + + def build(self): + """Generate commands to build this compiler.""" + self.ctx.remove_recreate_dirs(self.installdir, self.builddir, + self.logsdir) + cmdlist = CommandList('compilers-%s' % self.name, self.ctx.keep) + cmdlist.add_command('check-host-libraries', + ['test', '-f', + os.path.join(self.ctx.host_libraries_installdir, + 'ok')]) + cmdlist.use_path(self.bindir) + self.build_cross_tool(cmdlist, 'binutils', 'binutils', + ['--disable-gdb', + '--disable-libdecnumber', + '--disable-readline', + '--disable-sim']) + if self.os.startswith('linux'): + self.install_linux_headers(cmdlist) + self.build_gcc(cmdlist, True) + for g in self.compiler_glibcs: + cmdlist.push_subdesc('glibc') + cmdlist.push_subdesc(g.name) + g.build_glibc(cmdlist, True) + cmdlist.pop_subdesc() + cmdlist.pop_subdesc() + self.build_gcc(cmdlist, False) + cmdlist.add_command('done', ['touch', + os.path.join(self.installdir, 'ok')]) + self.ctx.add_makefile_cmdlist('compilers-%s' % self.name, cmdlist, + self.logsdir) + + def build_cross_tool(self, cmdlist, tool_src, tool_build, extra_opts=None): + """Build one cross tool.""" + srcdir = self.ctx.component_srcdir(tool_src) + builddir = self.component_builddir(tool_build) + cmdlist.push_subdesc(tool_build) + cmdlist.create_use_dir(builddir) + cfg_cmd = [os.path.join(srcdir, 'configure'), + '--prefix=%s' % self.installdir, + '--build=%s' % self.ctx.build_triplet, + '--host=%s' % self.ctx.build_triplet, + '--target=%s' % self.triplet, + '--with-sysroot=%s' % self.sysroot] + if extra_opts: + cfg_cmd.extend(extra_opts) + cmdlist.add_command('configure', cfg_cmd) + cmdlist.add_command('build', ['make']) + # Parallel "make install" for GCC has race conditions that can + # cause it to fail; see + # <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42980>. Such + # problems are not known for binutils, but doing the + # installation in parallel within a particular toolchain build + # (as opposed to installation of one toolchain from + # build-many-glibcs.py running in parallel to the installation + # of other toolchains being built) is not known to be + # significantly beneficial, so it is simplest just to disable + # parallel install for cross tools here. + cmdlist.add_command('install', ['make', '-j1', 'install']) + cmdlist.cleanup_dir() + cmdlist.pop_subdesc() + + def install_linux_headers(self, cmdlist): + """Install Linux kernel headers.""" + arch_map = {'aarch64': 'arm64', + 'alpha': 'alpha', + 'arm': 'arm', + 'hppa': 'parisc', + 'i486': 'x86', + 'i586': 'x86', + 'i686': 'x86', + 'i786': 'x86', + 'ia64': 'ia64', + 'm68k': 'm68k', + 'microblaze': 'microblaze', + 'mips': 'mips', + 'nios2': 'nios2', + 'powerpc': 'powerpc', + 's390': 's390', + 'sh': 'sh', + 'sparc': 'sparc', + 'tile': 'tile', + 'x86_64': 'x86'} + linux_arch = None + for k in arch_map: + if self.arch.startswith(k): + linux_arch = arch_map[k] + break + assert linux_arch is not None + srcdir = self.ctx.component_srcdir('linux') + builddir = self.component_builddir('linux') + headers_dir = os.path.join(self.sysroot, 'usr') + cmdlist.push_subdesc('linux') + cmdlist.create_use_dir(builddir) + cmdlist.add_command('install-headers', + ['make', '-C', srcdir, 'O=%s' % builddir, + 'ARCH=%s' % linux_arch, + 'INSTALL_HDR_PATH=%s' % headers_dir, + 'headers_install']) + cmdlist.cleanup_dir() + cmdlist.pop_subdesc() + + def build_gcc(self, cmdlist, bootstrap): + """Build GCC.""" + # libsanitizer commonly breaks because of glibc header + # changes, or on unusual targets. libssp is of little + # relevance with glibc's own stack checking support. + cfg_opts = list(self.gcc_cfg) + cfg_opts += ['--disable-libsanitizer', '--disable-libssp'] + host_libs = self.ctx.host_libraries_installdir + cfg_opts += ['--with-gmp=%s' % host_libs, + '--with-mpfr=%s' % host_libs, + '--with-mpc=%s' % host_libs] + if bootstrap: + tool_build = 'gcc-first' + # Building a static-only, C-only compiler that is + # sufficient to build glibc. Various libraries and + # features that may require libc headers must be disabled. + # When configuring with a sysroot, --with-newlib is + # required to define inhibit_libc (to stop some parts of + # libgcc including libc headers); --without-headers is not + # sufficient. + cfg_opts += ['--enable-languages=c', '--disable-shared', + '--disable-threads', + '--disable-libatomic', + '--disable-decimal-float', + '--disable-libffi', + '--disable-libgomp', + '--disable-libitm', + '--disable-libmpx', + '--disable-libquadmath', + '--without-headers', '--with-newlib', + '--with-glibc-version=%s' % self.ctx.glibc_version + ] + cfg_opts += self.first_gcc_cfg + else: + tool_build = 'gcc' + cfg_opts += ['--enable-languages=c,c++', '--enable-shared', + '--enable-threads'] + self.build_cross_tool(cmdlist, 'gcc', tool_build, cfg_opts) + + +class Glibc(object): + """A configuration for building glibc.""" + + def __init__(self, compiler, arch=None, os_name=None, variant=None, + cfg=None, ccopts=None): + """Initialize a Glibc object.""" + self.ctx = compiler.ctx + self.compiler = compiler + if arch is None: + self.arch = compiler.arch + else: + self.arch = arch + if os_name is None: + self.os = compiler.os + else: + self.os = os_name + self.variant = variant + if variant is None: + self.name = '%s-%s' % (self.arch, self.os) + else: + self.name = '%s-%s-%s' % (self.arch, self.os, variant) + self.triplet = '%s-glibc-%s' % (self.arch, self.os) + if cfg is None: + self.cfg = [] + else: + self.cfg = cfg + self.ccopts = ccopts + + def tool_name(self, tool): + """Return the name of a cross-compilation tool.""" + ctool = '%s-%s' % (self.compiler.triplet, tool) + if self.ccopts and (tool == 'gcc' or tool == 'g++'): + ctool = '%s %s' % (ctool, self.ccopts) + return ctool + + def build(self): + """Generate commands to build this glibc.""" + builddir = self.ctx.component_builddir('glibcs', self.name, 'glibc') + installdir = self.ctx.glibc_installdir(self.name) + logsdir = os.path.join(self.ctx.logsdir, 'glibcs', self.name) + self.ctx.remove_recreate_dirs(installdir, builddir, logsdir) + cmdlist = CommandList('glibcs-%s' % self.name, self.ctx.keep) + cmdlist.add_command('check-compilers', + ['test', '-f', + os.path.join(self.compiler.installdir, 'ok')]) + cmdlist.use_path(self.compiler.bindir) + self.build_glibc(cmdlist, False) + self.ctx.add_makefile_cmdlist('glibcs-%s' % self.name, cmdlist, + logsdir) + + def build_glibc(self, cmdlist, for_compiler): + """Generate commands to build this glibc, either as part of a compiler + build or with the bootstrapped compiler (and in the latter case, run + tests as well).""" + srcdir = self.ctx.component_srcdir('glibc') + if for_compiler: + builddir = self.ctx.component_builddir('compilers', + self.compiler.name, 'glibc', + self.name) + installdir = self.compiler.sysroot + srcdir_copy = self.ctx.component_builddir('compilers', + self.compiler.name, + 'glibc-src', + self.name) + else: + builddir = self.ctx.component_builddir('glibcs', self.name, + 'glibc') + installdir = self.ctx.glibc_installdir(self.name) + srcdir_copy = self.ctx.component_builddir('glibcs', self.name, + 'glibc-src') + cmdlist.create_use_dir(builddir) + # glibc builds write into the source directory, and even if + # not intentionally there is a risk of bugs that involve + # writing into the working directory. To avoid possible + # concurrency issues, copy the source directory. + cmdlist.create_copy_dir(srcdir, srcdir_copy) + cfg_cmd = [os.path.join(srcdir_copy, 'configure'), + '--prefix=/usr', + '--enable-add-ons', + '--build=%s' % self.ctx.build_triplet, + '--host=%s' % self.triplet, + 'CC=%s' % self.tool_name('gcc'), + 'CXX=%s' % self.tool_name('g++'), + 'AR=%s' % self.tool_name('ar'), + 'AS=%s' % self.tool_name('as'), + 'LD=%s' % self.tool_name('ld'), + 'NM=%s' % self.tool_name('nm'), + 'OBJCOPY=%s' % self.tool_name('objcopy'), + 'OBJDUMP=%s' % self.tool_name('objdump'), + 'RANLIB=%s' % self.tool_name('ranlib'), + 'READELF=%s' % self.tool_name('readelf'), + 'STRIP=%s' % self.tool_name('strip')] + cfg_cmd += self.cfg + cmdlist.add_command('configure', cfg_cmd) + cmdlist.add_command('build', ['make']) + cmdlist.add_command('install', ['make', 'install', + 'install_root=%s' % installdir]) + # GCC uses paths such as lib/../lib64, so make sure lib + # directories always exist. + cmdlist.add_command('mkdir-lib', ['mkdir', '-p', + os.path.join(installdir, 'lib'), + os.path.join(installdir, + 'usr', 'lib')]) + if not for_compiler: + if self.ctx.strip: + cmdlist.add_command('strip', + ['sh', '-c', + ('%s %s/lib*/*.so' % + (self.tool_name('strip'), installdir))]) + cmdlist.add_command('check', ['make', 'check']) + cmdlist.add_command('save-logs', [self.ctx.save_logs], + always_run=True) + cmdlist.cleanup_dir('cleanup-src', srcdir_copy) + cmdlist.cleanup_dir() + + +class Command(object): + """A command run in the build process.""" + + def __init__(self, desc, num, dir, path, command, always_run=False): + """Initialize a Command object.""" + self.dir = dir + self.path = path + self.desc = desc + trans = str.maketrans({' ': '-'}) + self.logbase = '%03d-%s' % (num, desc.translate(trans)) + self.command = command + self.always_run = always_run + + @staticmethod + def shell_make_quote_string(s): + """Given a string not containing a newline, quote it for use by the + shell and make.""" + assert '\n' not in s + if re.fullmatch('[]+,./0-9@A-Z_a-z-]+', s): + return s + strans = str.maketrans({"'": "'\\''"}) + s = "'%s'" % s.translate(strans) + mtrans = str.maketrans({'$': '$$'}) + return s.translate(mtrans) + + @staticmethod + def shell_make_quote_list(l, translate_make): + """Given a list of strings not containing newlines, quote them for use + by the shell and make, returning a single string. If translate_make + is true and the first string is 'make', change it to $(MAKE).""" + l = [Command.shell_make_quote_string(s) for s in l] + if translate_make and l[0] == 'make': + l[0] = '$(MAKE)' + return ' '.join(l) + + def shell_make_quote(self): + """Return this command quoted for the shell and make.""" + return self.shell_make_quote_list(self.command, True) + + +class CommandList(object): + """A list of commands run in the build process.""" + + def __init__(self, desc, keep): + """Initialize a CommandList object.""" + self.cmdlist = [] + self.dir = None + self.path = None + self.desc = [desc] + self.keep = keep + + def desc_txt(self, desc): + """Return the description to use for a command.""" + return '%s %s' % (' '.join(self.desc), desc) + + def use_dir(self, dir): + """Set the default directory for subsequent commands.""" + self.dir = dir + + def use_path(self, path): + """Set a directory to be prepended to the PATH for subsequent + commands.""" + self.path = path + + def push_subdesc(self, subdesc): + """Set the default subdescription for subsequent commands (e.g., the + name of a component being built, within the series of commands + building it).""" + self.desc.append(subdesc) + + def pop_subdesc(self): + """Pop a subdescription from the list of descriptions.""" + self.desc.pop() + + def create_use_dir(self, dir): + """Remove and recreate a directory and use it for subsequent + commands.""" + self.add_command_dir('rm', None, ['rm', '-rf', dir]) + self.add_command_dir('mkdir', None, ['mkdir', '-p', dir]) + self.use_dir(dir) + + def create_copy_dir(self, src, dest): + """Remove a directory and recreate it as a copy from the given + source.""" + self.add_command_dir('copy-rm', None, ['rm', '-rf', dest]) + parent = os.path.dirname(dest) + self.add_command_dir('copy-mkdir', None, ['mkdir', '-p', parent]) + self.add_command_dir('copy', None, ['cp', '-a', src, dest]) + + def add_command_dir(self, desc, dir, command, always_run=False): + """Add a command to run in a given directory.""" + cmd = Command(self.desc_txt(desc), len(self.cmdlist), dir, self.path, + command, always_run) + self.cmdlist.append(cmd) + + def add_command(self, desc, command, always_run=False): + """Add a command to run in the default directory.""" + cmd = Command(self.desc_txt(desc), len(self.cmdlist), self.dir, + self.path, command, always_run) + self.cmdlist.append(cmd) + + def cleanup_dir(self, desc='cleanup', dir=None): + """Clean up a build directory. If no directory is specified, the + default directory is cleaned up and ceases to be the default + directory.""" + if dir is None: + dir = self.dir + self.use_dir(None) + if self.keep != 'all': + self.add_command_dir(desc, None, ['rm', '-rf', dir], + always_run=(self.keep == 'none')) + + def makefile_commands(self, wrapper, logsdir): + """Return the sequence of commands in the form of text for a Makefile. + The given wrapper script takes arguments: base of logs for + previous command, or empty; base of logs for this command; + description; directory; PATH addition; the command itself.""" + # prev_base is the base of the name for logs of the previous + # command that is not always-run (that is, a build command, + # whose failure should stop subsequent build commands from + # being run, as opposed to a cleanup command, which is run + # even if previous commands failed). + prev_base = '' + cmds = [] + for c in self.cmdlist: + ctxt = c.shell_make_quote() + if prev_base and not c.always_run: + prev_log = os.path.join(logsdir, prev_base) + else: + prev_log = '' + this_log = os.path.join(logsdir, c.logbase) + if not c.always_run: + prev_base = c.logbase + if c.dir is None: + dir = '' + else: + dir = c.dir + if c.path is None: + path = '' + else: + path = c.path + prelims = [wrapper, prev_log, this_log, c.desc, dir, path] + prelim_txt = Command.shell_make_quote_list(prelims, False) + cmds.append('\t@%s %s' % (prelim_txt, ctxt)) + return '\n'.join(cmds) + + def status_logs(self, logsdir): + """Return the list of log files with command status.""" + return [os.path.join(logsdir, '%s-status.txt' % c.logbase) + for c in self.cmdlist] + + +def get_parser(): + """Return an argument parser for this module.""" + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('-j', dest='parallelism', + help='Run this number of jobs in parallel', + type=int, default=os.cpu_count()) + parser.add_argument('--keep', dest='keep', + help='Whether to keep all build directories, ' + 'none or only those from failed builds', + default='none', choices=('none', 'all', 'failed')) + parser.add_argument('--replace-sources', action='store_true', + help='Remove and replace source directories ' + 'with the wrong version of a component') + parser.add_argument('--strip', action='store_true', + help='Strip installed glibc libraries') + parser.add_argument('topdir', + help='Toplevel working directory') + parser.add_argument('action', + help='What to do', + choices=('checkout', 'bot-cycle', 'bot', + 'host-libraries', 'compilers', 'glibcs')) + parser.add_argument('configs', + help='Versions to check out or configurations to build', + nargs='*') + return parser + + +def main(argv): + """The main entry point.""" + parser = get_parser() + opts = parser.parse_args(argv) + topdir = os.path.abspath(opts.topdir) + ctx = Context(topdir, opts.parallelism, opts.keep, opts.replace_sources, + opts.strip, opts.action) + ctx.run_builds(opts.action, opts.configs) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/REORG.TODO/scripts/check-c++-types.sh b/REORG.TODO/scripts/check-c++-types.sh new file mode 100755 index 0000000000..060242ece1 --- /dev/null +++ b/REORG.TODO/scripts/check-c++-types.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# Copyright (C) 2003-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# This script creates a list of data types where each type is followed +# by the C++ mangled name for that type. That list is then compared +# against the list in the c++-types.data file for the platform being +# checked. Any difference between the two would mean that the C++ ABI +# had changed and that should not happen even if the change is compatible +# at the C language level. + +# +# The list of data types has been created with +# cat <<EOF | +# #include <sys/types.h> +# #include <unistd.h> +# #include <sys/resource.h> +# #include <sys/stat.h> +# EOF +# gcc -D_GNU_SOURCE -E - | +# egrep '^typedef.*;$' | +# sed 's/^typedef[[:space:]]*//;s/\([[:space:]]\{1,\}__attribute__.*\);/;/;s/.*[[:space:]]\([*]\|\)\(.*\);/\2/' | +# egrep -v '^_' | +# LC_ALL=C sort -u +# +data=$1 +shift +cxx=$(echo $* | sed 's/-fgnu89-inline//') +while read t; do + echo -n "$t:" + $cxx -S -xc++ -o - -D_GNU_SOURCE <(cat <<EOF +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/resource.h> +#include <unistd.h> +void foo ($t) { } +EOF +) | + sed 's/[[:space:]]*[.]globa\?l[[:space:]]*_Z3foo\([_[:alnum:]]*\).*/\1/p;d' +done <<EOF | +blkcnt64_t +blkcnt_t +blksize_t +caddr_t +clockid_t +clock_t +daddr_t +dev_t +fd_mask +fsblkcnt64_t +fsblkcnt_t +fsfilcnt64_t +fsfilcnt_t +fsid_t +gid_t +id_t +ino64_t +ino_t +int16_t +int32_t +int64_t +int8_t +intptr_t +key_t +loff_t +mode_t +nlink_t +off64_t +off_t +pid_t +pthread_attr_t +pthread_barrier_t +pthread_barrierattr_t +pthread_cond_t +pthread_condattr_t +pthread_key_t +pthread_mutex_t +pthread_mutexattr_t +pthread_once_t +pthread_rwlock_t +pthread_rwlockattr_t +pthread_spinlock_t +pthread_t +quad_t +register_t +rlim64_t +rlim_t +sigset_t +size_t +socklen_t +ssize_t +suseconds_t +time_t +u_char +uid_t +uint +u_int +u_int16_t +u_int32_t +u_int64_t +u_int8_t +ulong +u_long +u_quad_t +useconds_t +ushort +u_short +EOF +diff -N -U0 $data - diff --git a/REORG.TODO/scripts/check-execstack.awk b/REORG.TODO/scripts/check-execstack.awk new file mode 100644 index 0000000000..21d37e9f47 --- /dev/null +++ b/REORG.TODO/scripts/check-execstack.awk @@ -0,0 +1,52 @@ +# This awk script expects to get command-line files that are each +# the output of 'readelf -l' on a single shared object. +# But the first file should contain just "execstack-no" or "execstack-yes", +# indicating what the default is in the absence of PT_GNU_STACK. +# It exits successfully (0) if none indicated executable stack. +# It fails (1) if any did indicate executable stack. +# It fails (2) if the input did not take the expected form. + +BEGIN { result = sanity = 0; default_exec = -1 } + +/^execstack-no$/ { default_exec = 0; next } +/^execstack-yes$/ { default_exec = 1; next } + +function check_one(name) { + if (default_exec == -1) { + print "*** missing execstack-default file?"; + result = 2; + } + + if (!sanity) { + print name ": *** input did not look like readelf -l output"; + result = 2; + } else if (stack_line) { + if (stack_line ~ /^.*RW .*$/) { + print name ": OK"; + } else if (stack_line ~ /^.*E.*$/) { + print name ": *** executable stack signaled"; + result = result ? result : 1; + } + } else if (default_exec) { + print name ": *** no PT_GNU_STACK entry"; + result = result ? result : 1; + } else { + print name ": no PT_GNU_STACK but default is OK"; + } + + sanity = 0; +} + +FILENAME != lastfile { + if (lastfile) + check_one(lastfile); + lastfile = FILENAME; +} + +$1 == "Type" && $7 == "Flg" { sanity = 1; stack_line = "" } +$1 == "GNU_STACK" { stack_line = $0 } + +END { + check_one(lastfile); + exit(result); +} diff --git a/REORG.TODO/scripts/check-installed-headers.sh b/REORG.TODO/scripts/check-installed-headers.sh new file mode 100644 index 0000000000..4cbef0ea49 --- /dev/null +++ b/REORG.TODO/scripts/check-installed-headers.sh @@ -0,0 +1,173 @@ +#! /bin/sh +# Copyright (C) 2016-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# Check installed headers for cleanliness. For each header, confirm +# that it's possible to compile a file that includes that header and +# does nothing else, in several different compilation modes. Also, +# scan the header for a set of obsolete typedefs that should no longer +# appear. + +# These compilation switches assume GCC or compatible, which is probably +# fine since we also assume that when _building_ glibc. +c_modes="-std=c89 -std=gnu89 -std=c11 -std=gnu11" +cxx_modes="-std=c++98 -std=gnu++98 -std=c++11 -std=gnu++11" + +# An exhaustive test of feature selection macros would take far too long. +# These are probably the most commonly used three. +lib_modes="-D_DEFAULT_SOURCE=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700" + +# sys/types.h+bits/types.h have to define the obsolete types. +# rpc(svc)/* have the obsolete types too deeply embedded in their API +# to remove. +skip_obsolete_type_check='*/sys/types.h|*/bits/types.h|*/rpc/*|*/rpcsvc/*' +obsolete_type_re=\ +'\<((__)?(quad_t|u(short|int|long|_(char|short|int([0-9]+_t)?|long|quad_t))))\>' + +if [ $# -lt 3 ]; then + echo "usage: $0 c|c++ \"compile command\" header header header..." >&2 + exit 2 +fi +case "$1" in + (c) + lang_modes="$c_modes" + cih_test_c=$(mktemp ${TMPDIR-/tmp}/cih_test_XXXXXX.c) + already="$skip_obsolete_type_check" + ;; + (c++) + lang_modes="$cxx_modes" + cih_test_c=$(mktemp ${TMPDIR-/tmp}/cih_test_XXXXXX.cc) + # The obsolete-type check can be skipped for C++; it is + # sufficient to do it for C. + already="*" + ;; + (*) + echo "usage: $0 c|c++ \"compile command\" header header header..." >&2 + exit 2;; +esac +shift +cc_cmd="$1" +shift +trap "rm -f '$cih_test_c'" 0 + +failed=0 +is_x86_64=unknown +is_x32=unknown +for header in "$@"; do + # Skip various headers for which this test gets a false failure. + case "$header" in + # bits/* are not meant to be included directly and usually #error + # out if you try it. + # regexp.h is a stub containing only an #error. + # Sun RPC's .x files are traditionally installed in + # $prefix/include/rpcsvc, but they are not C header files. + (bits/* | regexp.h | rpcsvc/*.x) + continue;; + + # All extant versions of sys/elf.h contain nothing more than an + # exhortation (either a #warning or an #error) to use sys/procfs.h + # instead, plus an inclusion of that header. + (sys/elf.h) + continue;; + + # sys/sysctl.h is unsupported for x32. + (sys/sysctl.h) + case "$is_x32" in + (yes) continue;; + (no) ;; + (unknown) + cat >"$cih_test_c" <<EOF +#if defined __x86_64__ && defined __ILP32__ +# error "is x32" +#endif +EOF + if $cc_cmd -fsyntax-only "$cih_test_c" > /dev/null 2>&1 + then + is_x32=no + else + is_x32=yes + continue + fi + ;; + esac + ;; + + # sys/vm86.h is "unsupported on x86-64" and errors out on that target. + (sys/vm86.h) + case "$is_x86_64" in + (yes) continue;; + (no) ;; + (unknown) + cat >"$cih_test_c" <<EOF +#if defined __x86_64__ && __x86_64__ +#error "is x86-64" +#endif +EOF + if $cc_cmd -fsyntax-only "$cih_test_c" > /dev/null 2>&1 + then + is_x86_64=no + else + is_x86_64=yes + continue + fi + ;; + esac + esac + + echo :: "$header" + for lang_mode in "" $lang_modes; do + for lib_mode in "" $lib_modes; do + echo :::: $lang_mode $lib_mode + if [ -z "$lib_mode" ]; then + expanded_lib_mode='/* default library mode */' + else + expanded_lib_mode=$(echo : $lib_mode | \ + sed 's/^: -D/#define /; s/=/ /') + fi + cat >"$cih_test_c" <<EOF +/* These macros may have been defined on the command line. They are + inappropriate for this test. */ +#undef _LIBC +#undef _GNU_SOURCE +/* The library mode is selected here rather than on the command line to + ensure that this selection wins. */ +$expanded_lib_mode +#include <$header> +int avoid_empty_translation_unit; +EOF + if $cc_cmd -fsyntax-only $lang_mode "$cih_test_c" 2>&1 + then + includes=$($cc_cmd -fsyntax-only -H $lang_mode \ + "$cih_test_c" 2>&1 | sed -ne 's/^[.][.]* //p') + for h in $includes; do + # Don't repeat work. + eval 'case "$h" in ('"$already"') continue;; esac' + + if grep -qE "$obsolete_type_re" "$h"; then + echo "*** Obsolete types detected:" + grep -HE "$obsolete_type_re" "$h" + failed=1 + fi + already="$already|$h" + done + else + failed=1 + fi + done + done +done +exit $failed diff --git a/REORG.TODO/scripts/check-local-headers.sh b/REORG.TODO/scripts/check-local-headers.sh new file mode 100755 index 0000000000..7859f613b2 --- /dev/null +++ b/REORG.TODO/scripts/check-local-headers.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# Copyright (C) 2005-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. +# +includedir="$1" +objpfx="$2" + +# To avoid long paths. +cd "$objpfx" + +# OK if *.os is missing. +shopt -s nullglob + +# Search all dependency files for file names in the include directory. +# There are a few system headers we are known to use. +# These include Linux kernel headers (asm*, arch, and linux), +# and Mach kernel headers (mach). +exec ${AWK} -v includedir="$includedir" ' +BEGIN { + status = 0 + exclude = "^" includedir \ + "/(.*-.*-.*/|.*-.*/|)(asm[-/]|arch|linux/|selinux/|mach/|mach_debug/|device/|hurd/(((hurd|ioctl)_types|paths)\\.h|ioctls\\.defs|ihash\\.h)|cthreads\\.h|gd|nss3/|c\\+\\+/|sys/(capability|sdt(|-config))\\.h|libaudit\\.h)" +} +/^[^ ]/ && $1 ~ /.*:/ { obj = $1 } +{ + for (i = 1; i <= NF; ++i) { + if ($i ~ ("^" includedir) && $i !~ exclude) { + print "***", obj, "uses", $i + status = 1 + } + } +} +END { exit status }' */*.{o,os,oS}.d diff --git a/REORG.TODO/scripts/check-localplt.awk b/REORG.TODO/scripts/check-localplt.awk new file mode 100644 index 0000000000..3965292888 --- /dev/null +++ b/REORG.TODO/scripts/check-localplt.awk @@ -0,0 +1,83 @@ +# This is an awk script to process the output of elf/check-localplt. +# The first file argument is the file of expected results. +# Each line is either a comment starting with # or it looks like: +# libfoo.so: function +# or +# libfoo.so: function + {RELA|REL} RELOC +# or +# libfoo.so: function ? +# The first entry means that one is required. +# The second entry means that one is required and relocation may also be +# {RELA|REL} RELOC. +# The third entry means that a PLT entry for function is optional in +# libfoo.so. +# The second file argument is - and this (stdin) receives the output +# of the check-localplt program. + +BEGIN { result = 0 } + +FILENAME != "-" && /^#/ { next } + +FILENAME != "-" { + if (NF == 5 && $3 == "+" && ($4 == "RELA" || $4 == "REL")) { + accept_type[$1 " " $2] = $4; + accept_reloc[$1 " " $2] = $5; + } else if (NF != 2 && !(NF == 3 && $3 == "?")) { + printf "%s:%d: bad data line: %s\n", FILENAME, FNR, $0 > "/dev/stderr"; + result = 2; + } else { + accept[$1 " " $2] = NF == 2; + } + next; +} + +NF != 2 && !(NF == 4 && ($3 == "RELA" || $3 == "REL")) { + print "Unexpected output from check-localplt:", $0 > "/dev/stderr"; + result = 2; + next +} + +{ + key = $1 " " $2 + if ($3 == "RELA" || $3 == "REL") { + # Entries like: + # libc.so: free + RELA R_X86_64_GLOB_DAT + # may be ignored. + if (key in accept_type && accept_type[key] == $3 && accept_reloc[key] == $4) { + # Match + # libc.so: free + RELA R_X86_64_GLOB_DAT + delete accept_type[key] + } + } else if (NF == 2 && key in accept_reloc) { + # Match + # libc.so: free + # against + # libc.so: free + RELA R_X86_64_GLOB_DAT + if (key in accept_type) + delete accept_type[key] + } else if (key in accept) { + delete accept[key] + } else { + print "Extra PLT reference:", $0; + if (result == 0) + result = 1; + } +} + +END { + for (key in accept) { + if (accept[key]) { + # It's mandatory. + print "Missing required PLT reference:", key; + result = 1; + } + } + + for (key in accept_type) { + # It's mandatory. + print "Missing required PLT or " accept_reloc[key] " reference:", key; + result = 1; + } + + exit(result); +} diff --git a/REORG.TODO/scripts/check-textrel.awk b/REORG.TODO/scripts/check-textrel.awk new file mode 100644 index 0000000000..e7f2d70084 --- /dev/null +++ b/REORG.TODO/scripts/check-textrel.awk @@ -0,0 +1,41 @@ +# This awk script expects to get command-line files that are each +# the output of 'readelf -d' on a single shared object. +# It exits successfully (0) if none contained any TEXTREL markers. +# It fails (1) if any did contain a TEXTREL marker. +# It fails (2) if the input did not take the expected form. + +BEGIN { result = textrel = sanity = 0 } + +function check_one(name) { + if (!sanity) { + print name ": *** input did not look like readelf -d output"; + result = 2; + } else if (textrel) { + print name ": *** text relocations used"; + result = result ? result : 1; + } else { + print name ": OK"; + } + + textrel = sanity = 0; +} + +FILENAME != lastfile { + if (lastfile) + check_one(lastfile); + lastfile = FILENAME; +} + +$1 == "Tag" && $2 == "Type" { sanity = 1 } +$2 == "(TEXTREL)" { textrel = 1 } +$2 == "(FLAGS)" { + for (i = 3; i <= NF; ++i) { + if ($i == "TEXTREL") + textrel = 1; + } +} + +END { + check_one(lastfile); + exit(result); +} diff --git a/REORG.TODO/scripts/config-uname.sh b/REORG.TODO/scripts/config-uname.sh new file mode 100755 index 0000000000..cf32ca53bf --- /dev/null +++ b/REORG.TODO/scripts/config-uname.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +config_os=$1 +config_release=$2 +uname_machine=$3 + +uname_sysname=`echo $config_os | sed 's/[0-9.]*$//'` +if test $uname_sysname != $config_os; then + config_release=`echo $config_os | sed s/$uname_sysname//` +fi + +if test -r /vmunix; then + kernel_id=`strings /vmunix | grep UNIX` +elif test -r /dynix; then + kernel_id=`strings /dynix | grep DYNIX` +else + kernel_id= +fi + +kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'` +if test x`echo "$config_release" | sed "s/^$kernel_release//"` \ + != x$config_release; then + # The configuration release is a substring of the kernel release. + uname_release=$kernel_release +elif test x$config_release != x; then + uname_release=$config_release +elif test x$kernel_release != x; then + uname_release=$kernel_release +else + uname_release=unknown +fi + +kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'` +if test -n "$kernel_version"; then + uname_version="$kernel_version" +else + uname_version=unknown +fi + +cat <<EOF +/* This file is generated by $0. DO NOT EDIT. + + This is used only by the generic uname function for systems with no real + uname call. If this data is not correct, it does not matter much. */ + +#define UNAME_SYSNAME "$uname_sysname" +#define UNAME_RELEASE "$uname_release" +#define UNAME_VERSION "$uname_version" +#define UNAME_MACHINE "$uname_machine" +EOF diff --git a/REORG.TODO/scripts/config.guess b/REORG.TODO/scripts/config.guess new file mode 100755 index 0000000000..bbd48b60e8 --- /dev/null +++ b/REORG.TODO/scripts/config.guess @@ -0,0 +1,1462 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-01-01' + +# This file 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, see <http://www.gnu.org/licenses/>. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to <config-patches@gnu.org>. + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2017 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include <features.h> + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case "${UNAME_MACHINE_ARCH}" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = hppa2.0w ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + k1om:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = 386; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; +esac + +cat >&2 <<EOF +$0: unable to guess system type + +This script (version $timestamp), has failed to recognize the +operating system you are using. If your script is old, overwrite +config.guess and config.sub with the latest versions from: + + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +and + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/REORG.TODO/scripts/config.sub b/REORG.TODO/scripts/config.sub new file mode 100755 index 0000000000..7e792b4ae1 --- /dev/null +++ b/REORG.TODO/scripts/config.sub @@ -0,0 +1,1828 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-01-01' + +# This file 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, see <http://www.gnu.org/licenses/>. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to <config-patches@gnu.org>. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2017 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -ios) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + pru-*) + os=-elf + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/REORG.TODO/scripts/cpp b/REORG.TODO/scripts/cpp new file mode 100755 index 0000000000..cb24fe2bba --- /dev/null +++ b/REORG.TODO/scripts/cpp @@ -0,0 +1,6 @@ +#!/bin/sh + +# This script is used solely by rpcgen when run by sunrpc/Makefile, +# which passes CPP in the environment to tell us what to run. + +exec ${CPP} "$@" diff --git a/REORG.TODO/scripts/cross-test-ssh.sh b/REORG.TODO/scripts/cross-test-ssh.sh new file mode 100755 index 0000000000..140fed97ef --- /dev/null +++ b/REORG.TODO/scripts/cross-test-ssh.sh @@ -0,0 +1,135 @@ +#!/bin/bash +# Run a testcase on a remote system, via ssh. +# Copyright (C) 2012-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# usage: cross-test-ssh.sh [--ssh SSH] HOST COMMAND ... +# Run with --help flag to get more detailed help. + +progname="$(basename $0)" + +usage="usage: ${progname} [--ssh SSH] HOST COMMAND ..." +help="Run a glibc test COMMAND on the remote machine HOST, via ssh, +preserving the current working directory, and respecting quoting. + +If the '--ssh SSH' flag is present, use SSH as the SSH command, +instead of ordinary 'ssh'. + +If the '--timeoutfactor FACTOR' flag is present, set TIMEOUTFACTOR on +the remote machine to the specified FACTOR. + +To use this to run glibc tests, invoke the tests as follows: + + $ make test-wrapper='ABSPATH/cross-test-ssh.sh HOST' tests + +where ABSPATH is the absolute path to this script, and HOST is the +name of the machine to connect to via ssh. + +If you need to connect to the test machine as a different user, you +may specify that just as you would to SSH: + + $ make test-wrapper='ABSPATH/cross-test-ssh.sh USER@HOST' tests + +Naturally, the remote user must have an appropriate public key, and +you will want to ensure that SSH does not prompt interactively for a +password on each connection. + +HOST and the build machines (on which 'make check' is being run) must +share a filesystem; all files needed by the tests must be visible at +the same paths on both machines. + +${progname} runs COMMAND in the same directory on the HOST that +${progname} itself is run in on the build machine. + +The command and arguments are passed to the remote host in a way that +avoids any further shell substitution or expansion, on the assumption +that the shell on the build machine has already done them +appropriately." + +ssh='ssh' +timeoutfactor=$TIMEOUTFACTOR +while [ $# -gt 0 ]; do + case "$1" in + + "--ssh") + shift + if [ $# -lt 1 ]; then + break + fi + ssh="$1" + ;; + + "--timeoutfactor") + shift + if [ $# -lt 1 ]; then + break + fi + timeoutfactor="$1" + ;; + + "--help") + echo "$usage" + echo "$help" + exit 0 + ;; + + *) + break + ;; + esac + shift +done + +if [ $# -lt 1 ]; then + echo "$usage" >&2 + echo "Type '${progname} --help' for more detailed help." >&2 + exit 1 +fi + +host="$1"; shift + +# Print the sequence of arguments as strings properly quoted for the +# Bourne shell, separated by spaces. +bourne_quote () +{ + local arg qarg + for arg in "$@"; do + qarg=${arg//\'/\'\\\'\'} + echo -n "'$qarg' " + done +} + +# Transform the current argument list into a properly quoted Bourne shell +# command string. +command="$(bourne_quote "$@")" + +# Add command to set the current directory. +command="cd $(bourne_quote "$PWD") +${command}" + +# Add command to set the timeout factor, if required. +if [ "$timeoutfactor" ]; then + command="export TIMEOUTFACTOR=$(bourne_quote "$timeoutfactor") +${command}" +fi + +# HOST's sshd simply concatenates its arguments with spaces and +# passes them to some shell. We want to force the use of /bin/sh, +# so we need to re-quote the whole command to ensure it appears as +# the sole argument of the '-c' option. +full_command="$(bourne_quote "${command}")" +$ssh "$host" /bin/sh -c "$full_command" diff --git a/REORG.TODO/scripts/documented.sh b/REORG.TODO/scripts/documented.sh new file mode 100644 index 0000000000..047a1d3493 --- /dev/null +++ b/REORG.TODO/scripts/documented.sh @@ -0,0 +1,102 @@ +#!/bin/sh +bindir=$1 + +VERSION=1.0 + +egrep -h @deftypefu?nx? *.texi ../linuxthreads/*.texi | +sed -e 's/@deftypefunx*[[:space:]]*\({[^{]*}\|[[:alnum:]_]*\)[[:space:]]*\([[:alnum:]_]*\).*/\2/' -e 's/@deftypefn {[^}]*function}*[[:space:]]*\({[^{]*}\|[[:alnum:]_]*\)[[:space:]]*\([[:alnum:]_]*\).*/\2/' -e '/^@/d' | +sed -e '/^obstack_/d' -e '/^\([lf]\|\)stat\(\|64\)$/d' -e '/^mknod$/d' | +sed -e '/^signbit$/d' -e '/^sigsetjmp$/d' | +sed -e '/^pthread_cleanup/d' -e '/^IFTODT$/d' -e '/^DTTOIF$/d' | +sed -e '/^__fwriting$/d' -e '/^__fwritable$/d' -e '/^__fsetlocking$/d' | +sed -e '/^__freading$/d' -e '/^__freadable$/d' -e '/^__fpurge$/d' | +sed -e '/^__fpending$/d' -e '/^__flbf$/d' -e '/^__fbufsize$/d' | +sed -e '/^alloca$/d' | +sort -u > DOCUMENTED + +nm --extern --define $bindir/libc.so $bindir/math/libm.so $bindir/rt/librt.so $bindir/linuxthreads/libpthread.so $bindir/dlfcn/libdl.so $bindir/crypt/libcrypt.so $bindir/login/libutil.so | +egrep " [TW] ([[:alpha:]]|_[[:alpha:]])" | +sed 's/\(@.*\)//' | +cut -b 12- | +sed -e '/^_IO/d' -e '/^_dl/d' -e '/^_pthread/d' -e '/^_obstack/d' | +sed -e '/^_argp/d' -e '/^_authenticate$/d' -e '/^_environ$/d' | +sed -e '/^_errno$/d' -e '/^_h_errno$/d' -e '/^_longjmp$/d' | +sed -e '/^_mcleanup$/d' -e '/^_rpc_dtablesize$/d' -e '/^_seterr_reply$/d' | +sed -e '/^_nss/d' -e '/^_setjmp$/d' | +sort -u > AVAILABLE + +cat <<EOF +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> + <head> + <title>Undocumented glibc functions</title> + </head> + + <body> + <center><h1>Undocumented <tt>glibc</tt> functions</h1></center> + + <p>The following table includes names of the function in glibc + which are not yet documented in the manual. This list is + automatically created and therefore might contain errors. Please + check the latest manual (available from the CVS archive) before + starting to work. It might also be good to let me know in + advanace on which functions you intend to work to avoid + duplication.</p> + + <p>A few comments:</p> + + <ul> + <li>Some functions in the list are much less important than + others. Please prioritize.</li> + + <li>Similarly for the LFS functions (those ending in 64).</li> + </ul> + + <p>The function sombody already volunteered to document are marked + with a reference to the person.</p> + + <center><table> +EOF + +n=0 +diff -y --width=60 --suppress-common-lines DOCUMENTED AVAILABLE | +expand | cut -b 33- | sed '/^[[:space:]]*$/d' | +while read name; do + line="$line +<td><tt>$name</tt></td>" + n=$(expr $n + 1) + if [ $n -eq 4 ]; then + echo "<tr> +$line +</tr>" + line="" + n=0 + fi +done +if [ $n -gt 0 ]; then + if [ $n -eq 1 ]; then + line="$line +<td></td>" + fi + if [ $n -eq 2 ]; then + line="$line +<td></td>" + fi + if [ $n -eq 3 ]; then + line="$line +<td></td>" + fi + echo "<tr> +$line +</tr>" +fi + +cat <<EOF + </table></center> + + <hr> + <address><a href="mailto:drepper@redhat.com">Ulrich Drepper</a></address> +Generated on $(date) with documented.sh version $VERSION + </body> +</html> +EOF diff --git a/REORG.TODO/scripts/evaluate-test.sh b/REORG.TODO/scripts/evaluate-test.sh new file mode 100755 index 0000000000..0abd41abb3 --- /dev/null +++ b/REORG.TODO/scripts/evaluate-test.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# Output a test status line. +# Copyright (C) 2012-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# usage: evaluate-test.sh test_name rc xfail stop_on_failure + +test_name=$1 +rc=$2 +orig_rc=$rc +xfail=$3 +stop_on_failure=$4 + +if [ $rc -eq 77 ]; then + result="UNSUPPORTED" + rc=0 +else + if [ $rc -eq 0 ]; then + result="PASS" + else + result="FAIL" + fi + + if $xfail; then + result="X$result" + rc=0 + fi +fi + +echo "$result: $test_name" +echo "original exit status $orig_rc" +if $stop_on_failure; then + exit $rc +else + exit 0 +fi diff --git a/REORG.TODO/scripts/firstversions.awk b/REORG.TODO/scripts/firstversions.awk new file mode 100644 index 0000000000..ccde4b59b4 --- /dev/null +++ b/REORG.TODO/scripts/firstversions.awk @@ -0,0 +1,89 @@ +# Script to preprocess Versions.all lists based on "earliest version" +# specifications in the shlib-versions file. + +# Return -1, 0 or 1 according to whether v1 is less than, equal to or +# greater than v2 as a version string. Simplified from GNU Autoconf +# version; this one does not need to handle .0x fraction-style versions. +function vers_compare (v1, v2) +{ + while (length(v1) && length(v2)) { + if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) { + for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue; + for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue; + d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1); + d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1); + d1 += 0; + d2 += 0; + } else { + d1 = substr(v1, 1, 1); v1 = substr(v1, 2); + d2 = substr(v2, 1, 1); v2 = substr(v2, 2); + } + if (d1 < d2) return -1; + if (d1 > d2) return 1; + } + if (length(v2)) return -1; + if (length(v1)) return 1; + return 0; +} + +NF > 2 && $2 == ":" { + for (i = 0; i <= NF - 3; ++i) + firstversion[$1, i] = $(3 + i); + idx[$1] = 0; + next; +} + +NF == 2 && $2 == "{" { thislib = $1; print; next } + +$1 == "}" { + if ((thislib, idx[thislib]) in firstversion) { + # We haven't seen the stated version, but have produced + # others pointing to it, so we synthesize it now. + printf " %s\n", firstversion[thislib, idx[thislib]]; + idx[thislib]++; + } + print; + next; +} + +/GLIBC_PRIVATE/ { print; next } + +{ + if ((thislib, idx[thislib]) in firstversion) { + f = v = firstversion[thislib, idx[thislib]]; + while (vers_compare($1, v) >= 0) { + delete firstversion[thislib, idx[thislib]]; + idx[thislib]++; + if ((thislib, idx[thislib]) in firstversion) { + # If we're skipping a referenced version to jump ahead to a + # later version, synthesize the earlier referenced version now. + if (v != $1 && (thislib, v) in usedversion) + print " " v; + v = firstversion[thislib, idx[thislib]]; + } else + break; + } + if ($1 == v || $1 == f) + # This version was the specified earliest version itself. + print; + else if (vers_compare($1, v) < 0) { + # This version is older than the specified earliest version. + print " " $1, "=", v; + # Record that V has been referred to, so we will be sure to emit it + # if we hit a later one without hitting V itself. + usedversion[thislib, v] = 1; + } + else { + # This version is newer than the specified earliest version. + # We haven't seen that version itself or else we wouldn't be here + # because we would have removed it from the firstversion array. + # If there were any earlier versions that used that one, emit it now. + if ((thislib, v) in usedversion) { + print " " v; + } + print " " $1; + } + } + else + print; +} diff --git a/REORG.TODO/scripts/gen-as-const.awk b/REORG.TODO/scripts/gen-as-const.awk new file mode 100644 index 0000000000..1ffd5f2c1c --- /dev/null +++ b/REORG.TODO/scripts/gen-as-const.awk @@ -0,0 +1,63 @@ +# Script used in producing headers of assembly constants from C expressions. +# The input to this script looks like: +# #cpp-directive ... +# NAME1 +# NAME2 expression ... +# The output of this script is C code to be run through gcc -S and then +# massaged to extract the integer constant values of the given C expressions. +# A line giving just a name implies an expression consisting of just that name. + +BEGIN { started = 0 } + +# cpp directives go straight through. +/^#/ { print; next } + +NF >= 1 && !started { + if (test) { + print "\n#include <inttypes.h>"; + print "\n#include <stdio.h>"; + print "\n#include <bits/wordsize.h>"; + print "\n#if __WORDSIZE == 64"; + print "\ntypedef uint64_t c_t;"; + print "\n#define U(n) UINT64_C (n)"; + print "\n#define PRI PRId64"; + print "\n#else"; + print "\ntypedef uint32_t c_t;"; + print "\n#define U(n) UINT32_C (n)"; + print "\n#define PRI PRId32"; + print "\n#endif"; + print "\nstatic int do_test (void)\n{\n int bad = 0, good = 0;\n"; + print "#define TEST(name, source, expr) \\\n" \ + " if (U (asconst_##name) != (c_t) (expr)) { ++bad;" \ + " fprintf (stderr, \"%s: %s is %\" PRI \" but %s is %\"PRI \"\\n\"," \ + " source, #name, U (asconst_##name), #expr, (c_t) (expr));" \ + " } else ++good;\n"; + } + else + print "void dummy(void) {"; + started = 1; +} + +# Separator. +$1 == "--" { next } + +NF == 1 { sub(/^.*$/, "& &"); } + +NF > 1 { + name = $1; + sub(/^[^ ]+[ ]+/, ""); + if (test) + print " TEST (" name ", \"" FILENAME ":" FNR "\", " $0 ")"; + else + printf "asm (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" ((long) %s));\n", + name, $0; +} + +END { + if (test) { + print " printf (\"%d errors in %d tests\\n\", bad, good + bad);" + print " return bad != 0 || good == 0;\n}\n"; + print "#define TEST_FUNCTION do_test ()"; + } + else if (started) print "}"; +} diff --git a/REORG.TODO/scripts/gen-libc-abis b/REORG.TODO/scripts/gen-libc-abis new file mode 100644 index 0000000000..c5537645dc --- /dev/null +++ b/REORG.TODO/scripts/gen-libc-abis @@ -0,0 +1,26 @@ +#!/bin/sh +triple="$1" + +printf "#ifndef _LIBC_ABIS_H\n#define _LIBC_ABIS_H 1\n\n" +printf "enum\n{\n LIBC_ABI_DEFAULT = 0,\n" + +while read s t; do + if test "$s" = "#" || test -z "$s"; then continue; fi + if test -z "$t"; then + printf " LIBC_ABI_%s,\n" "$s" + features="$features $s" + else + case "$triple" in + $t) printf " LIBC_ABI_%s,\n" "$s" + features="$features $s" ;; + *) ;; + esac + fi +done + +printf " LIBC_ABI_MAX\n};\n" +printf "\n#endif\n" + +if test -n "$features"; then + printf "#define LIBC_ABIS_STRING \"libc ABIs:%s\\\\n\"\n" "$features" +fi diff --git a/REORG.TODO/scripts/gen-libc-modules.awk b/REORG.TODO/scripts/gen-libc-modules.awk new file mode 100644 index 0000000000..2f92cd41b2 --- /dev/null +++ b/REORG.TODO/scripts/gen-libc-modules.awk @@ -0,0 +1,34 @@ +# Generate a header file that defines the MODULE_* macros for each library and +# module we build in glibc. The library names are pulled in from soversions.i +# and the additional modules are passed in the BUILDLIST variable. +BEGIN { + # BUILDLIST is set from the build-list variable in Makeconfig and is a space + # separated list of non-library modules that we build in glibc. + num = split (buildlist, libs, " ") + # Separate the built modules from the libraries. + libs[++num] = "LIBS_BEGIN" +} + +# Skip over comments. +$1 == "#" { + next +} + +# We have only one special case in soversions.i parsing, which is to replace ld +# with rtld since that's what we call it throughout the sources. +match (FILENAME, ".*soversions.i") { + name = $2 + if (name == "ld") + name = "rtld" + + # Library names are not duplicated in soversions.i. + libs[++num] = name +} + +# Finally, print out the header file. +END { + printf ("/* AUTOGENERATED BY gen-libc-modules.awk, DO NOT EDIT. */\n\n") + for (l in libs) { + printf ("#define MODULE_%s %d\n", libs[l], l) + } +} diff --git a/REORG.TODO/scripts/gen-posix-conf-vars.awk b/REORG.TODO/scripts/gen-posix-conf-vars.awk new file mode 100644 index 0000000000..9a4c54256a --- /dev/null +++ b/REORG.TODO/scripts/gen-posix-conf-vars.awk @@ -0,0 +1,86 @@ +# Generate posix-conf-vars-def.h with definitions for CONF_DEF{CONF} for each +# configuration variable that getconf or sysconf may use. Currently it is +# equipped only to generate such macros for specification macros and for +# SYSCONF macros in the _POSIX namespace. + +BEGIN { + prefix = "" +} + +$1 ~ /^#/ || $0 ~ /^\s*$/ { + next +} + +# Begin a new prefix. +$NF == "{" { + type = $1 + prefix = $2 + + if (NF == 4) + sc_prefix = $3 + else + sc_prefix = "_SC" + + next +} + +$1 == "}" { + prefix = "" + type = "" + sc_prefix = "" + next +} + +{ + if (prefix == "" && type == "" && sc_prefix == "") { + printf ("Syntax error at %s:%d\n", FILENAME, FNR) > "/dev/stderr" + exit 1 + } + + # The prefix and variable names are indices and the value indicates what type + # of variable it is. The possible options are: + # CONFSTR: A configuration string + # SYSCONF: A numeric value + # SPEC: A specification + c = prefix "_" $1 + sc_prefixes[c] = sc_prefix + prefix_conf[c] = type + conf[c] = $1 +} + +END { + print "/* AUTOGENERATED by gen-posix-conf-vars.awk. DO NOT EDIT. */\n" + + # Generate macros that specify if a sysconf macro is defined and/or set. + for (c in prefix_conf) { + printf "#ifndef _%s\n", c + printf "# define CONF_DEF_%s CONF_DEF_UNDEFINED\n", c + # CONFSTR have string values and they are not set or unset. + if (prefix_conf[c] != "CONFSTR") { + printf "#else\n" + printf "# if _%s > 0\n", c + printf "# define CONF_DEF_%s CONF_DEF_DEFINED_SET\n", c + printf "# else\n" + printf "# define CONF_DEF_%s CONF_DEF_DEFINED_UNSET\n", c + printf "# endif\n" + } + printf "#endif\n\n" + + # Build a name -> sysconf number associative array to print a C array at + # the end. + if (prefix_conf[c] == "SPEC") + spec[c] = sc_prefixes[c] "_" conf[c] + } + + # Print the specification array. Define the macro NEED_SPEC_ARRAY before + # including posix-conf-vars.h to make it available in the compilation unit. + print "#if NEED_SPEC_ARRAY" + print "static const struct { const char *name; int num; } specs[] =" + print " {" + for (s in spec) { + printf " { \"%s\", %s },\n", s, spec[s] + } + print " };" + print "static const size_t nspecs = sizeof (specs) / sizeof (specs[0]);" + print "#endif" +} diff --git a/REORG.TODO/scripts/gen-py-const.awk b/REORG.TODO/scripts/gen-py-const.awk new file mode 100644 index 0000000000..694b8a5fd0 --- /dev/null +++ b/REORG.TODO/scripts/gen-py-const.awk @@ -0,0 +1,118 @@ +# Script to generate constants for Python pretty printers. +# +# Copyright (C) 2016-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# This script is a smaller version of the clever gen-asm-const.awk hack used to +# generate ASM constants from .sym files. We'll use this to generate constants +# for Python pretty printers. +# +# The input to this script are .pysym files that look like: +# #C_Preprocessor_Directive... +# NAME1 +# NAME2 expression... +# +# A line giving just a name implies an expression consisting of just that name. +# Comments start with '--'. +# +# The output of this script is a 'dummy' function containing 'asm' declarations +# for each non-preprocessor line in the .pysym file. The expression values +# will appear as input operands to the 'asm' declaration. For example, if we +# have: +# +# /* header.h */ +# #define MACRO 42 +# +# struct S { +# char c1; +# char c2; +# char c3; +# }; +# +# enum E { +# ZERO, +# ONE +# }; +# +# /* symbols.pysym */ +# #include <stddef.h> +# #include "header.h" +# -- This is a comment +# MACRO +# C3_OFFSET offsetof(struct S, c3) +# E_ONE ONE +# +# the output will be: +# +# #include <stddef.h> +# #include "header.h" +# void dummy(void) +# { +# asm ("@name@MACRO@value@%0@" : : "i" (MACRO)); +# asm ("@name@C3_OFFSET@value@%0@" : : "i" (offsetof(struct S, c3))); +# asm ("@name@E_ONE@value@%0@" : : "i" (ONE)); +# } +# +# We'll later feed this output to gcc -S. Since '-S' tells gcc to compile but +# not assemble, gcc will output something like: +# +# dummy: +# ... +# @name@MACRO@value@$42@ +# @name@C3_OFFSET@value@$2@ +# @name@E_ONE@value@$1@ +# +# Finally, we can process that output to extract the constant values. +# Notice gcc may prepend a special character such as '$' to each value. + +# found_symbol indicates whether we found a non-comment, non-preprocessor line. +BEGIN { found_symbol = 0 } + +# C preprocessor directives go straight through. +/^#/ { print; next; } + +# Skip comments. +/--/ { next; } + +# Trim leading whitespace. +{ sub(/^[[:blank:]]*/, ""); } + +# If we found a non-comment, non-preprocessor line, print the 'dummy' function +# header. +NF > 0 && !found_symbol { + print "void dummy(void)\n{"; + found_symbol = 1; +} + +# If the line contains just a name, duplicate it so we can use that name +# as the value of the expression. +NF == 1 { sub(/^.*$/, "& &"); } + +# If a line contains a name and an expression... +NF > 1 { + name = $1; + + # Remove any characters before the second field. + sub(/^[^[:blank:]]+[[:blank:]]+/, ""); + + # '$0' ends up being everything that appeared after the first field + # separator. + printf " asm (\"@name@%s@value@%0@\" : : \"i\" (%s));\n", name, $0; +} + +# Close the 'dummy' function. +END { if (found_symbol) print "}"; } diff --git a/REORG.TODO/scripts/gen-rrtypes.py b/REORG.TODO/scripts/gen-rrtypes.py new file mode 100644 index 0000000000..ec71e9fc46 --- /dev/null +++ b/REORG.TODO/scripts/gen-rrtypes.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 +# Generate DNS RR type constants for resolv header files. +# Copyright (C) 2016-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +"""Generate DNS RR type constants for resolv header files. + +resolv/arpa/nameser.h and resolv/arpa/nameser_compat.h contain lists +of RR type constants. This script downloads the current definitions +from the IANA DNS Parameters protocol registry and translates it into +the two different lists. + +Two lists are written to standard output. The first one contains enum +constants for resolv/arpa/nameser.h. The second one lists the +preprocessor macros for resolv/arpa/nameser_compat.h. + +""" + +# URL of the IANA registry. +source = "http://www.iana.org/assignments/dns-parameters/dns-parameters-4.csv" + +import collections +import csv +import io +import urllib.request + +Type = collections.namedtuple("Type", "name number comment") + +def get_types(source): + for row in csv.reader(io.TextIOWrapper(urllib.request.urlopen(source))): + if row[0] in ('TYPE', 'Unassigned', 'Private use', 'Reserved'): + continue + name, number, comment = row[:3] + if name == '*': + name = 'ANY' + comment = 'request for all cached records' + number = int(number) + yield Type(name, number, comment) + +types = list(get_types(source)) + +print("// enum constants for resolv/arpa/nameser.h") +print() +for typ in types: + name = typ.name.replace("-", "_").lower() + print(" ns_t_{0} = {1.number},".format(name, typ)) +print() + +print("// macro aliases resolv/arpa/nameser_compat.h") +print() +for typ in types: + name = typ.name.replace("-", "_") + print("#define T_{0} ns_t_{1}".format(name.upper(), name.lower())) +print() diff --git a/REORG.TODO/scripts/gen-sorted.awk b/REORG.TODO/scripts/gen-sorted.awk new file mode 100755 index 0000000000..922eafcc2d --- /dev/null +++ b/REORG.TODO/scripts/gen-sorted.awk @@ -0,0 +1,139 @@ +#!/usr/bin/awk -f +# Generate sorted list of directories. The sorting is stable but with +# dependencies between directories resolved by moving dependees in front. +# Copyright (C) 1998-2017 Free Software Foundation, Inc. +# Written by Ulrich Drepper <drepper@cygnus.com>, 1998. + +BEGIN { + cnt = split(subdirs, all) + 1 + dnt = 0 +} + +# Let input files have comments. +{ sub(/[ ]*#.*$/, "") } +NF == 0 { next } + +{ + subdir = type = FILENAME; + sub(/^.*\//, "", type); + sub(/\/[^/]+$/, "", subdir); + sub(/^.*\//, "", subdir); + thisdir = ""; +} + +type == "Depend" && NF == 1 { + from[dnt] = subdir; + to[dnt] = $1; + ++dnt; + next +} + +type == "Subdirs" && NF == 1 { thisdir = $1 } + +type == "Subdirs" && NF == 2 && $1 == "first" { + thisdir = $2; + # Make the first dir in the list depend on this one. + from[dnt] = all[1]; + to[dnt] = thisdir; + ++dnt; +} + +type == "Subdirs" && NF == 2 && $1 == "inhibit" { + inhibit[$2] = subdir; + next +} + +type == "Subdirs" && thisdir { + all[cnt++] = thisdir; + + if (FILENAME ~ (srcpfx ? /^\.\.\/sysdeps\// : /^sysdeps\//) \ + || system("test -d " srcpfx thisdir) == 0) { + # This Subdirs file is in the main source tree, + # or this subdirectory exists in the main source tree. + this_srcdir = srcpfx thisdir + } + else { + # The Subdirs file comes from an add-on that should have the subdirectory. + dir = FILENAME; + do + sub(/\/[^/]+$/, "", dir); + while (dir !~ /\/sysdeps$/); + sub(/\/sysdeps$/, "", dir); + if (system("test -d " dir "/" thisdir) == 0) + dir = dir "/" thisdir; + else { + sub(/\/[^/]+$/, "", dir); + if (system("test -d " dir "/" thisdir) == 0) + dir = dir "/" thisdir; + else { + print FILENAME ":" FNR ":", "cannot find", thisdir > "/dev/stderr"; + exit 2 + } + } + file = dir "/Depend"; + if (srcpfx) + sub(/^\.\.\//, "", dir); + if (dir !~ /^\/.*$/) + dir = "$(..)" dir; + print thisdir "-srcdir", ":=", dir; + } + file = this_srcdir "/Depend"; + if (system("test -f " file) == 0) { + ARGV[ARGC++] = file; + # Emit a dependency on the implicitly-read file. + if (srcpfx) + sub(/^\.\.\//, "", file); + if (file !~ /^\/.*$/) + file = "$(..)" file; + print "$(common-objpfx)sysd-sorted:", "$(wildcard", file ")"; + } + next +} + +{ + print FILENAME ":" FNR ":", "what type of file is this?" > "/dev/stderr"; + exit 2 +} + +END { + do { + moved = 0 + for (i = 0; i < dnt; ++i) { + for (j = 1; j < cnt; ++j) { + if (all[j] == from[i]) { + for (k = j + 1; k < cnt; ++k) { + if (all[k] == to[i]) { + break; + } + } + if (k < cnt) { + for (l = k - 1; l >= j; --l) { + all[l + 1] = all[l] + } + all[j] = to[i] + break; + } + } + } + if (j < cnt) { + moved = 1 + break + } + } + } while (moved); + + # Make sure we list "elf" last. + saw_elf = 0; + printf "sorted-subdirs :="; + for (i = 1; i < cnt; ++i) { + if (all[i] in inhibit) + continue; + if (all[i] == "elf") + saw_elf = 1; + else + printf " %s", all[i]; + } + printf "%s\n", saw_elf ? " elf" : ""; + + print "sysd-sorted-done := t" +} diff --git a/REORG.TODO/scripts/gen-tunables.awk b/REORG.TODO/scripts/gen-tunables.awk new file mode 100644 index 0000000000..93e5aff0ef --- /dev/null +++ b/REORG.TODO/scripts/gen-tunables.awk @@ -0,0 +1,166 @@ +# Generate dl-tunable-list.h from dl-tunables.list + +BEGIN { + tunable="" + ns="" + top_ns="" +} + +# Skip over blank lines and comments. +/^#/ { + next +} + +/^[ \t]*$/ { + next +} + +# Beginning of either a top namespace, tunable namespace or a tunable, decided +# on the current value of TUNABLE, NS or TOP_NS. +$2 == "{" { + if (top_ns == "") { + top_ns = $1 + } + else if (ns == "") { + ns = $1 + } + else if (tunable == "") { + tunable = $1 + } + else { + printf ("Unexpected occurrence of '{': %s:%d\n", FILENAME, FNR) + exit 1 + } + + next +} + +# End of either a top namespace, tunable namespace or a tunable. +$1 == "}" { + if (tunable != "") { + # Tunables definition ended, now fill in default attributes. + if (!types[top_ns][ns][tunable]) { + types[top_ns][ns][tunable] = "STRING" + } + if (!minvals[top_ns][ns][tunable]) { + minvals[top_ns][ns][tunable] = "0" + } + if (!maxvals[top_ns][ns][tunable]) { + maxvals[top_ns][ns][tunable] = "0" + } + if (!env_alias[top_ns][ns][tunable]) { + env_alias[top_ns][ns][tunable] = "NULL" + } + if (!security_level[top_ns][ns][tunable]) { + security_level[top_ns][ns][tunable] = "SXID_ERASE" + } + + tunable = "" + } + else if (ns != "") { + ns = "" + } + else if (top_ns != "") { + top_ns = "" + } + else { + printf ("syntax error: extra }: %s:%d\n", FILENAME, FNR) + exit 1 + } + next +} + +# Everything else, which could either be a tunable without any attributes or a +# tunable attribute. +{ + if (ns == "") { + printf("Line %d: Invalid tunable outside a namespace: %s\n", NR, $0) + exit 1 + } + + if (tunable == "") { + # We encountered a tunable without any attributes, so note it with a + # default. + types[top_ns][ns][$1] = "STRING" + next + } + + # Otherwise, we have encountered a tunable attribute. + split($0, arr, ":") + attr = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[1]) + val = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[2]) + + if (attr == "type") { + types[top_ns][ns][tunable] = val + } + else if (attr == "minval") { + minvals[top_ns][ns][tunable] = val + } + else if (attr == "maxval") { + maxvals[top_ns][ns][tunable] = val + } + else if (attr == "env_alias") { + env_alias[top_ns][ns][tunable] = sprintf("\"%s\"", val) + } + else if (attr == "security_level") { + if (val == "SXID_ERASE" || val == "SXID_IGNORE" || val == "NONE") { + security_level[top_ns][ns][tunable] = val + } + else { + printf("Line %d: Invalid value (%s) for security_level: %s, ", NR, val, + $0) + print("Allowed values are 'SXID_ERASE', 'SXID_IGNORE', or 'NONE'") + exit 1 + } + } + else if (attr == "default") { + if (types[top_ns][ns][tunable] == "STRING") { + default_val[top_ns][ns][tunable] = sprintf(".strval = \"%s\"", val); + } + else { + default_val[top_ns][ns][tunable] = sprintf(".numval = %s", val) + } + } +} + +END { + if (ns != "") { + print "Unterminated namespace. Is a closing brace missing?" + exit 1 + } + + print "/* AUTOGENERATED by gen-tunables.awk. */" + print "#ifndef _TUNABLES_H_" + print "# error \"Do not include this file directly.\"" + print "# error \"Include tunables.h instead.\"" + print "#endif" + print "#include <dl-procinfo.h>\n" + + # Now, the enum names + print "\ntypedef enum" + print "{" + for (t in types) { + for (n in types[t]) { + for (m in types[t][n]) { + printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t, n, m); + } + } + } + print "} tunable_id_t;\n" + + # Finally, the tunable list. + print "\n#ifdef TUNABLES_INTERNAL" + print "static tunable_t tunable_list[] attribute_relro = {" + for (t in types) { + for (n in types[t]) { + for (m in types[t][n]) { + printf (" {TUNABLE_NAME_S(%s, %s, %s)", t, n, m) + printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n", + types[t][n][m], minvals[t][n][m], maxvals[t][n][m], + default_val[t][n][m], security_level[t][n][m], env_alias[t][n][m]); + } + } + } + print "};" + print "#endif" +} diff --git a/REORG.TODO/scripts/install-sh b/REORG.TODO/scripts/install-sh new file mode 100755 index 0000000000..0360b79e7d --- /dev/null +++ b/REORG.TODO/scripts/install-sh @@ -0,0 +1,501 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2016-01-11.22; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/REORG.TODO/scripts/lib-names.awk b/REORG.TODO/scripts/lib-names.awk new file mode 100644 index 0000000000..a9e018bba1 --- /dev/null +++ b/REORG.TODO/scripts/lib-names.awk @@ -0,0 +1,32 @@ +# awk script for soversions.i -> gnu/lib-names.h; see Makeconfig. + +# +{ + split($1, fields, "=") + lib = fields[1]; + soname = version = fields[2]; + sub(/^.*=/, "", soname); + sub(/^lib.*\.so\./, "", version); + if ($soname !~ /^lib/) { + extra = soname; + sub(/\.so.*$/, "", extra); + } + else { + extra = ""; + } + soname = "\"" soname "\""; + lib = toupper(lib); + extra = toupper(extra); + gsub(/-/, "_", lib); + gsub(/-/, "_", extra); + macros[$1 FS lib "_SO"] = soname; + if (extra) + macros[$1 FS extra "_SO"] = soname; +} + +END { + for (elt in macros) { + split(elt, x); + printf("%-40s%s\n", "#define " x[2], macros[elt]); + } +} diff --git a/REORG.TODO/scripts/list-fixed-bugs.py b/REORG.TODO/scripts/list-fixed-bugs.py new file mode 100755 index 0000000000..72f9446ec0 --- /dev/null +++ b/REORG.TODO/scripts/list-fixed-bugs.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# Copyright (C) 2015-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +"""List fixed bugs for the NEWS file. + +This script takes a version number as input and generates a list of +bugs marked as FIXED with that milestone, to be added to the NEWS file +just before release. The output is in UTF-8. +""" + +import argparse +import json +import sys +import textwrap +import urllib.request + + +def get_parser(): + """Return an argument parser for this module.""" + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('version', + help='Release version to look up') + return parser + + +def list_fixed_bugs(version): + """List the bugs fixed in a given version.""" + url = ('https://sourceware.org/bugzilla/rest.cgi/bug?product=glibc' + '&resolution=FIXED&target_milestone=%s' + '&include_fields=id,component,summary' % version) + response = urllib.request.urlopen(url) + json_data = response.read().decode('utf-8') + data = json.loads(json_data) + for bug in data['bugs']: + desc = '[%d] %s: %s' % (bug['id'], bug['component'], bug['summary']) + desc = textwrap.fill(desc, width=76, initial_indent=' ', + subsequent_indent=' ') + '\n' + sys.stdout.buffer.write(desc.encode('utf-8')) + + +def main(argv): + """The main entry point.""" + parser = get_parser() + opts = parser.parse_args(argv) + list_fixed_bugs(opts.version) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/REORG.TODO/scripts/list-sources.sh b/REORG.TODO/scripts/list-sources.sh new file mode 100755 index 0000000000..d1c6803af6 --- /dev/null +++ b/REORG.TODO/scripts/list-sources.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# +# List all the files under version control in the source tree. +# + +case $# in +0) ;; +1) cd "$1" ;; +*) echo >&2 "Usage: $0 [top_srcdir]"; exit 2 ;; +esac + +if [ -r .git/HEAD ]; then + ${GIT:-git} ls-files + exit 0 +fi + +echo >&2 'Cannot list sources without some version control system in use.' +exit 1 diff --git a/REORG.TODO/scripts/localplt.awk b/REORG.TODO/scripts/localplt.awk new file mode 100644 index 0000000000..beaa342922 --- /dev/null +++ b/REORG.TODO/scripts/localplt.awk @@ -0,0 +1,112 @@ +# This awk script expects to get command-line files that are each +# the output of 'readelf -WSdr' on a single shared object, and named +# .../NAME.jmprel where NAME is the unadorned file name of the shared object. +# It writes "NAME: SYMBOL" for each PLT entry in NAME that refers to a +# symbol defined in the same object. + +BEGIN { result = 0 } + +FILENAME != lastfile { + if (lastfile && jmprel_offset == 0 && rela_offset == 0 && rel_offset == 0) { + print FILENAME ": *** failed to find expected output (readelf -WSdr)"; + result = 2; + } + lastfile = FILENAME; + jmprel_offset = 0; + rela_offset = 0; + rel_offset = 0; + delete section_offset_by_address; +} + +/^Section Headers:/ { in_shdrs = 1; next } +in_shdrs && !/^ +\[/ { in_shdrs = 0 } + +in_shdrs && /^ +\[/ { sub(/\[ +/, "[") } +in_shdrs { + address = strtonum("0x" $4); + offset = strtonum("0x" $5); + section_offset_by_address[address] = offset; +} + +in_shdrs { next } + +$1 == "Offset" && $2 == "Info" { in_relocs = 1; next } +NF == 0 { in_relocs = 0 } + +in_relocs && relocs_offset == jmprel_offset && NF >= 5 { + # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal + # value, but rather as the resolver symbol followed by (). + if ($4 ~ /\(\)/) { + print whatfile, gensub(/@.*/, "", "g", $5) + } else { + symval = strtonum("0x" $4); + if (symval != 0) + print whatfile, gensub(/@.*/, "", "g", $5) + } +} + +in_relocs && relocs_offset == rela_offset && NF >= 5 { + # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal + # value, but rather as the resolver symbol followed by (). + if ($4 ~ /\(\)/) { + print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3 + } else { + symval = strtonum("0x" $4); + if (symval != 0) + print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3 + } +} + +in_relocs && relocs_offset == rel_offset && NF >= 5 { + # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal + # value, but rather as the resolver symbol followed by (). + if ($4 ~ /\(\)/) { + print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3 + } else { + symval = strtonum("0x" $4); + if (symval != 0) + print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3 + } +} + +in_relocs { next } + +$1 == "Relocation" && $2 == "section" && $5 == "offset" { + relocs_offset = strtonum($6); + whatfile = gensub(/^.*\/([^/]+)\.jmprel$/, "\\1:", 1, FILENAME); + next +} + +$2 == "(JMPREL)" { + jmprel_addr = strtonum($3); + if (jmprel_addr in section_offset_by_address) { + jmprel_offset = section_offset_by_address[jmprel_addr]; + } else { + print FILENAME ": *** DT_JMPREL does not match any section's address"; + result = 2; + } + next +} + +$2 == "(RELA)" { + rela_addr = strtonum($3); + if (rela_addr in section_offset_by_address) { + rela_offset = section_offset_by_address[rela_addr]; + } else { + print FILENAME ": *** DT_RELA does not match any section's address"; + result = 2; + } + next +} + +$2 == "(REL)" { + rel_addr = strtonum($3); + if (rel_addr in section_offset_by_address) { + rel_offset = section_offset_by_address[rel_addr]; + } else { + print FILENAME ": *** DT_REL does not match any section's address"; + result = 2; + } + next +} +END { exit(result) } diff --git a/REORG.TODO/scripts/merge-test-results.sh b/REORG.TODO/scripts/merge-test-results.sh new file mode 100755 index 0000000000..e32c5f6303 --- /dev/null +++ b/REORG.TODO/scripts/merge-test-results.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Merge test results of individual tests or subdirectories. +# Copyright (C) 2014-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# usage: merge-test-results.sh -s objpfx subdir test-name... +# (subdirectory tests; empty subdir at top level), or +# merge-test-results.sh -t objpfx subdir-file-name subdir... +# (top-level merge) + +set -e + +type=$1 +objpfx=$2 +shift 2 + +case $type in + -s) + subdir=$1 + shift + subdir=${subdir:+$subdir/} + for t in "$@"; do + if [ -s "$objpfx$t.test-result" ]; then + head -n1 "$objpfx$t.test-result" + else + echo "UNRESOLVED: $subdir$t" + fi + done + ;; + + -t) + subdir_file_name=$1 + shift + for d in "$@"; do + if [ -f "$objpfx$d/$subdir_file_name" ]; then + cat "$objpfx$d/$subdir_file_name" + else + echo "ERROR: test results for $d directory missing" + fi + done + ;; + + *) + echo "unknown type $type" >&2 + exit 1 + ;; +esac diff --git a/REORG.TODO/scripts/mkinstalldirs b/REORG.TODO/scripts/mkinstalldirs new file mode 100755 index 0000000000..a31ce6d029 --- /dev/null +++ b/REORG.TODO/scripts/mkinstalldirs @@ -0,0 +1,162 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy + +scriptversion=2016-01-11.22; # UTC + +# Original author: Noah Friedman <friedman@prep.ai.mit.edu> +# Created: 1993-05-16 +# Public domain. +# +# This file is maintained in Automake, please report +# bugs to <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +nl=' +' +IFS=" "" $nl" +errstatus=0 +dirmode= + +usage="\ +Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... + +Create each directory DIR (with mode MODE, if specified), including all +leading file name components. + +Report bugs to <bug-automake@gnu.org>." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" + exit $? + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --version) + echo "$0 $scriptversion" + exit $? + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and +# mkdir -p a/c at the same time, both will detect that a is missing, +# one will create a, then the other will try to create a and die with +# a "File exists" error. This is a problem when calling mkinstalldirs +# from a parallel make. We use --version in the probe to restrict +# ourselves to GNU mkdir, which is thread-safe. +case $dirmode in + '') + if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + else + # On NextStep and OpenStep, the 'mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because '.' already + # exists. + test -d ./-p && rmdir ./-p + test -d ./--version && rmdir ./--version + fi + ;; + *) + if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && + test ! -d ./--version; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + else + # Clean up after NextStep and OpenStep mkdir. + for d in ./-m ./-p ./--version "./$dirmode"; + do + test -d $d && rmdir $d + done + fi + ;; +esac + +for file +do + case $file in + /*) pathcomp=/ ;; + *) pathcomp= ;; + esac + oIFS=$IFS + IFS=/ + set fnord $file + shift + IFS=$oIFS + + for d + do + test "x$d" = x && continue + + pathcomp=$pathcomp$d + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr= + chmod "$dirmode" "$pathcomp" || lasterr=$? + + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi + + pathcomp=$pathcomp/ + done +done + +exit $errstatus + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/REORG.TODO/scripts/move-if-change b/REORG.TODO/scripts/move-if-change new file mode 100755 index 0000000000..e3fe71d18f --- /dev/null +++ b/REORG.TODO/scripts/move-if-change @@ -0,0 +1,83 @@ +#!/bin/sh +# Like mv $1 $2, but if the files are the same, just delete $1. +# Status is zero if successful, nonzero otherwise. + +VERSION='2016-01-11 22:04'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +# Copyright (C) 2002-2016 Free Software Foundation, Inc. + +# 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, see <http://www.gnu.org/licenses/>. + +usage="usage: $0 SOURCE DEST" + +help="$usage + or: $0 OPTION +If SOURCE is different than DEST, then move it to DEST; else remove SOURCE. + + --help display this help and exit + --version output version information and exit + +The variable CMPPROG can be used to specify an alternative to 'cmp'. + +Report bugs to <bug-gnulib@gnu.org>." + +version=`expr "$VERSION" : '\([^ ]*\)'` +version="move-if-change (gnulib) $version +Copyright (C) 2011 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + +cmpprog=${CMPPROG-cmp} + +for arg +do + case $arg in + --help | --hel | --he | --h) + exec echo "$help" ;; + --version | --versio | --versi | --vers | --ver | --ve | --v) + exec echo "$version" ;; + --) + shift + break ;; + -*) + echo "$0: invalid option: $arg" >&2 + exit 1 ;; + *) + break ;; + esac +done + +test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } + +if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then + rm -f -- "$1" +else + if mv -f -- "$1" "$2"; then :; else + # Ignore failure due to a concurrent move-if-change. + test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" + fi +fi + +## Local Variables: +## eval: (add-hook 'write-file-hooks 'time-stamp) +## time-stamp-start: "VERSION='" +## time-stamp-format: "%:y-%02m-%02d %02H:%02M" +## time-stamp-time-zone: "UTC0" +## time-stamp-end: "'; # UTC" +## End: diff --git a/REORG.TODO/scripts/output-format.sed b/REORG.TODO/scripts/output-format.sed new file mode 100644 index 0000000000..364f52059f --- /dev/null +++ b/REORG.TODO/scripts/output-format.sed @@ -0,0 +1,35 @@ +/ld.*[ ]-E[BL]/b f +/collect.*[ ]-E[BL]/b f +/OUTPUT_FORMAT[^)]*$/{N +s/\n[ ]*/ / +} +t o +: o +s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/ +t q +s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/ +t s +s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/ +t q +d +: s +s/"//g +G +s/\n// +s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p +s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p +s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p +/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p +q +: q +s/"//g +p +q +: f +s/^.*[ ]-E\([BL]\)[ ].*$/,\1/ +t h +s/^.*[ ]-E\([BL]\)$/,\1/ +t h +d +: h +h diff --git a/REORG.TODO/scripts/pylint b/REORG.TODO/scripts/pylint new file mode 100755 index 0000000000..49a775e52f --- /dev/null +++ b/REORG.TODO/scripts/pylint @@ -0,0 +1,5 @@ +#!/bin/sh +# Simple wrapper around the pylint program that uses the pylintrc file to +# validate the source code in files passed on command line. + +exec pylint --rcfile "${0%/*}/pylintrc" "$@" diff --git a/REORG.TODO/scripts/pylintrc b/REORG.TODO/scripts/pylintrc new file mode 100644 index 0000000000..c92f100b4b --- /dev/null +++ b/REORG.TODO/scripts/pylintrc @@ -0,0 +1,274 @@ +[MASTER] + +# Specify a configuration file. +#rcfile= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Profiled execution. +profile=no + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Pickle collected data for later comparisons. +persistent=yes + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + + +[MESSAGES CONTROL] + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time. See also the "--disable" option for examples. +#enable= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +#disable= + + +[REPORTS] + +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html. You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". +files-output=no + +# Tells whether to display a full report or only the messages +reports=no + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Add a comment according to your evaluation note. This is used by the global +# evaluation report (RP0004). +comment=no + +# Template used to display messages. This is a python new-style format string +# used to format the massage information. See doc for all details +#msg-template= + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + + +[BASIC] + +# Required attributes for module, separated by a comma +required-attributes= + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct method names +method-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct attribute names in class +# bodies +class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +# f is a useful name for a file descriptor +good-names=f,i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=__.*__ + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + + +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the beginning of the name of dummy variables +# (i.e. not used). +dummy-variables-rgx=_$|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=79 + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )?<?https?://\S+>?$ + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + + +[TYPECHECK] + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +ignored-classes=SQLObject + +# When zope mode is activated, add a predefined set of Zope acquired attributes +# to generated-members. +zope=no + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. Python regular +# expressions are accepted. +generated-members=REQUEST,acl_users,aq_parent + + +[CLASSES] + +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branches=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/REORG.TODO/scripts/rellns-sh b/REORG.TODO/scripts/rellns-sh new file mode 100755 index 0000000000..a5779c70bb --- /dev/null +++ b/REORG.TODO/scripts/rellns-sh @@ -0,0 +1,78 @@ +#!/bin/sh +# rellns-sh - Simplified ln program to generate relative symbolic link. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Written by Ulrich Drepper <drepper@cygnus.com>, October 1996 +# +# 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 2, 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, see <http://www.gnu.org/licenses/>. + +# With -p, instead of creating the link print the computed relative link +# name. +do_print=false +case $1 in + -p) + do_print=true + shift + ;; +esac +if test $# -ne 2; then + echo "Usage: rellns [-p] SOURCE DEST" >&2 + exit 1 +fi + +# Make both paths absolute. +if test -d $1; then + to=`cd $1 && pwd -P` +else + temp=`echo $1 | sed 's%/*[^/]*$%%'` + if test -z "$temp"; then + to=`pwd -P` + else + to=`cd $temp && pwd -P` + fi + to="$to/`echo $1 | sed 's%.*/\([^/][^/]*\)$%\1%'`" +fi +to=`echo $to | sed 's%^/%%'` + +if test -d $2; then + from=`echo $2 | sed 's%/*$%%'` +else + from=`echo $2 | sed 's%/*[^/]*$%%'` +fi + +if test -z "$from"; then + from=`pwd -P | sed 's%^/%%'` +else + from=`cd $from && pwd -P | sed 's%^/%%'` +fi + +while test -n "$to" && test -n "$from"; do + preto=`echo $to | sed 's%^\([^/]*\)/.*%\1%'` + prefrom=`echo $from | sed 's%^\([^/]*\)/.*%\1%'` + + test "$preto" != "$prefrom" && break + + to=`echo $to | sed 's%^[^/]*/*\(.*\)$%\1%'` + from=`echo $from | sed 's%^[^/]*/*\(.*\)$%\1%'` +done + +while test -n "$from"; do + rfrom="../$rfrom" + from=`echo $from | sed 's%^[^/]*/*%%'` +done + +if $do_print; then + echo "$rfrom$to" +else + ln -s $rfrom$to $2 +fi diff --git a/REORG.TODO/scripts/soversions.awk b/REORG.TODO/scripts/soversions.awk new file mode 100644 index 0000000000..247f061bc3 --- /dev/null +++ b/REORG.TODO/scripts/soversions.awk @@ -0,0 +1,43 @@ +# awk script for shlib-versions.v -> soversions.i; see Makeconfig. + +# Obey the first matching DEFAULT line. +$1 == "DEFAULT" { + $1 = ""; + default_set[++ndefault_set] = $0; + next +} + +# Collect all lib lines before emitting anything, so DEFAULT +# can be interspersed. +{ + lib = number = $1; + sub(/=.*$/, "", lib); + sub(/^.*=/, "", number); + if (lib in numbers) next; + numbers[lib] = number; + order[lib] = ++order_n; + if (NF > 1) { + $1 = ""; + versions[lib] = $0 + } +} + +END { + for (lib in numbers) { + if (lib in versions) + set = versions[lib]; + else { + set = ""; + if (ndefault_set >= 1) + set = default_set[1]; + } + line = set ? (lib FS numbers[lib] FS set) : (lib FS numbers[lib]); + if (!(lib in lineorder) || order[lib] < lineorder[lib]) { + lineorder[lib] = order[lib]; + lines[lib] = "DEFAULT" FS line; + } + } + for (c in lines) { + print lines[c] + } +} diff --git a/REORG.TODO/scripts/sysd-rules.awk b/REORG.TODO/scripts/sysd-rules.awk new file mode 100644 index 0000000000..c82e8fd607 --- /dev/null +++ b/REORG.TODO/scripts/sysd-rules.awk @@ -0,0 +1,80 @@ +# This is a GAWK script to generate the sysd-rules file. +# It does not read any input, but it requires that several variables +# be set on its command line (using -v) to their makefile counterparts: +# all_object_suffixes $(all-object-suffixes) +# inhibit_sysdep_asm $(inhibit-sysdep-asm) +# config_sysdirs $(config_sysdirs) +# sysd_rules_patterns $(sysd-rules-patterns) + +BEGIN { + print "sysd-rules-sysdirs :=", config_sysdirs; + + nsuffixes = split(all_object_suffixes, suffixes); + ninhibit_asm = split(inhibit_sysdep_asm, inhibit_asm); + nsysdirs = split(config_sysdirs, sysdirs); + npatterns = split(sysd_rules_patterns, patterns); + + # Each element of $(sysd-rules-patterns) is a pair TARGET:DEP. + # They are no in particular order. We need to sort them so that + # the longest TARGET is first, and, among elements with the same + # TARGET, the longest DEP is first. + for (i = 1; i <= npatterns; ++i) { + if (split(patterns[i], td, ":") != 2) { + msg = "bad sysd-rules-patterns element '" patterns[i] "'"; + print msg > "/dev/stderr"; + exit 2; + } + target_order = sprintf("%09d", npatterns + 1 - length(td[1])); + dep_order = sprintf("%09d", npatterns - length(td[2])); + sort_patterns[target_order SUBSEP dep_order] = patterns[i]; + } + asorti(sort_patterns, map_patterns); + for (i in map_patterns) { + patterns[i] = sort_patterns[map_patterns[i]]; + } + + for (sysdir_idx = 1; sysdir_idx <= nsysdirs; ++sysdir_idx) { + dir = sysdirs[sysdir_idx]; + if (dir !~ /^\//) dir = "$(..)" dir; + asm_rules = 1; + for (i = 1; i <= ninhibit_asm; ++i) { + if (dir ~ ("^.*sysdeps/" inhibit_asm[i] "$")) { + asm_rules = 0; + break; + } + } + for (suffix_idx = 1; suffix_idx <= nsuffixes; ++suffix_idx) { + o = suffixes[suffix_idx]; + for (pattern_idx = 1; pattern_idx <= npatterns; ++pattern_idx) { + pattern = patterns[pattern_idx]; + split(pattern, td, ":"); + target_pattern = td[1]; + dep_pattern = td[2]; + # rtld objects are always PIC. + if (target_pattern ~ /^rtld/ && o != ".os") { + continue; + } + if (target_pattern == "%") { + command_suffix = ""; + } else { + prefix = gensub(/%/, "", 1, target_pattern); + command_suffix = " $(" prefix "CPPFLAGS)" " $(" prefix "CFLAGS)"; + } + target = "$(objpfx)" target_pattern o ":"; + if (asm_rules) { + dep = dir "/" dep_pattern ".S"; + print target, dep, "$(before-compile)"; + print "\t$(compile-command.S)" command_suffix; + } + dep = dir "/" dep_pattern ".c"; + print target, dep, "$(before-compile)"; + print "\t$(compile-command.c)" command_suffix; + } + } + print "$(inst_includedir)/%.h:", dir "/%.h", "$(+force)"; + print "\t$(do-install)"; + } + + print "sysd-rules-done := t"; + exit 0; +} diff --git a/REORG.TODO/scripts/test-installation.pl b/REORG.TODO/scripts/test-installation.pl new file mode 100755 index 0000000000..c5b9fdefd2 --- /dev/null +++ b/REORG.TODO/scripts/test-installation.pl @@ -0,0 +1,220 @@ +#!/usr/bin/perl -w +# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1997. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + + +$PACKAGE = "libc"; +$progname = $0; +if ($ENV{CC}) { + $CC = $ENV{CC}; +} else { + $CC= "gcc"; +} +if ($ENV{LD_SO}) { + $LD_SO = $ENV{LD_SO}; +} else { + $LD_SO = ""; +} + +sub usage { + print "Usage: test-installation [soversions.mk]\n"; + print " --help print this help, then exit\n"; + print " --version print version number, then exit\n"; + exit 0; +} + +sub installation_problem { + print "The script has found some problems with your installation!\n"; + print "Please read the FAQ and the README file and check the following:\n"; + print "- Did you change the gcc specs file (necessary after upgrading from\n"; + print " Linux libc5)?\n"; + print "- Are there any symbolic links of the form libXXX.so to old libraries?\n"; + print " Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,\n"; + print " libm.so should point to the newly installed glibc file - and there should be\n"; + print " only one such link (check e.g. /lib and /usr/lib)\n"; + print "You should restart this script from your build directory after you've\n"; + print "fixed all problems!\n"; + print "Btw. the script doesn't work if you're installing GNU libc not as your\n"; + print "primary library!\n"; + exit 1; +} + +arglist: while (@ARGV) { + if ($ARGV[0] eq "--v" || $ARGV[0] eq "--ve" || $ARGV[0] eq "--ver" || + $ARGV[0] eq "--vers" || $ARGV[0] eq "--versi" || + $ARGV[0] eq "--versio" || $ARGV[0] eq "--version") { + print "test-installation (GNU $PACKAGE)\n"; + print "Copyright (C) 2017 Free Software Foundation, Inc.\n"; + print "This is free software; see the source for copying conditions. There is NO\n"; + print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; + print "Written by Andreas Jaeger <aj\@arthur.rhein-neckar.de>\n"; + + exit 0; + } elsif ($ARGV[0] eq "--h" || $ARGV[0] eq "--he" || $ARGV[0] eq "--hel" || + $ARGV[0] eq "--help") { + &usage; + } elsif ($ARGV[0] =~ /^-/) { + print "$progname: unrecognized option `$ARGV[0]'\n"; + print "Try `$progname --help' for more information.\n"; + exit 1; + } else { + last arglist; + } +} + +# We expect none or one argument. +if ($#ARGV == -1) { + $soversions="soversions.mk"; + $config="config.make"; +} elsif ($#ARGV == 0) { + if (-d $ARGV[0]) { + $soversions = "$ARGV[0]/soversions.mk"; + $config = "$ARGV[0]/config.make"; + } else { + $soversions = $dir = $ARGV[0]; + $dir =~ s!/?[^/]*/*$!!; + $config = $dir . "/config.make"; + } +} else { + die "Wrong number of arguments."; +} + +if (system ("grep -q \"build-mathvec = yes\" $config") == 0) { + $build_mathvec = 1; +} else { + $build_mathvec = 0; +} + +# Read names and versions of all shared libraries that are part of +# glibc +open SOVERSIONS, $soversions + or die ("Couldn't open $soversions in build directory!"); + +$link_libs = ""; +%versions = (); + +while (<SOVERSIONS>) { + next if (/^all-sonames/); + chop; + if (/^lib/) { + ($name, $version)= /^lib(.*)\.so-version=\.(.*)$/; + # Filter out some libraries we don't want to link: + # - nss_ldap since it's not yet available + # - libdb1 since it conflicts with libdb + # - libnss1_* from glibc-compat add-on + # - libthread_db since it contains unresolved references + # - it's just a test NSS module + # - We don't provide the libgcc so we don't test it + # - libmvec if it wasn't built + next if ($build_mathvec == 0 && $name eq "mvec"); + if ($name ne "nss_ldap" && $name ne "db1" + && !($name =~/^nss1_/) && $name ne "thread_db" + && $name ne "nss_test1" && $name ne "libgcc_s") { + $link_libs .= " -l$name"; + $versions{$name} = $version; + } + } elsif ($LD_SO ne "") { + ($ld_so_name, $ld_so_version) = split ('\.so\.', $LD_SO); + } else { + if (/^ld\.so/) { + ($ld_so_name, $ld_so_version)= /=(.*)\.so\.(.*)$/; + } + } +} + +close SOVERSIONS; + +# Create test program and link it against all +# shared libraries + +open PRG, ">/tmp/test-prg$$.c" + or die ("Couldn't write test file /tmp/test-prg$$.c"); + +print PRG ' +#include <stdio.h> +#include <stdlib.h> +int main(void) { + printf ("Your new glibc installation seems to be ok.\n"); + exit (0); +} +'; +close PRG; + +open GCC, "$CC /tmp/test-prg$$.c $link_libs -o /tmp/test-prg$$ 2>&1 |" + or die ("Couldn't execute $CC!"); + +while (<GCC>) { + print $_ if (! /warning/); +} +close GCC; +if ($?) { + print "Execution of $CC failed!\n"; + &installation_problem; +} + +# Test if test program is linked against the right versions of +# shared libraries + +$ok = 1; +%found = (); + +open LDD, "ldd /tmp/test-prg$$ |" + or die ("Couldn't execute ldd"); +while (<LDD>) { + if (/^\s*lib/) { + ($name, $version1, $version2) = + /^\s*lib(\w*)\.so\.([0-9\.]*)\s*=>.*\.so\.([0-9\.]*)/; + $found{$name} = 1; + if ($versions{$name} ne $version1 || $version1 ne $version2) { + print "Library lib$name is not correctly installed.\n"; + print "Please check your installation!\n"; + print "Offending line of ldd output: $_\n"; + $ok = 0; + } + } + if (/$ld_so_name/) { + ($version1) = /$ld_so_name\.so\.([0-9\.]*)/; + if ($version1 ne $ld_so_version) { + print "The dynamic linker $ld_so_name.so is not correctly installed.\n"; + print "Please check your installation!\n"; + print "Offending line of ldd output: $_\n"; + $ok = 0; + } + } +} + +close LDD; +die "ldd execution failed" if $?; + +foreach (keys %versions) { + unless ($found{$_}) { + print "Library lib$_ is not correctly installed since the test program\n"; + print "was not linked dynamically against it.\n"; + print "Do you have a file/link lib$_.so?\n"; + $ok = 0; + } +} + +&installation_problem unless $ok; + +# Finally execute the test program +system ("/tmp/test-prg$$") == 0 + or die ("Execution of test program failed"); + +# Clean up after ourselves +unlink ("/tmp/test-prg$$", "/tmp/test-prg$$.c"); diff --git a/REORG.TODO/scripts/test_printers_common.py b/REORG.TODO/scripts/test_printers_common.py new file mode 100644 index 0000000000..fe88f36366 --- /dev/null +++ b/REORG.TODO/scripts/test_printers_common.py @@ -0,0 +1,365 @@ +# Common functions and variables for testing the Python pretty printers. +# +# Copyright (C) 2016-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +"""These tests require PExpect 4.0 or newer. + +Exported constants: + PASS, FAIL, UNSUPPORTED (int): Test exit codes, as per evaluate-test.sh. +""" + +import os +import re +from test_printers_exceptions import * + +PASS = 0 +FAIL = 1 +UNSUPPORTED = 77 + +gdb_bin = 'gdb' +gdb_options = '-q -nx' +gdb_invocation = '{0} {1}'.format(gdb_bin, gdb_options) +pexpect_min_version = 4 +gdb_min_version = (7, 8) +encoding = 'utf-8' + +try: + import pexpect +except ImportError: + print('PExpect 4.0 or newer must be installed to test the pretty printers.') + exit(UNSUPPORTED) + +pexpect_version = pexpect.__version__.split('.')[0] + +if int(pexpect_version) < pexpect_min_version: + print('PExpect 4.0 or newer must be installed to test the pretty printers.') + exit(UNSUPPORTED) + +if not pexpect.which(gdb_bin): + print('gdb 7.8 or newer must be installed to test the pretty printers.') + exit(UNSUPPORTED) + +timeout = 5 +TIMEOUTFACTOR = os.environ.get('TIMEOUTFACTOR') + +if TIMEOUTFACTOR: + timeout = int(TIMEOUTFACTOR) + +try: + # Check the gdb version. + version_cmd = '{0} --version'.format(gdb_invocation, timeout=timeout) + gdb_version_out = pexpect.run(version_cmd, encoding=encoding) + + # The gdb version string is "GNU gdb <PKGVERSION><version>", where + # PKGVERSION can be any text. We assume that there'll always be a space + # between PKGVERSION and the version number for the sake of the regexp. + version_match = re.search(r'GNU gdb .* ([1-9]+)\.([0-9]+)', gdb_version_out) + + if not version_match: + print('The gdb version string (gdb -v) is incorrectly formatted.') + exit(UNSUPPORTED) + + gdb_version = (int(version_match.group(1)), int(version_match.group(2))) + + if gdb_version < gdb_min_version: + print('gdb 7.8 or newer must be installed to test the pretty printers.') + exit(UNSUPPORTED) + + # Check if gdb supports Python. + gdb_python_cmd = '{0} -ex "python import os" -batch'.format(gdb_invocation, + timeout=timeout) + gdb_python_error = pexpect.run(gdb_python_cmd, encoding=encoding) + + if gdb_python_error: + print('gdb must have python support to test the pretty printers.') + print('gdb output: {!r}'.format(gdb_python_error)) + exit(UNSUPPORTED) + + # If everything's ok, spawn the gdb process we'll use for testing. + gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout, + encoding=encoding) + gdb_prompt = u'\(gdb\)' + gdb.expect(gdb_prompt) + +except pexpect.ExceptionPexpect as exception: + print('Error: {0}'.format(exception)) + exit(FAIL) + +def test(command, pattern=None): + """Sends 'command' to gdb and expects the given 'pattern'. + + If 'pattern' is None, simply consumes everything up to and including + the gdb prompt. + + Args: + command (string): The command we'll send to gdb. + pattern (raw string): A pattern the gdb output should match. + + Returns: + string: The string that matched 'pattern', or an empty string if + 'pattern' was None. + """ + + match = '' + + gdb.sendline(command) + + if pattern: + # PExpect does a non-greedy match for '+' and '*'. Since it can't look + # ahead on the gdb output stream, if 'pattern' ends with a '+' or a '*' + # we may end up matching only part of the required output. + # To avoid this, we'll consume 'pattern' and anything that follows it + # up to and including the gdb prompt, then extract 'pattern' later. + index = gdb.expect([u'{0}.+{1}'.format(pattern, gdb_prompt), + pexpect.TIMEOUT]) + + if index == 0: + # gdb.after now contains the whole match. Extract the text that + # matches 'pattern'. + match = re.match(pattern, gdb.after, re.DOTALL).group() + elif index == 1: + # We got a timeout exception. Print information on what caused it + # and bail out. + error = ('Response does not match the expected pattern.\n' + 'Command: {0}\n' + 'Expected pattern: {1}\n' + 'Response: {2}'.format(command, pattern, gdb.before)) + + raise pexpect.TIMEOUT(error) + else: + # Consume just the the gdb prompt. + gdb.expect(gdb_prompt) + + return match + +def init_test(test_bin, printer_files, printer_names): + """Loads the test binary file and the required pretty printers to gdb. + + Args: + test_bin (string): The name of the test binary file. + pretty_printers (list of strings): A list with the names of the pretty + printer files. + """ + + # Load all the pretty printer files. We're assuming these are safe. + for printer_file in printer_files: + test('source {0}'.format(printer_file)) + + # Disable all the pretty printers. + test('disable pretty-printer', r'0 of [0-9]+ printers enabled') + + # Enable only the required printers. + for printer in printer_names: + test('enable pretty-printer {0}'.format(printer), + r'[1-9][0-9]* of [1-9]+ printers enabled') + + # Finally, load the test binary. + test('file {0}'.format(test_bin)) + +def go_to_main(): + """Executes a gdb 'start' command, which takes us to main.""" + + test('start', r'main') + +def get_line_number(file_name, string): + """Returns the number of the line in which 'string' appears within a file. + + Args: + file_name (string): The name of the file we'll search through. + string (string): The string we'll look for. + + Returns: + int: The number of the line in which 'string' appears, starting from 1. + """ + number = -1 + + with open(file_name) as src_file: + for i, line in enumerate(src_file): + if string in line: + number = i + 1 + break + + if number == -1: + raise NoLineError(file_name, string) + + return number + +def break_at(file_name, string, temporary=True, thread=None): + """Places a breakpoint on the first line in 'file_name' containing 'string'. + + 'string' is usually a comment like "Stop here". Notice this may fail unless + the comment is placed inline next to actual code, e.g.: + + ... + /* Stop here */ + ... + + may fail, while: + + ... + some_func(); /* Stop here */ + ... + + will succeed. + + If 'thread' isn't None, the breakpoint will be set for all the threads. + Otherwise, it'll be set only for 'thread'. + + Args: + file_name (string): The name of the file we'll place the breakpoint in. + string (string): A string we'll look for inside the file. + We'll place a breakpoint on the line which contains it. + temporary (bool): Whether the breakpoint should be automatically deleted + after we reach it. + thread (int): The number of the thread we'll place the breakpoint for, + as seen by gdb. If specified, it should be greater than zero. + """ + + if not thread: + thread_str = '' + else: + thread_str = 'thread {0}'.format(thread) + + if temporary: + command = 'tbreak' + break_type = 'Temporary breakpoint' + else: + command = 'break' + break_type = 'Breakpoint' + + line_number = str(get_line_number(file_name, string)) + + test('{0} {1}:{2} {3}'.format(command, file_name, line_number, thread_str), + r'{0} [0-9]+ at 0x[a-f0-9]+: file {1}, line {2}\.'.format(break_type, + file_name, + line_number)) + +def continue_cmd(thread=None): + """Executes a gdb 'continue' command. + + If 'thread' isn't None, the command will be applied to all the threads. + Otherwise, it'll be applied only to 'thread'. + + Args: + thread (int): The number of the thread we'll apply the command to, + as seen by gdb. If specified, it should be greater than zero. + """ + + if not thread: + command = 'continue' + else: + command = 'thread apply {0} continue'.format(thread) + + test(command) + +def next_cmd(count=1, thread=None): + """Executes a gdb 'next' command. + + If 'thread' isn't None, the command will be applied to all the threads. + Otherwise, it'll be applied only to 'thread'. + + Args: + count (int): The 'count' argument of the 'next' command. + thread (int): The number of the thread we'll apply the command to, + as seen by gdb. If specified, it should be greater than zero. + """ + + if not thread: + command = 'next' + else: + command = 'thread apply {0} next' + + test('{0} {1}'.format(command, count)) + +def select_thread(thread): + """Selects the thread indicated by 'thread'. + + Args: + thread (int): The number of the thread we'll switch to, as seen by gdb. + This should be greater than zero. + """ + + if thread > 0: + test('thread {0}'.format(thread)) + +def get_current_thread_lwpid(): + """Gets the current thread's Lightweight Process ID. + + Returns: + string: The current thread's LWP ID. + """ + + # It's easier to get the LWP ID through the Python API than the gdb CLI. + command = 'python print(gdb.selected_thread().ptid[1])' + + return test(command, r'[0-9]+') + +def set_scheduler_locking(mode): + """Executes the gdb 'set scheduler-locking' command. + + Args: + mode (bool): Whether the scheduler locking mode should be 'on'. + """ + modes = { + True: 'on', + False: 'off' + } + + test('set scheduler-locking {0}'.format(modes[mode])) + +def test_printer(var, to_string, children=None, is_ptr=True): + """ Tests the output of a pretty printer. + + For a variable called 'var', this tests whether its associated printer + outputs the expected 'to_string' and children (if any). + + Args: + var (string): The name of the variable we'll print. + to_string (raw string): The expected output of the printer's 'to_string' + method. + children (map {raw string->raw string}): A map with the expected output + of the printer's children' method. + is_ptr (bool): Whether 'var' is a pointer, and thus should be + dereferenced. + """ + + if is_ptr: + var = '*{0}'.format(var) + + test('print {0}'.format(var), to_string) + + if children: + for name, value in children.items(): + # Children are shown as 'name = value'. + test('print {0}'.format(var), r'{0} = {1}'.format(name, value)) + +def check_debug_symbol(symbol): + """ Tests whether a given debugging symbol exists. + + If the symbol doesn't exist, raises a DebugError. + + Args: + symbol (string): The symbol we're going to check for. + """ + + try: + test('ptype {0}'.format(symbol), r'type = {0}'.format(symbol)) + + except pexpect.TIMEOUT: + # The symbol doesn't exist. + raise DebugError(symbol) diff --git a/REORG.TODO/scripts/test_printers_exceptions.py b/REORG.TODO/scripts/test_printers_exceptions.py new file mode 100644 index 0000000000..6fc98a0404 --- /dev/null +++ b/REORG.TODO/scripts/test_printers_exceptions.py @@ -0,0 +1,61 @@ +# Exception classes used when testing the Python pretty printers. +# +# Copyright (C) 2016-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +class NoLineError(Exception): + """Custom exception to indicate that a test file doesn't contain + the requested string. + """ + + def __init__(self, file_name, string): + """Constructor. + + Args: + file_name (string): The name of the test file. + string (string): The string that was requested. + """ + + super(NoLineError, self).__init__() + self.file_name = file_name + self.string = string + + def __str__(self): + """Shows a readable representation of the exception.""" + + return ('File {0} has no line containing the following string: {1}' + .format(self.file_name, self.string)) + +class DebugError(Exception): + """Custom exception to indicate that a required debugging symbol is missing. + """ + + def __init__(self, symbol): + """Constructor. + + Args: + symbol (string): The name of the entity whose debug info is missing. + """ + + super(DebugError, self).__init__() + self.symbol = symbol + + def __str__(self): + """Shows a readable representation of the exception.""" + + return ('The required debugging information for {0} is missing.' + .format(self.symbol)) diff --git a/REORG.TODO/scripts/update-abilist.sh b/REORG.TODO/scripts/update-abilist.sh new file mode 100644 index 0000000000..d0a1bcb552 --- /dev/null +++ b/REORG.TODO/scripts/update-abilist.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# Update abilist files based on differences on one architecture. +# Copyright (C) 2015-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +set -e +export LC_ALL=C + +if [ $# -lt 3 ]; then + echo "usage: $0 OLD-FILE NEW-FILE FILES-TO-BE-PATCHED..." 1>&2 + exit 2 +fi + +old_file="$1" +shift +new_file="$1" +shift + +tmp_old_sorted="$(mktemp)" +tmp_new_sorted="$(mktemp)" +tmp_new_symbols="$(mktemp)" +tmp_patched="$(mktemp)" + +cleanup () { + rm -f -- "$tmp_old_sorted" "$tmp_new_sorted" \ + "$tmp_new_symbols" "$tmp_patched" +} + +trap cleanup 0 + +sort -u -o "$tmp_old_sorted" -- "$old_file" +sort -u -o "$tmp_new_sorted" -- "$new_file" + +# -1 skips symbols only in $old_file (deleted symbols). +# -3 skips symbols in both files (unchanged symbols). +comm -1 -3 "$tmp_old_sorted" "$tmp_new_sorted" > "$tmp_new_symbols" + +new_symbol_count="$(wc -l < "$tmp_new_symbols")" +if [ "$new_symbol_count" -eq 0 ]; then + echo "info: no symbols added" 1>&2 + exit 0 +fi + +echo "info: $new_symbol_count symbol(s) added" 1>&2 + +for to_be_patched in "$@" ; do + sort -u -o "$tmp_patched" -- "$to_be_patched" "$tmp_new_symbols" + if ! cmp -s -- "$to_be_patched" "$tmp_patched"; then + echo "info: updating $to_be_patched" 1>&2 + cp -- "$tmp_patched" "$to_be_patched" + fi +done diff --git a/REORG.TODO/scripts/update-copyrights b/REORG.TODO/scripts/update-copyrights new file mode 100755 index 0000000000..1a03134dfa --- /dev/null +++ b/REORG.TODO/scripts/update-copyrights @@ -0,0 +1,77 @@ +#!/bin/sh +# Update copyright year lists. +# Copyright (C) 2012-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library 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 +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# Run this script with the first argument being the location of +# gnulib's update-copyright script. Any other arguments are ignored. +# FSF copyright notices in the glibc source directory containing this +# script will be updated; glibc must then be built to update generated +# files. Copyright dates in --version copyright notices are not +# updated. + +set -e + +export LC_ALL=C +export UPDATE_COPYRIGHT_FORCE=1 +export UPDATE_COPYRIGHT_USE_INTERVALS=2 +export UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 + +update_script=$1 + +if ! [ -f "$update_script" ]; then + echo "error: first argument must point to gnulib update-copyright script" >&2 + exit 1 +fi + +cd "$(dirname "$0")/.." + +files=$(find . -type f | sed 's|^\./||' | grep -v '^\.git/') + +for f in $files; do + case $f in + COPYING | COPYING.LIB | manual/fdl-1.3.texi | manual/lgpl-2.1.texi) + # Licenses imported verbatim from FSF sources. + ;; + manual/texinfo.tex | scripts/config.guess | scripts/config.sub \ + | scripts/install-sh | scripts/mkinstalldirs | scripts/move-if-change) + # Other files imported verbatim from other GNU repositories. + ;; + po/*.po) + # Files imported verbatim from the Translation Project. + ;; + INSTALL | intl/plural.c | locale/C-translit.h \ + | locale/programs/charmap-kw.h | locale/programs/locfile-kw.h \ + | po/libc.pot | sysdeps/gnu/errlist.c) + # Generated files. + ;; + configure | */configure | preconfigure | */preconfigure) + # Possibly generated files. + if ! [ -f "$f.ac" ]; then + "$update_script" "$f" + fi + ;; + grp/initgroups.c | misc/bits/stab.def | posix/regex.h \ + | sysdeps/wordsize-32/divdi3.c) + # Pre-1991 gaps in copyright years, so cannot use a single range. + UPDATE_COPYRIGHT_USE_INTERVALS=1 "$update_script" "$f" + ;; + *) + "$update_script" "$f" + ;; + esac +done diff --git a/REORG.TODO/scripts/versionlist.awk b/REORG.TODO/scripts/versionlist.awk new file mode 100644 index 0000000000..fe872aaeb5 --- /dev/null +++ b/REORG.TODO/scripts/versionlist.awk @@ -0,0 +1,67 @@ +# Extract ordered list of version sets from Versions files. +# Copyright (C) 2014-2017 Free Software Foundation, Inc. + +BEGIN { in_lib = ""; in_version = 0 } + +!in_lib && NF == 2 && $2 == "{" { + in_lib = $1; + all_libs[in_lib] = 1; + next +} +!in_lib { next } + +NF == 2 && $2 == "{" { + in_version = 1; + lib_versions[in_lib, $1] = 1; + # Partition the version sets into GLIBC_* and others. + if ($1 ~ /GLIBC_/) { + libs[in_lib] = libs[in_lib] " " $1 "\n"; + all_versions[$1] = 1; + } + else { + others_libs[in_lib] = others_libs[in_lib] " " $1 "\n"; + others_all_versions[$1] = 1; + } + next +} + +in_version && $1 == "}" { in_version = 0; next } +in_version { next } + +$1 == "}" { in_lib = ""; next } + +END { + nlibs = asorti(all_libs, libs_order); + for (i = 1; i <= nlibs; ++i) { + lib = libs_order[i]; + + for (v in all_versions) { + if (!((lib, v) in lib_versions)) { + libs[lib] = libs[lib] " " v "\n"; + } + } + + for (v in others_all_versions) { + if (!((lib, v) in lib_versions)) { + others_libs[lib] = others_libs[lib] " " v "\n"; + } + } + + print lib, "{"; + + # Sort and print all the GLIBC_* sets first, then all the others. + # This is not really generically right, but it suffices + # for the cases we have so far. e.g. GCC_3.0 is "later than" + # all GLIBC_* sets that matter for purposes of Versions files. + + sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3"; + printf "%s", libs[lib] | sort; + close(sort); + + sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3"; + printf "%s", others_libs[lib] | sort; + close(sort); + + print "}"; + } +} diff --git a/REORG.TODO/scripts/versions.awk b/REORG.TODO/scripts/versions.awk new file mode 100644 index 0000000000..5d4768c992 --- /dev/null +++ b/REORG.TODO/scripts/versions.awk @@ -0,0 +1,173 @@ +# Combine version map fragments into version scripts for our shared objects. +# Copyright (C) 1998-2017 Free Software Foundation, Inc. +# Written by Ulrich Drepper <drepper@cygnus.com>, 1998. + +# This script expects the following variables to be defined: +# defsfile name of Versions.def file +# buildroot name of build directory with trailing slash +# move_if_change move-if-change command + +# Read definitions for the versions. +BEGIN { + lossage = 0; + + nlibs=0; + while (getline < defsfile) { + if (/^[a-zA-Z0-9_.]+ \{/) { + libs[$1] = 1; + curlib = $1; + while (getline < defsfile && ! /^}/) { + if ($2 == "=") { + renamed[curlib "::" $1] = $3; + } + else + versions[curlib "::" $1] = 1; + } + } + } + close(defsfile); + + tmpfile = buildroot "Versions.tmp"; + # POSIX sort needed. + sort = "sort -t. -k 1,1 -k 2n,2n -k 3 > " tmpfile; +} + +# Remove comment lines. +/^ *#/ { + next; +} + +# This matches the beginning of the version information for a new library. +/^[a-zA-Z0-9_.]+/ { + actlib = $1; + if (!libs[$1]) { + printf("no versions defined for %s\n", $1) > "/dev/stderr"; + ++lossage; + } + next; +} + +# This matches the beginning of a new version for the current library. +/^ [A-Za-z_]/ { + if (renamed[actlib "::" $1]) + actver = renamed[actlib "::" $1]; + else if (!versions[actlib "::" $1] && $1 != "GLIBC_PRIVATE") { + printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr"; + ++lossage; + } + else + actver = $1; + next; +} + +# This matches lines with names to be added to the current version in the +# current library. This is the only place where we print something to +# the intermediate file. +/^ / { + sortver=actver + # Ensure GLIBC_ versions come always first + sub(/^GLIBC_/," GLIBC_",sortver) + printf("%s %s %s\n", actlib, sortver, $0) | sort; +} + + +function closeversion(name, oldname) { + if (firstinfile) { + printf(" local:\n *;\n") > outfile; + firstinfile = 0; + } + # This version inherits from the last one only if they + # have the same nonnumeric prefix, i.e. GLIBC_x.y and GLIBC_x.z + # or FOO_x and FOO_y but not GLIBC_x and FOO_y. + pfx = oldname; + sub(/[0-9.]+/,".+",pfx); + if (oldname == "" || name !~ pfx) print "};" > outfile; + else printf("} %s;\n", oldname) > outfile; +} + +function close_and_move(name, real_name) { + close(name); + system(move_if_change " " name " " real_name " >&2"); +} + +# Now print the accumulated information. +END { + close(sort); + + if (lossage) { + system("rm -f " tmpfile); + exit 1; + } + + oldlib = ""; + oldver = ""; + real_first_ver_header = buildroot "first-versions.h" + first_ver_header = real_first_ver_header "T" + printf("#ifndef _FIRST_VERSIONS_H\n") > first_ver_header; + printf("#define _FIRST_VERSIONS_H\n") > first_ver_header; + real_ldbl_compat_header = buildroot "ldbl-compat-choose.h" + ldbl_compat_header = real_ldbl_compat_header "T" + printf("#ifndef _LDBL_COMPAT_CHOOSE_H\n") > ldbl_compat_header; + printf("#define _LDBL_COMPAT_CHOOSE_H\n") > ldbl_compat_header; + printf("#ifndef LONG_DOUBLE_COMPAT\n") > ldbl_compat_header; + printf("# error LONG_DOUBLE_COMPAT not defined\n") > ldbl_compat_header; + printf("#endif\n") > ldbl_compat_header; + printf("version-maps ="); + while (getline < tmpfile) { + if ($1 != oldlib) { + if (oldlib != "") { + closeversion(oldver, veryoldver); + oldver = ""; + close_and_move(outfile, real_outfile); + } + oldlib = $1; + real_outfile = buildroot oldlib ".map"; + outfile = real_outfile "T"; + firstinfile = 1; + veryoldver = ""; + printf(" %s.map", oldlib); + } + if ($2 != oldver) { + if (oldver != "") { + closeversion(oldver, veryoldver); + veryoldver = oldver; + } + printf("%s {\n global:\n", $2) > outfile; + oldver = $2; + } + printf(" ") > outfile; + for (n = 3; n <= NF; ++n) { + printf(" %s", $n) > outfile; + sym = $n; + sub(";", "", sym); + first_ver_macro = "FIRST_VERSION_" oldlib "_" sym; + if (!(first_ver_macro in first_ver_seen) \ + && oldver ~ "^GLIBC_[0-9]" \ + && sym ~ "^[A-Za-z0-9_]*$") { + ver_val = oldver; + gsub("\\.", "_", ver_val); + printf("#define %s %s\n", first_ver_macro, ver_val) > first_ver_header; + first_ver_seen[first_ver_macro] = 1; + if (oldlib == "libc" || oldlib == "libm") { + printf("#if LONG_DOUBLE_COMPAT (%s, %s)\n", + oldlib, ver_val) > ldbl_compat_header; + printf("# define LONG_DOUBLE_COMPAT_CHOOSE_%s_%s(a, b) a\n", + oldlib, sym) > ldbl_compat_header; + printf("#else\n") > ldbl_compat_header; + printf("# define LONG_DOUBLE_COMPAT_CHOOSE_%s_%s(a, b) b\n", + oldlib, sym) > ldbl_compat_header; + printf("#endif\n") > ldbl_compat_header; + } + } + } + printf("\n") > outfile; + } + printf("\n"); + printf("#endif /* first-versions.h */\n") > first_ver_header; + printf("#endif /* ldbl-compat-choose.h */\n") > ldbl_compat_header; + closeversion(oldver, veryoldver); + close_and_move(outfile, real_outfile); + close_and_move(first_ver_header, real_first_ver_header); + close_and_move(ldbl_compat_header, real_ldbl_compat_header); + #system("rm -f " tmpfile); +} |