summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore26
-rw-r--r--.travis.yml42
-rw-r--r--INSTALL5
-rw-r--r--Makefile.in49
-rw-r--r--README2
-rw-r--r--README.md10
-rwxr-xr-xconfig.guess1441
-rwxr-xr-xconfig.sub611
-rw-r--r--configure.ac72
-rw-r--r--docker/README.md21
-rw-r--r--docker/base/Dockerfile15
-rw-r--r--docker/base/apt-conf4
-rwxr-xr-xdocker/build.sh27
-rw-r--r--docker/compilers/Dockerfile.clang-3.89
-rw-r--r--docker/compilers/Dockerfile.gcc-4.811
-rw-r--r--docker/compilers/Dockerfile.gcc-511
-rwxr-xr-xfind_c_extension.sh2
-rw-r--r--gnome/distccmon-gnome.desktop4
-rwxr-xr-xinclude_server/__init__.py0
-rwxr-xr-xinclude_server/basics.py28
-rwxr-xr-xinclude_server/basics_test.py28
-rw-r--r--include_server/c_extensions/distcc_pump_c_extensions_module.c128
-rwxr-xr-xinclude_server/c_extensions_test.py32
-rwxr-xr-xinclude_server/cache_basics.py27
-rwxr-xr-xinclude_server/compiler_defaults.py12
-rwxr-xr-xinclude_server/compress_files.py16
-rwxr-xr-xinclude_server/include_analyzer.py16
-rwxr-xr-xinclude_server/include_analyzer_memoizing_node.py48
-rwxr-xr-xinclude_server/include_analyzer_memoizing_node_test.py30
-rwxr-xr-xinclude_server/include_analyzer_test.py46
-rwxr-xr-xinclude_server/include_server.py123
-rwxr-xr-xinclude_server/include_server_test.py28
-rwxr-xr-xinclude_server/macro_eval.py28
-rwxr-xr-xinclude_server/macro_eval_test.py14
-rwxr-xr-xinclude_server/mirror_path.py2
-rwxr-xr-xinclude_server/mirror_path_test.py6
-rwxr-xr-xinclude_server/parse_command.py29
-rwxr-xr-xinclude_server/parse_command_test.py16
-rwxr-xr-xinclude_server/parse_file.py22
-rwxr-xr-xinclude_server/parse_file_test.py20
-rwxr-xr-xinclude_server/run.py17
-rwxr-xr-xinclude_server/setup.py8
-rwxr-xr-xinclude_server/statistics.py76
-rw-r--r--man/distccd.12
-rw-r--r--packaging/RedHat/conf/clients.allow4
-rw-r--r--src/access.c2
-rw-r--r--src/arg.c11
-rw-r--r--src/auth_common.c6
-rw-r--r--src/auth_distcc.c2
-rw-r--r--src/clinet.c2
-rw-r--r--src/dparent.c2
-rw-r--r--src/exec.c6
-rw-r--r--src/hosts.c3
-rw-r--r--src/lsdistcc.c2
-rw-r--r--src/rpc.h6
-rw-r--r--src/rslave.c2
-rw-r--r--src/serve.c15
-rw-r--r--src/ssh.c30
-rw-r--r--src/stats.c1
-rw-r--r--src/zeroconf-reg.c12
-rw-r--r--src/zeroconf.c23
-rw-r--r--src/zeroconf.h2
-rwxr-xr-xtest/comfychair.py62
-rwxr-xr-xtest/onetest.py2
-rwxr-xr-xtest/testdistcc.py288
65 files changed, 2194 insertions, 1453 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..116f9c2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,26 @@
+*.o
+*.d
+*.out
+*.err
+# binaries
+distcc
+distccd
+distccmon-text
+lsdistcc
+pump
+
+# files generated by build tools
+Makefile
+_include_server/
+aclocal.m4
+autom4te.cache/
+config.log
+config.status
+configure
+lzo/.stamp-conf
+popt/.stamp-conf
+src/config.h
+src/config.h.in
+src/config.h.stamp
+man/*.gz
+_testtmp/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..2d06389
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,42 @@
+language: c
+
+addons:
+ apt:
+ packages:
+ - python3-dev
+ - libiberty-dev
+ - clang
+
+before_install:
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi
+
+script:
+ - ./autogen.sh
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./configure; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./configure --without-libiberty; fi
+ - make
+ - make check
+
+matrix:
+ include:
+ - os: linux
+ compiler: gcc
+ dist: trusty
+ - os: linux
+ compiler: clang
+ env: FIXME=1
+ dist: trusty
+ - os: osx
+ osx_image: xcode8.2
+ env:
+ - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
+ - os: osx
+ osx_image: xcode8.2
+ compiler: clang
+ - os: osx
+ osx_image: xcode8.3
+ compiler: clang
+ - os: osx
+ osx_image: xcode9
+ compiler: clang
diff --git a/INSTALL b/INSTALL
index a8be3f9..8d5309c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -19,6 +19,11 @@ QUICK SUMMARY
Note that past versions of Debian used binutils-dev instead of
libiberty-dev.
+ Note that distcc-pump needs Python 3.x, while the default version of
+ Python on many systems is 2.x, so you may have to be explicit - e.g.
+
+ sudo apt-get install libpython3.5-dev
+
1. Build and install
./autogen.sh # If "configure" does not already exist.
diff --git a/Makefile.in b/Makefile.in
index b398bc8..3ea595c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -29,6 +29,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@ ${DIR_DEFS} \
-Isrc -I"$(srcdir)/src" -I"$(srcdir)/lzo" $(POPT_INCLUDES)
+PYTHON = @PYTHON@
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
builddir = @builddir@
@@ -72,14 +74,6 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
-# We use python for two tasks in distcc: running the unittests, and
-# running the include-server. The latter requires python 2.4 or
-# higher, while the former only requires python 2.2. So it's possible
-# a particular machine will be able to run one but not the other.
-# Thus we have two variables.
-TEST_PYTHON = @TEST_PYTHON@
-INCLUDESERVER_PYTHON = @INCLUDESERVER_PYTHON@
-
# RESTRICTED_PATH is a colon separated list of directory names. It
# contains the locations of 'make', 'sh', 'gcc', and 'python' for use
# in installation tests. This path is used to avoid confusion caused
@@ -171,7 +165,6 @@ example_DOCS = \
doc/example/xinetd \
include_server_PY = \
- include_server/__init__.py \
include_server/basics.py \
include_server/cache_basics.py \
include_server/compiler_defaults.py \
@@ -315,7 +308,7 @@ h_fix_debug_info = src/h_fix_debug_info.o $(common_obj)
h_compile_obj = src/h_compile.o $(common_obj) src/compile.o src/timefile.o \
src/backoff.o src/emaillog.o src/remote.o src/clinet.o \
src/clirpc.o src/include_server_if.o src/state.o src/where.o \
- src/ssh.o src/strip.o src/cpp.o
+ src/ssh.o src/strip.o src/cpp.o @AUTH_DISTCC_OBJS@
h_getline_obj = src/h_getline.o $(common_obj)
# All source files, for the purposes of building the distribution
@@ -578,7 +571,7 @@ distccmon-gnome@EXEEXT@: $(mon_obj) $(gnome_obj)
# the distcc version, the source location, the CPP flags (for location of the
# includes), and the build location.
include-server:
- if test -z "$(INCLUDESERVER_PYTHON)"; then \
+ if test -z "$(PYTHON)"; then \
echo "Not building $@: No suitable python found"; \
else \
mkdir -p "$(include_server_builddir)" && \
@@ -586,7 +579,7 @@ include-server:
SRCDIR="$(srcdir)" \
CFLAGS="$(CFLAGS) $(PYTHON_CFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" \
- $(INCLUDESERVER_PYTHON) "$(srcdir)/include_server/setup.py" \
+ $(PYTHON) "$(srcdir)/include_server/setup.py" \
build \
--build-base="$(include_server_builddir)" \
--build-temp="$(include_server_builddir)"; \
@@ -711,17 +704,17 @@ TESTDISTCC_OPTS =
# satisfied w/o actually building an include server (or rather the C extension);
# this logic needs to be verified or amended.
maintainer-check-no-set-path:
- @if ! $(TEST_PYTHON) -c 'import sys; print sys.version'; then \
+ @if ! $(PYTHON) -c 'import sys; print(sys.version)'; then \
echo "WARNING: python not found; tests skipped"; \
else \
- if ! gcc --version 2>/dev/null; then \
- echo "Could not find gcc on the restricted path used to avoid"; \
+ if ! $(CC) --version 2>/dev/null; then \
+ echo "Could not find CC on the restricted path used to avoid"; \
echo "confusion caused by distcc masquerades on the normal path."; \
echo "PATH is currently '$$PATH'."; \
echo "Please change RESTRICTED_PATH to change this PATH value."; \
exit 1; \
fi; \
- $(TEST_PYTHON) "$(srcdir)/test/testdistcc.py" $(TESTDISTCC_OPTS); \
+ $(PYTHON) "$(srcdir)/test/testdistcc.py" $(TESTDISTCC_OPTS); \
fi
distcc-maintainer-check: check_programs
@@ -744,8 +737,8 @@ include-server-maintainer-check: include-server
for p in $(check_include_server_PY); do \
p_base=`basename "$$p"`; \
echo "Running:" \
- "PYTHONPATH=$$CURDIR/$$include_server_loc:$$PYTHONPATH $(INCLUDESERVER_PYTHON) $$p_base"; \
- if PYTHONPATH="$$CURDIR/$$include_server_loc:$$PYTHONPATH" $(INCLUDESERVER_PYTHON) "$$p_base" \
+ "PYTHONPATH=$$CURDIR/$$include_server_loc:$$PYTHONPATH $(PYTHON) $$p_base"; \
+ if PYTHONPATH="$$CURDIR/$$include_server_loc:$$PYTHONPATH" $(PYTHON) "$$p_base" \
> "$$CURDIR/$(tempdir)/$$p_base.out" 2>&1; then \
echo "PASS"; \
rm "$$CURDIR/$(tempdir)/$$p_base.out"; \
@@ -773,9 +766,9 @@ maintainer-check: distcc-maintainer-check include-server-maintainer-check \
pump-maintainer-check
check:
- @if test -n "$(INCLUDESERVER_PYTHON)"; then \
+ @if test -n "$(PYTHON)"; then \
$(MAKE) maintainer-check; \
- elif test -n "$(TEST_PYTHON)"; then \
+ elif test -n "$(PYTHON)"; then \
echo "WARNING: pump-mode not being tested"; \
$(MAKE) distcc-maintainer-check; \
else \
@@ -798,7 +791,7 @@ valgrind-check:
TESTNAME = NoDetachDaemon_Case # Override this with the desired test.
single-test: check_programs
PATH="`pwd`:$(RESTRICTED_PATH)" \
- $(TEST_PYTHON) "$(srcdir)/test/onetest.py" $(TESTDISTCC_OPTS) $(TESTNAME)
+ $(PYTHON) "$(srcdir)/test/onetest.py" $(TESTDISTCC_OPTS) $(TESTNAME)
# Run a single test in pump-mode.
pump-single-test: pump include-server check_programs
@@ -861,9 +854,9 @@ maintainer-installcheck: verify-binaries-installcheck distcc-installcheck \
pump-installcheck
installcheck:
- @if test -n "$(INCLUDESERVER_PYTHON)"; then \
+ @if test -n "$(PYTHON)"; then \
$(MAKE) maintainer-installcheck; \
- elif test -n "$(TEST_PYTHON)"; then \
+ elif test -n "$(PYTHON)"; then \
echo "WARNING: pump-mode not being tested"; \
$(MAKE) distcc-maintainer-installcheck; \
else \
@@ -913,7 +906,7 @@ benchmark:
@echo "Pass BENCH_ARGS to make to specify which benchmarks to run."
@echo
@sleep 5
- cd bench && $(TEST_PYTHON) benchmark.py $(BENCH_ARGS)
+ cd bench && $(PYTHON) benchmark.py $(BENCH_ARGS)
######################################################################
@@ -943,12 +936,12 @@ clean-lzo:
clean-include-server:
- if test -n "$(INCLUDESERVER_PYTHON)"; then \
+ if test -n "$(PYTHON)"; then \
DISTCC_VERSION="$(VERSION)" \
SRCDIR="$(srcdir)" \
CFLAGS="$(CFLAGS) $(PYTHON_CFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" \
- $(INCLUDESERVER_PYTHON) "$(srcdir)/include_server/setup.py" \
+ $(PYTHON) "$(srcdir)/include_server/setup.py" \
clean \
--build-base="$(include_server_builddir)" \
--build-temp="$(include_server_builddir)"; \
@@ -1062,7 +1055,7 @@ install-programs: $(bin_PROGRAMS)
# line endings), so we need to convert it from DOS text file format to
# Unix text file format (LF line endings); we use sed for that too.
install-include-server: include-server pump
- if test -z "$(INCLUDESERVER_PYTHON)"; then \
+ if test -z "$(PYTHON)"; then \
echo "Not building $@: No suitable python found"; \
else \
mkdir -p "$(include_server_builddir)" && \
@@ -1071,7 +1064,7 @@ install-include-server: include-server pump
SRCDIR="$(srcdir)" \
CFLAGS="$(CFLAGS) $(PYTHON_CFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" \
- $(INCLUDESERVER_PYTHON) "$(srcdir)/include_server/setup.py" \
+ $(PYTHON) "$(srcdir)/include_server/setup.py" \
build \
--build-base="$(include_server_builddir)" \
--build-temp="$(include_server_builddir)" \
diff --git a/README b/README
index 53956a9..4dc01e7 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
distcc -- a free distributed C/C++ compiler system
- http://code.google.com/p/distcc/
+ https://github.com/distcc/distcc
by Martin Pool <mbp@samba.org>
diff --git a/README.md b/README.md
index 897de65..2d79235 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
# distcc -- a free distributed C/C++ compiler system
+[![Build Status](https://travis-ci.org/distcc/distcc.svg?branch=master)](https://travis-ci.org/distcc/distcc)
by Martin Pool
-http://distcc.org/
+Current Documents: https://cdn.rawgit.com/distcc/distcc/9a09372bd3f420cdd7021e52eda14fa536a3c10e/doc/web/index.html
+Formally http://distcc.org/
"pump" functionality added by
Fergus Henderson, Nils Klarlund, Manos Renieris, and Craig Silverstein (Google Inc.)
@@ -55,8 +57,8 @@ typical case, three machines are 2.6 times faster than one.
distcc is distributed under the GNU General Public Licence v2.
## Resources
-
+ * [Continuous Integration System](https://travis-ci.org/distcc/distcc)(Travis CI)
+
* [Mailing list](https://lists.samba.org/mailman/listinfo/distcc)
-
+
* [Stack Overflow questions](http://stackoverflow.com/questions/tagged/distcc)
-
diff --git a/config.guess b/config.guess
index 9b1384b..2193702 100755
--- a/config.guess
+++ b/config.guess
@@ -1,13 +1,12 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1992-2017 Free Software Foundation, Inc.
-timestamp='2002-11-30'
+timestamp='2017-05-27'
# 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 2 of the License, or
+# 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
@@ -16,24 +15,22 @@ timestamp='2002-11-30'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 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.
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
+# 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.
#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
+# 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
#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
+# Please send patches to <config-patches@gnu.org>.
+
me=`echo "$0" | sed -e 's,.*/,,'`
@@ -53,8 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
+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."
@@ -66,11 +62,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
- echo "$timestamp" ; exit 0 ;;
+ echo "$timestamp" ; exit ;;
--version | -v )
- echo "$version" ; exit 0 ;;
+ echo "$version" ; exit ;;
--help | --h* | -h )
- echo "$usage"; exit 0 ;;
+ echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
@@ -98,14 +94,18 @@ trap 'exit 1' 1 2 15
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
-# This shell variable is my proudest work .. or something. --bje
+# Portable tmp directory creation inspired by the Autoconf team.
-set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ;
-(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old)
- || (echo "$me: cannot create $tmpdir" >&2 && exit 1) ;
-dummy=$tmpdir/dummy ;
-files="$dummy.c $dummy.o $dummy.rel $dummy" ;
-trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ;
+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
@@ -113,15 +113,13 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
- rm -f $files ;
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 ;
-unset files'
+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)
@@ -134,12 +132,33 @@ 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 tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # 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
@@ -149,22 +168,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# 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=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ 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.
+ # 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 __ELF__ >/dev/null
+ | grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
@@ -174,7 +204,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
fi
;;
*)
- os=netbsd
+ 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
@@ -187,146 +224,133 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
release='-gnu'
;;
*)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ 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}"
- exit 0 ;;
- amiga:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- arc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- hp300:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- macppc:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme88k:OpenBSD:*:*)
- echo m88k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvmeppc:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- pmax:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sgi:OpenBSD:*:*)
- echo mipseb-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sun3:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- wgrisc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
+ echo "${machine}-${os}${release}${abi}"
+ exit ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+ exit ;;
*:OpenBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
+ 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:*:*)
- if test $UNAME_RELEASE = "V4.0"; then
+ case $UNAME_RELEASE in
+ *4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- fi
+ ;;
+ *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.
- eval $set_cc_for_build
- cat <<EOF >$dummy.s
- .data
-\$Lformat:
- .byte 37,100,45,37,120,10,0 # "%d-%x\n"
-
- .text
- .globl main
- .align 4
- .ent main
-main:
- .frame \$30,16,\$26,0
- ldgp \$29,0(\$27)
- .prologue 1
- .long 0x47e03d80 # implver \$0
- lda \$2,-1
- .long 0x47e20c21 # amask \$2,\$1
- lda \$16,\$Lformat
- mov \$0,\$17
- not \$1,\$18
- jsr \$26,printf
- ldgp \$29,0(\$26)
- mov 0,\$16
- jsr \$26,exit
- .end main
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
- if test "$?" = 0 ; then
- case `$dummy` in
- 0-0)
- UNAME_MACHINE="alpha"
- ;;
- 1-0)
- UNAME_MACHINE="alphaev5"
- ;;
- 1-1)
- UNAME_MACHINE="alphaev56"
- ;;
- 1-101)
- UNAME_MACHINE="alphapca56"
- ;;
- 2-303)
- UNAME_MACHINE="alphaev6"
- ;;
- 2-307)
- UNAME_MACHINE="alphaev67"
- ;;
- 2-1307)
- UNAME_MACHINE="alphaev68"
- ;;
- 3-1307)
- UNAME_MACHINE="alphaev7"
- ;;
- esac
- fi
- rm -f $dummy.s $dummy && rmdir $tmpdir
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
- exit 0 ;;
+ exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
- exit 0;;
+ exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
- exit 0 ;;
+ exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
- exit 0 ;;
+ exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
- exit 0 ;;
+ 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 0;;
+ 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 0;;
+ 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
@@ -334,29 +358,51 @@ EOF
else
echo pyramid-pyramid-bsd
fi
- exit 0 ;;
+ exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
- exit 0 ;;
- DRS?6000:UNIX_SV:4.2*:7*)
+ 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 0 ;;
+ 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 0 ;;
+ exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
@@ -365,13 +411,13 @@ EOF
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit 0 ;;
+ exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
- exit 0 ;;
+ 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
+ test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
@@ -380,10 +426,10 @@ EOF
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
- exit 0 ;;
+ exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
- exit 0 ;;
+ 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
@@ -393,38 +439,41 @@ EOF
# 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 0 ;;
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit 0 ;;
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit 0 ;;
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
- exit 0 ;;
+ exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
@@ -448,36 +497,36 @@ EOF
exit (-1);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c \
- && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
- rm -f $dummy.c $dummy && rmdir $tmpdir
+ $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 0 ;;
+ exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
- exit 0 ;;
+ exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
- exit 0 ;;
+ exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
- exit 0 ;;
+ exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
- exit 0 ;;
+ exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
- exit 0 ;;
+ exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
- exit 0 ;;
+ exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
- exit 0 ;;
+ exit ;;
AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
+ # 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 ] || \
@@ -490,29 +539,29 @@ EOF
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
- exit 0 ;;
+ exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
- exit 0 ;;
+ exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
- exit 0 ;;
+ exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
- exit 0 ;;
+ exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
- exit 0 ;;
+ exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit 0 ;;
+ 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 0 ;; # Note that: echo "'`uname -s`'" gives '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 0 ;;
+ exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
@@ -520,7 +569,7 @@ EOF
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit 0 ;;
+ exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
@@ -535,50 +584,54 @@ EOF
exit(0);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
- rm -f $dummy.c $dummy && rmdir $tmpdir
- echo rs6000-ibm-aix3.2.5
+ 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 0 ;;
- *:AIX:*:[45])
+ 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/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
+ 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 0 ;;
+ exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
- exit 0 ;;
+ exit ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
- exit 0 ;;
+ exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit 0 ;; # report: romp-ibm BSD 4.3
+ exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
- exit 0 ;;
+ exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
- exit 0 ;;
+ exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
- exit 0 ;;
+ exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
- exit 0 ;;
+ exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
@@ -587,64 +640,84 @@ EOF
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
+ 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
+ sed 's/^ //' << EOF >$dummy.c
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
+ #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);
+ 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);
- }
+ 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`
- if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
- rm -f $dummy.c $dummy && rmdir $tmpdir
+ (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 0 ;;
+ exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
- exit 0 ;;
+ exit ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
@@ -672,317 +745,358 @@ EOF
exit (0);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
- rm -f $dummy.c $dummy && rmdir $tmpdir
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
- exit 0 ;;
+ exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
- exit 0 ;;
+ exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
- exit 0 ;;
+ exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
- exit 0 ;;
+ exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
- exit 0 ;;
+ exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
- exit 0 ;;
+ exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
- exit 0 ;;
+ exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
- exit 0 ;;
+ exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
- exit 0 ;;
+ exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
- exit 0 ;;
+ exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
- exit 0 ;;
+ exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
- exit 0 ;;
+ exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
- exit 0 ;;
+ exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
- CRAY*T3D:*:*:*)
- echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ 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 0 ;;
+ 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 0 ;;
+ exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:FreeBSD:*:*)
- # Determine whether the default compiler uses glibc.
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #if __GLIBC__ >= 2
- LIBC=gnu
- #else
- LIBC=
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- rm -f $dummy.c && rmdir $tmpdir
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
- exit 0 ;;
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ case ${UNAME_PROCESSOR} in
+ amd64)
+ UNAME_PROCESSOR=x86_64 ;;
+ i386)
+ UNAME_PROCESSOR=i586 ;;
+ esac
+ echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
- exit 0 ;;
- i*:MINGW*:*)
+ exit ;;
+ *:MINGW64*:*)
+ echo ${UNAME_MACHINE}-pc-mingw64
+ exit ;;
+ *:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
- exit 0 ;;
+ 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 0 ;;
- x86:Interix*:3*)
- echo i586-pc-interix3
- exit 0 ;;
+ 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 0 ;;
+ 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 0 ;;
+ exit ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
- exit 0 ;;
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
- exit 0 ;;
+ exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
+ exit ;;
*:GNU:*:*)
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit 0 ;;
+ # 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 0 ;;
+ 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:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ 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-gnu
- exit 0 ;;
+ 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-gnu
- exit 0 ;;
- mips: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 mips
- #undef mipsel
+ #undef ${UNAME_MACHINE}
+ #undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
+ CPU=${UNAME_MACHINE}el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
+ CPU=${UNAME_MACHINE}
#else
CPU=
#endif
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- rm -f $dummy.c && rmdir $tmpdir
- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- rm -f $dummy.c && rmdir $tmpdir
- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
- ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit 0 ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit 0 ;;
- 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 ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit 0 ;;
+ 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-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
+ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+ *) echo hppa-unknown-linux-${LIBC} ;;
esac
- exit 0 ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit 0 ;;
+ 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
- exit 0 ;;
+ echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ 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 x86_64-unknown-linux-gnu
- exit 0 ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit 0 ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit 0 ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit 0 ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- rm -f $dummy.c && rmdir $tmpdir
- test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
- ;;
+ 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 0 ;;
+ 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,
+ # 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.
+ # Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
- exit 0 ;;
+ exit ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
- exit 0 ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ 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 0 ;;
+ exit ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit 0 ;;
+ 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
@@ -990,15 +1104,16 @@ EOF
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
- exit 0 ;;
- i*86:*:5:[78]*)
+ 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 0 ;;
+ exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
@@ -1016,73 +1131,86 @@ EOF
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
- exit 0 ;;
+ 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 i386.
- echo i386-pc-msdosdjgpp
- exit 0 ;;
+ # 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 0 ;;
+ exit ;;
paragon:*:*:*)
echo i860-intel-osf1
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
- exit 0 ;;
+ exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
- exit 0 ;;
+ exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
- exit 0 ;;
- M68*:*:R3V[567]*:*)
- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*: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)
+ 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 0
+ && { 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 0 ;;
+ && { 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 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 0 ;;
+ exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
- exit 0 ;;
+ exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
- exit 0 ;;
+ exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
- exit 0 ;;
+ exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
@@ -1090,282 +1218,227 @@ EOF
else
echo ns32k-sni-sysv
fi
- exit 0 ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
- exit 0 ;;
+ exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
+ echo mips-nec-sysv${UNAME_RELEASE}
else
- echo mips-unknown-sysv${UNAME_RELEASE}
+ echo mips-unknown-sysv${UNAME_RELEASE}
fi
- exit 0 ;;
+ exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
- exit 0 ;;
+ exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
- exit 0 ;;
+ exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
- exit 0 ;;
+ 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 0 ;;
+ exit ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:Darwin:*:*)
- echo `uname -p`-apple-darwin${UNAME_RELEASE}
- exit 0 ;;
+ 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
+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_PPC >/dev/null
+ then
+ UNAME_PROCESSOR=powerpc
+ 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
+ if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
- exit 0 ;;
- NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
+ 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 0 ;;
+ exit ;;
+ NSX-*:NONSTOP_KERNEL:*:*)
+ echo nsx-tandem-nsk${UNAME_RELEASE}
+ exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
- exit 0 ;;
+ exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
- exit 0 ;;
+ exit ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit 0 ;;
+ 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
+ if test "$cputype" = 386; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
- exit 0 ;;
+ exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
- exit 0 ;;
+ exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
- exit 0 ;;
+ exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
- exit 0 ;;
+ exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
- exit 0 ;;
+ exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
- exit 0 ;;
+ exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
- exit 0 ;;
+ 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
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
-rm -f $dummy.c $dummy && rmdir $tmpdir
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit 0 ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit 0 ;;
- c34*)
- echo c34-convex-bsd
- exit 0 ;;
- c38*)
- echo c38-convex-bsd
- exit 0 ;;
- c4*)
- echo c4-convex-bsd
- exit 0 ;;
- esac
-fi
-
cat >&2 <<EOF
$0: unable to guess system type
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+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:
- ftp://ftp.gnu.org/pub/gnu/config/
+ 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 the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+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
diff --git a/config.sub b/config.sub
index f0675aa..40ea5df 100755
--- a/config.sub
+++ b/config.sub
@@ -1,42 +1,40 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1992-2017 Free Software Foundation, Inc.
-timestamp='2002-11-30'
+timestamp='2017-04-02'
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# 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 2 of the License, or
+# 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.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
+# 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.
+# 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>. Submit a context
-# diff and a properly formatted ChangeLog entry.
+
+# 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.
@@ -55,8 +53,7 @@ timestamp='2002-11-30'
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
@@ -70,8 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
+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."
@@ -83,11 +79,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
- echo "$timestamp" ; exit 0 ;;
+ echo "$timestamp" ; exit ;;
--version | -v )
- echo "$version" ; exit 0 ;;
+ echo "$version" ; exit ;;
--help | --h* | -h )
- echo "$usage"; exit 0 ;;
+ echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
@@ -99,7 +95,7 @@ while test $# -gt 0 ; do
*local*)
# First pass through any local machine types.
echo $1
- exit 0;;
+ exit ;;
* )
break ;;
@@ -118,10 +114,18 @@ esac
# 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* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ 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 ]
@@ -144,10 +148,13 @@ case $os in
-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)
+ -apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
+ -bluegene*)
+ os=-cnk
+ ;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
@@ -162,13 +169,17 @@ case $os in
os=-chorusos
basic_machine=$1
;;
- -chorusrdb)
- os=-chorusrdb
+ -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/'`
@@ -185,6 +196,10 @@ case $os in
# 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/'`
@@ -202,6 +217,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
-lynx*)
os=-lynxos
;;
@@ -226,53 +247,116 @@ case $basic_machine in
# 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] \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | clipper \
+ | 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 \
- | fr30 | frv \
+ | e2k | epiphany \
+ | fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k \
- | m32r | m68000 | m68k | m88k | mcore \
+ | hexagon \
+ | i370 | i860 | i960 | ia16 | 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 \
- | mips64vr | mips64vrel \
+ | 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 \
- | openrisc | or32 \
+ | open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pru \
| pyramid \
- | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | 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 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic80 | tron \
- | v850 | v850e \
+ | 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 \
+ | wasm32 \
| we32k \
- | x86 | xscale | xstormy16 | xtensa \
- | z8k)
+ | x86 | xc16x | xstormy16 | xtensa \
+ | z8k | z80)
basic_machine=$basic_machine-unknown
;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
+ 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
@@ -288,54 +372,91 @@ case $basic_machine in
# 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-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \
- | clipper-* | cydra-* \
+ | avr-* | avr32-* \
+ | ba-* \
+ | be32-* | be64-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
+ | c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | e2k-* | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* \
- | m32r-* \
+ | hexagon-* \
+ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | k1om-* \
+ | le32-* | le64-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | mcore-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
+ | 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-* \
- | mipstx39 | mipstx39el \
+ | 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-* | ppcbe-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pru-* \
| pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
+ | 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-* | sparc86x-* | sparclet-* | sparclite-* \
- | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \
- | v850-* | v850e-* | vax-* \
+ | 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-* \
+ | wasm32-* \
| we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
- | xtensa-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
+ | xstormy16-* | xtensa*-* \
| ymp-* \
- | z8k-*)
+ | 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.
@@ -353,6 +474,9 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
@@ -367,6 +491,12 @@ case $basic_machine in
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
@@ -390,6 +520,13 @@ case $basic_machine in
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
@@ -398,10 +535,35 @@ case $basic_machine in
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
@@ -426,12 +588,27 @@ case $basic_machine in
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
;;
@@ -454,6 +631,14 @@ case $basic_machine in
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
@@ -462,6 +647,14 @@ case $basic_machine in
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
@@ -565,7 +758,6 @@ case $basic_machine in
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
@@ -604,6 +796,17 @@ case $basic_machine in
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
;;
@@ -615,10 +818,21 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
+ microblaze*)
+ basic_machine=microblaze-xilinx
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=-mingw64
+ ;;
mingw32)
- basic_machine=i386-pc
+ basic_machine=i686-pc
os=-mingw32
;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
miniframe)
basic_machine=m68000-convergent
;;
@@ -632,10 +846,6 @@ case $basic_machine in
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
- mmix*)
- basic_machine=mmix-knuth
- os=-mmixware
- ;;
monitor)
basic_machine=m68k-rom68k
os=-coff
@@ -644,14 +854,29 @@ case $basic_machine in
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
@@ -716,16 +941,28 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
+ neo-tandem)
+ basic_machine=neo-tandem
+ ;;
+ nse-tandem)
+ basic_machine=nse-tandem
+ ;;
nsr-tandem)
basic_machine=nsr-tandem
;;
+ nsx-tandem)
+ basic_machine=nsx-tandem
+ ;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
- or32 | or32-*)
+ openrisc | openrisc-*)
basic_machine=or32-unknown
- os=-coff
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
@@ -743,6 +980,14 @@ case $basic_machine in
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
;;
@@ -752,34 +997,47 @@ case $basic_machine in
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)
+ 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-*)
+ 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) basic_machine=powerpc-unknown
+ ppc | ppcbe) basic_machine=powerpc-unknown
;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ppc-* | ppcbe-*)
+ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
+ ppcle | powerpclittle)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
@@ -789,7 +1047,7 @@ case $basic_machine in
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ ppc64le | powerpc64little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
@@ -802,6 +1060,14 @@ case $basic_machine in
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
@@ -828,6 +1094,14 @@ case $basic_machine in
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
sequent)
basic_machine=i386-sequent
;;
@@ -835,6 +1109,12 @@ case $basic_machine in
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
@@ -853,6 +1133,9 @@ case $basic_machine in
basic_machine=i860-stratus
os=-sysv4
;;
+ strongarm-* | thumb-*)
+ basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
sun2)
basic_machine=m68000-sun
;;
@@ -901,10 +1184,6 @@ case $basic_machine in
basic_machine=i386-sequent
os=-dynix
;;
- t3d)
- basic_machine=alpha-cray
- os=-unicos
- ;;
t3e)
basic_machine=alphaev5-cray
os=-unicos
@@ -913,13 +1192,9 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
- tic4x | c4x*)
- basic_machine=tic4x-unknown
- os=-coff
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
+ tile*)
+ basic_machine=$basic_machine-unknown
+ os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
@@ -934,6 +1209,10 @@ case $basic_machine in
tower | tower-32)
basic_machine=m68k-ncr
;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
udi29k)
basic_machine=a29k-amd
os=-udi
@@ -969,6 +1248,9 @@ case $basic_machine in
basic_machine=a29k-wrs
os=-vxworks
;;
+ wasm32)
+ basic_machine=wasm32-unknown
+ ;;
w65*)
basic_machine=w65-wdc
os=-none
@@ -977,9 +1259,16 @@ case $basic_machine in
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
@@ -988,6 +1277,10 @@ case $basic_machine in
basic_machine=z8k-unknown
os=-sim
;;
+ z80-*-coff)
+ basic_machine=z80-unknown
+ os=-sim
+ ;;
none)
basic_machine=none-none
os=-none
@@ -1007,6 +1300,9 @@ case $basic_machine in
romp)
basic_machine=romp-ibm
;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
rs6000)
basic_machine=rs6000-ibm
;;
@@ -1023,13 +1319,10 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
- sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparc | sparcv9 | sparcv9b)
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
@@ -1073,9 +1366,12 @@ esac
if [ x"$os" != x"" ]
then
case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
+ # 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|'`
;;
@@ -1096,25 +1392,32 @@ case $os in
# 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* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -*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* \
+ | -aos* | -aros* | -cloudabi* | -sortix* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -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* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -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*)
+ | -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*)
@@ -1132,12 +1435,15 @@ case $os in
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -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|'`
;;
@@ -1150,6 +1456,9 @@ case $os in
-opened*)
os=-openedition
;;
+ -os400*)
+ os=-os400
+ ;;
-wince*)
os=-wince
;;
@@ -1171,6 +1480,9 @@ case $os in
-atheos*)
os=-atheos
;;
+ -syllable*)
+ os=-syllable
+ ;;
-386bsd)
os=-bsd
;;
@@ -1193,6 +1505,9 @@ case $os in
-sinix*)
os=-sysv4
;;
+ -tpf*)
+ os=-tpf
+ ;;
-triton*)
os=-sysv3
;;
@@ -1223,6 +1538,19 @@ case $os in
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
+ -aros*)
+ os=-aros
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -dicos*)
+ os=-dicos
+ ;;
+ -nacl*)
+ ;;
+ -ios)
+ ;;
-none)
;;
*)
@@ -1245,6 +1573,12 @@ else
# system, and we'll never get to this point.
case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
*-acorn)
os=-riscix1.2
;;
@@ -1254,6 +1588,24 @@ case $basic_machine in
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
@@ -1272,13 +1624,13 @@ case $basic_machine in
;;
m68000-sun)
os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
;;
m68*-cisco)
os=-aout
;;
+ mep-*)
+ os=-elf
+ ;;
mips*-cisco)
os=-elf
;;
@@ -1294,12 +1646,21 @@ case $basic_machine in
sparc-* | *-sun)
os=-sunos4.1.1
;;
+ pru-*)
+ os=-elf
+ ;;
*-be)
os=-beos
;;
+ *-haiku)
+ os=-haiku
+ ;;
*-ibm)
os=-aix
;;
+ *-knuth)
+ os=-mmixware
+ ;;
*-wec)
os=-proelf
;;
@@ -1402,7 +1763,7 @@ case $basic_machine in
-sunos*)
vendor=sun
;;
- -aix*)
+ -cnk*|-aix*)
vendor=ibm
;;
-beos*)
@@ -1432,9 +1793,15 @@ case $basic_machine in
-mvs* | -opened*)
vendor=ibm
;;
+ -os400*)
+ vendor=ibm
+ ;;
-ptx*)
vendor=sequent
;;
+ -tpf*)
+ vendor=ibm
+ ;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
@@ -1459,7 +1826,7 @@ case $basic_machine in
esac
echo $basic_machine$os
-exit 0
+exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
diff --git a/configure.ac b/configure.ac
index 16a593f..8f4a202 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script
-# "We are ugly but we have the music"
+# "We are ugly but we have the music"
# -- Leonard Cohen
#
# http://jerkcity.com/jerkcity1335.html
@@ -48,10 +48,10 @@ AC_CHECK_TYPE([socklen_t], ,[
AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([dcc_cv_socklen_t_equiv],
[
- # Systems have either "struct sockaddr *" or
+ # Systems have either "struct sockaddr{,_in} *" or
# "void *" as the second argument to getpeername
dcc_cv_socklen_t_equiv=
- for arg2 in "struct sockaddr" void; do
+ for arg2 in "struct sockaddr_in" "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
AC_TRY_COMPILE([
#include <sys/types.h>
@@ -78,6 +78,21 @@ getpeername(0,0,&len);
[#include <sys/types.h>
#include <sys/socket.h>])
+dnl Android requires -llog for printf and friends
+dnl and will only run position independant executables
+AC_MSG_CHECKING([if building on Android])
+AC_TRY_COMPILE([
+ #ifdef __BIONIC__
+ int ok;
+ (void)ok;
+ #else
+ choke me
+ #endif],
+[func("a"); func("a", "b"); func("a", "b", "c")],
+[AC_MSG_RESULT(yes)
+ LDFLAGS="$LDFLAGS -llog -pie"],
+[AC_MSG_RESULT(no)])
+
# TODO: Handle program transform rules by autoconf.
### Checks for configure options
@@ -124,7 +139,7 @@ AC_ARG_ENABLE(Werror,
# Now get the package configuration information for whatever packages
# we need. It's faster to just do it once during configuration.
if test "x${with_gnome}" = xyes
-then
+then
GNOME_PACKAGES="gtk+-2.0 libgnome-2.0 libgnomeui-2.0 pango"
elif test "x${with_gtk}" = xyes
then
@@ -140,11 +155,11 @@ do
then
AC_MSG_RESULT($gnomevers)
else
- AC_MSG_ERROR([$pkg was not found by pkg-config])
+ AC_MSG_ERROR([$pkg was not found by pkg-config])
fi
done
-if test x${with_gnome} = xyes -o x${with_gtk} = xyes
+if test x${with_gnome} = xyes -o x${with_gtk} = xyes
then
INSTALL_GNOME="install-gnome-data"
UNINSTALL_GNOME="uninstall-gnome-data"
@@ -210,7 +225,8 @@ then
-Wno-write-strings"
# For popt/*.c, we disable unused variable warnings.
- POPT_CFLAGS="-Wno-unused"
+ # When using Apple GCC/Clang you have to explicitly disable unused parameters.
+ POPT_CFLAGS="-Wno-unused -Wno-unused-parameter"
AC_MSG_NOTICE([Adding gcc options: $CFLAGS])
fi
@@ -239,35 +255,12 @@ CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
AC_PROG_MAKE_SET
AC_PROG_INSTALL
-# We prefer to use the latest Python, but try to find an explicit
-# version to make sure we don't get a really old one.
-#
-# The include server requires python 2.4 or later, but the 'make test'
-# routines only require python 2.2. Thus we have two separate
-# variables. Each variable is the empty string if the python that we
-# haven't isn't recent enough for that use, or the path to a python
-# executable if it is recent enough.
+# We prefer to use the latest Python
#
# NB: Cannot use AC_CONFIG_LIBOBJ_DIR here, because it's not present
# in autoconf 2.53.
-AC_PATH_PROGS(PYTHON, [python2.7 python-2.7 python2.6 python-2.6 python2.5 python-2.5 python2.4 python-2.4 python])
+AM_PATH_PYTHON([3.1],,[:])
AC_ARG_VAR(PYTHON, [Python interpreter])
-# Python 1 doesn't even support -V
-if ! "$PYTHON" -V 2>&1 | grep "^Python" >/dev/null; then
- TEST_PYTHON=""
- INCLUDESERVER_PYTHON=""
-elif "$PYTHON" -V 2>&1 | grep "^Python 2.1" >/dev/null; then
- TEST_PYTHON=""
- INCLUDESERVER_PYTHON=""
-elif "$PYTHON" -V 2>&1 | grep "^Python 2.[[23]]" >/dev/null; then
- TEST_PYTHON="$PYTHON"
- INCLUDESERVER_PYTHON=""
-else
- TEST_PYTHON="$PYTHON"
- INCLUDESERVER_PYTHON="$PYTHON"
-fi
-AC_SUBST(TEST_PYTHON)
-AC_SUBST(INCLUDESERVER_PYTHON)
AC_SUBST(PYTHON_RELATIVE_LIB)
AC_C_INLINE
AC_C_BIGENDIAN
@@ -277,7 +270,7 @@ AC_C_BIGENDIAN
# Some of these are needed by popt (or other libraries included in the future).
-AC_CHECK_HEADERS([unistd.h sys/types.h sys/sendfile.h sys/signal.h])
+AC_CHECK_HEADERS([unistd.h sys/types.h sys/sendfile.h])
AC_CHECK_HEADERS([ctype.h sys/resource.h sys/socket.h sys/select.h])
AC_CHECK_HEADERS([netinet/in.h], [], [],
[#if HAVE_SYS_TYPES_H
@@ -342,8 +335,8 @@ AC_SEARCH_LIBS(inet_aton, [resolv])
if test x"$with_included_popt" != x"yes" && test x"$with_included_popt" != xno
then
- # If not explicitly requested, guess.
- # People might have the library but not the header, in which case we
+ # If not explicitly requested, guess.
+ # People might have the library but not the header, in which case we
# still need to use the included copy.
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
AC_CHECK_HEADER(popt.h, , [with_included_popt=yes])
@@ -409,6 +402,7 @@ AC_CHECK_DECLS([snprintf, vsnprintf, vasprintf, asprintf, strndup])
AC_MSG_CHECKING([if mmap() supports MAP_FAILED])
AC_TRY_COMPILE([
+#include <stddef.h>
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif],[
@@ -453,7 +447,7 @@ AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
#include <stdarg.h>
-void foo(const char *format, ...) {
+void foo(const char *format, ...) {
va_list ap;
int len;
char buf[5];
@@ -525,7 +519,7 @@ AC_ARG_WITH([auth],
if test x"$with_auth" = xyes; then
AC_SEARCH_LIBS([gss_init_sec_context],
- [gssapi gssapi_krb5],
+ [gssapi gssapi_krb5 gss],
AC_DEFINE(HAVE_GSSAPI, 1, [Define if the GSS_API is available])
AUTH_COMMON_OBJS="src/auth_common.o"
AUTH_DISTCC_OBJS="src/auth_distcc.o"
@@ -578,12 +572,12 @@ cat <<EOF
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..b1f35b7
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,21 @@
+# Building distcc with different compilers
+
+## Requirements:
+
+Docker 1.9.1
+
+## Build
+The following command will create three images based on Ubuntu 16.04 using gcc 4.8, 5.4 and clang 3.8 and
+build distcc inside the container.
+
+```
+$ cd docker
+$ ./build.sh
+```
+
+In order to build only one variant use the following command:
+
+```
+$ cd docker
+$ ./build.sh clang-3.8|gcc-4.8|gcc-5
+```
diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile
new file mode 100644
index 0000000..5e995d8
--- /dev/null
+++ b/docker/base/Dockerfile
@@ -0,0 +1,15 @@
+FROM ubuntu:xenial-20170802
+
+LABEL maintainer=""
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+COPY apt-conf /etc/apt/apt.conf.d/
+
+RUN apt-get update && \
+ apt-get install autoconf \
+ python3-dev \
+ python-dev \
+ libiberty-dev \
+ build-essential \
+ make
diff --git a/docker/base/apt-conf b/docker/base/apt-conf
new file mode 100644
index 0000000..8cb6e98
--- /dev/null
+++ b/docker/base/apt-conf
@@ -0,0 +1,4 @@
+APT::Get::Assume-Yes "true";
+APT::Get::Install-Recommends "false";
+APT::Get::Install-Suggests "false";
+DPkg::Post-Invoke { "rm -rf /var/lib/apt/lists/* || true"; };
diff --git a/docker/build.sh b/docker/build.sh
new file mode 100755
index 0000000..f38740c
--- /dev/null
+++ b/docker/build.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+set -e # exit immediately if a command returns with a nonzero exit code
+
+echo "*** Building distcc/base image"
+docker build -t distcc/base -f base/Dockerfile base
+
+if [ $# -eq 0 ]; then
+ compilers=("gcc-4.8" "gcc-5" "clang-3.8")
+else
+ compilers=("$1")
+fi
+
+for compiler in "${compilers[@]}"
+do
+ echo "*** Building distcc/$compiler image"
+ docker build -t distcc/$compiler -f compilers/Dockerfile.$compiler .
+done
+
+echo "*** Building distcc"
+for compiler in "${compilers[@]}"
+do
+ echo "*** Building distcc with distcc/$compiler image"
+ set -x
+ docker run --rm -it -v /tmp:/tmp -v `pwd`/..:/src:rw -w /src distcc/$compiler bash -c "./autogen.sh && ./configure && make clean && make && make install && make check" &> distcc-$compiler.log
+ set +x
+done
diff --git a/docker/compilers/Dockerfile.clang-3.8 b/docker/compilers/Dockerfile.clang-3.8
new file mode 100644
index 0000000..0c6657c
--- /dev/null
+++ b/docker/compilers/Dockerfile.clang-3.8
@@ -0,0 +1,9 @@
+FROM distcc/base
+
+LABEL maintainer=""
+
+RUN apt-get update && \
+ apt-get install clang-3.8 build-essential && \
+ apt-get remove gcc g++ && \
+ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 50 && \
+ update-alternatives --install /usr/bin/cc cc /usr/bin/clang-3.8 50
diff --git a/docker/compilers/Dockerfile.gcc-4.8 b/docker/compilers/Dockerfile.gcc-4.8
new file mode 100644
index 0000000..ac227a7
--- /dev/null
+++ b/docker/compilers/Dockerfile.gcc-4.8
@@ -0,0 +1,11 @@
+FROM distcc/base
+
+LABEL maintainer=""
+
+RUN apt-get update && \
+ apt-get install gcc-4.8 \
+ gcc-multilib \
+ g++-4.8 \
+ g++-multilib && \
+ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 && \
+ update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-4.8 50
diff --git a/docker/compilers/Dockerfile.gcc-5 b/docker/compilers/Dockerfile.gcc-5
new file mode 100644
index 0000000..064ab14
--- /dev/null
+++ b/docker/compilers/Dockerfile.gcc-5
@@ -0,0 +1,11 @@
+FROM distcc/base
+
+LABEL maintainer=""
+
+RUN apt-get update && \
+ apt-get install gcc-5 \
+ gcc-multilib \
+ g++-5 \
+ g++-multilib && \
+ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 && \
+ update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-5 50
diff --git a/find_c_extension.sh b/find_c_extension.sh
index ab0f8f7..3172a0a 100755
--- a/find_c_extension.sh
+++ b/find_c_extension.sh
@@ -19,7 +19,7 @@ builddir="$1"
# (Side note: there is intense internal debate about whether the
# '[sd][ol]' hack is "so ugly I can't stand it" or "kinda cute".)
so_files=`ls $builddir/_include_server/lib.*/include_server/\
-distcc_pump_c_extensions.[sd][ol]*`
+distcc_pump_c_extensions*.[sd][ol]*`
if [ -z "$so_files" ]; then
echo \
'__________Could not find shared libraries for distcc-pump' 1>&2
diff --git a/gnome/distccmon-gnome.desktop b/gnome/distccmon-gnome.desktop
index 27e61e6..bd1fa26 100644
--- a/gnome/distccmon-gnome.desktop
+++ b/gnome/distccmon-gnome.desktop
@@ -3,9 +3,9 @@ Version=0.9.4
Encoding=UTF-8
Exec=distccmon-gnome
Name=distcc monitor
-Name[sv]=distcc övervakare
+Name[sv]=distcc övervakare
GenericName=Distributed Compile Monitor
-GenericName[sv]=Distribuerad kompilerings-övervakare
+GenericName[sv]=Distribuerad kompilerings-övervakare
Comment=Graphical view of distributed compile tasks
Comment[sv]=Grafisk vy av distribuerade kompileringsuppgifter
Icon=distccmon-gnome-icon.png
diff --git a/include_server/__init__.py b/include_server/__init__.py
deleted file mode 100755
index e69de29..0000000
--- a/include_server/__init__.py
+++ /dev/null
diff --git a/include_server/basics.py b/include_server/basics.py
index f2c5301..1a088b3 100755
--- a/include_server/basics.py
+++ b/include_server/basics.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
#
# Copyright 2007 Google Inc.
#
@@ -56,7 +56,7 @@ class ClientRootKeeper(object):
invariant. Some client roots are padded with '/padding' to satisfy the
invariant.
"""
-
+
# This constant is embedded in names of client root directories.
INCLUDE_SERVER_NAME = 'include_server'
@@ -84,7 +84,7 @@ class ClientRootKeeper(object):
return glob.glob('%s/*.%s-%s-*'
% (self.client_tmp, self.INCLUDE_SERVER_NAME,
pid_expr))
-
+
def ClientRootMakedir(self, generation):
"""Make a new client directory for a generation of compressed files.
@@ -104,7 +104,7 @@ class ClientRootKeeper(object):
+ '/padding' * self.number_missing_levels)
if not os.path.isdir(self.client_root):
os.makedirs(self.client_root)
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
sys.exit('Could not create client root directory %s: %s' %
(self.client_root, why))
@@ -204,7 +204,7 @@ ALGORITHMS = [SIMPLE, MEMOIZING]
# tested on a very large application, where include server time CPU time drops
# from 151s to 118s (best times out of 10 runs). There was no seeming changes to
# memory usage. Trying with 100,000 did not speed up the application further.
-GC_THRESHOLD = 10000
+GC_THRESHOLD = 10000
# FLAGS FOR COMMAND LINE OPTIONS
@@ -287,15 +287,15 @@ def Debug(trigger_pattern, message, *params):
i = 1
for unused_j in range(DEBUG_NUM_BITS):
if i & DEBUG_WARNING & triggered:
- print >> sys.stderr, 'WARNING include server:', message % params
+ print('WARNING include server:', message % params, file=sys.stderr)
if i & DEBUG_TRACE & triggered:
- print >> sys.stderr, 'TRACE:', message % params
+ print('TRACE:', message % params, file=sys.stderr)
elif i & DEBUG_TRACE1 & triggered:
- print >> sys.stderr, 'TRACE1:', message % params
+ print(sys.stderr, 'TRACE1:', message % params, file=sys.stderr)
elif i & DEBUG_TRACE2 & triggered:
- print >> sys.stderr, 'TRACE2:', message % params
+ print('TRACE2:', message % params, file=sys.stderr)
elif i & DEBUG_DATA & triggered:
- print >> sys.stderr, 'DATA:', message % params
+ print('DATA:', message % params, file=sys.stderr)
i *= 2
sys.stderr.flush()
@@ -342,7 +342,7 @@ class NotCoveredError(Error):
% (source_file, line_number, message))
else:
message = """File: '%s': %s""" % (source_file, message)
- # Message, a string, becomes self.args[0]
+ # Message, a string, becomes self.args[0]
Error.__init__(self, message)
@@ -390,8 +390,8 @@ class IncludeAnalyzerTimer(object):
sys.stdout.flush()
signal.alarm(0)
signal.signal(signal.SIGALRM, self.old)
-
-
+
+
class SignalSIGTERM(Error):
pass
@@ -415,7 +415,7 @@ def SafeNormPath(path):
Returns:
a string
-
+
Python's os.path.normpath is an unsafe operation; the result may not point to
the same file as the argument. Instead, this function just removes
initial './'s and a final '/'s if present.
diff --git a/include_server/basics_test.py b/include_server/basics_test.py
index 02d4f75..ab8dfdc 100755
--- a/include_server/basics_test.py
+++ b/include_server/basics_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -46,7 +46,7 @@ class BasicsTest(unittest.TestCase):
os_makedirs = os.makedirs
def Mock_tempfile_mkdtemp(pat, dir):
- self.assert_((pat, dir)
+ self.assertTrue((pat, dir)
in
[('.%s-%s-%d' %
(basics.ClientRootKeeper.INCLUDE_SERVER_NAME,
@@ -56,15 +56,15 @@ class BasicsTest(unittest.TestCase):
[(1,'/to/be'), (2, '/to')]])
return (dir == '/to/be' and '/to/be/xxxxxx'
or dir == '/to' and '/to/xxxxxxx')
-
+
def Mock_os_makedirs(f, *unused_args):
if not f.startswith('/to/'):
- raise Exception, f
-
+ raise Exception(f)
+
tempfile.mkdtemp = Mock_tempfile_mkdtemp
os.makedirs = Mock_os_makedirs
-
+
os.environ['DISTCC_CLIENT_TMP'] = '/to/be'
client_root_keeper = basics.ClientRootKeeper()
client_root_keeper.ClientRootMakedir(1)
@@ -91,13 +91,13 @@ class BasicsTest(unittest.TestCase):
os.environ['DISTCC_CLIENT_TMP'] = '/tmp'
client_root_keeper = basics.ClientRootKeeper()
client_root_keeper.ClientRootMakedir(117)
- self.assert_(os.path.isdir(client_root_keeper._client_root_before_padding))
- self.assert_(os.path.isdir(client_root_keeper.client_root))
- self.assert_(client_root_keeper.client_root.endswith('/padding'))
+ self.assertTrue(os.path.isdir(client_root_keeper._client_root_before_padding))
+ self.assertTrue(os.path.isdir(client_root_keeper.client_root))
+ self.assertTrue(client_root_keeper.client_root.endswith('/padding'))
client_root_keeper.ClientRootMakedir(118)
client_root_keeper.CleanOutClientRoots()
# Directories must be gone now!
- self.assert_(not os.path.isdir(
+ self.assertTrue(not os.path.isdir(
client_root_keeper._client_root_before_padding))
# Test with a two-level value of DISTCC_CLIENT_TMP.
try:
@@ -105,14 +105,14 @@ class BasicsTest(unittest.TestCase):
dir='/tmp')
client_root_keeper = basics.ClientRootKeeper()
client_root_keeper.ClientRootMakedir(117)
- self.assert_(os.path.isdir(
+ self.assertTrue(os.path.isdir(
client_root_keeper._client_root_before_padding))
- self.assert_(os.path.isdir(client_root_keeper.client_root))
+ self.assertTrue(os.path.isdir(client_root_keeper.client_root))
client_root_keeper.ClientRootMakedir(118)
client_root_keeper.CleanOutClientRoots()
- self.assert_(os.path.isdir,
+ self.assertTrue(os.path.isdir,
client_root_keeper._client_root_before_padding)
finally:
os.rmdir(os.environ['DISTCC_CLIENT_TMP'])
-unittest.main()
+unittest.main()
diff --git a/include_server/c_extensions/distcc_pump_c_extensions_module.c b/include_server/c_extensions/distcc_pump_c_extensions_module.c
index 549f922..2946df2 100644
--- a/include_server/c_extensions/distcc_pump_c_extensions_module.c
+++ b/include_server/c_extensions/distcc_pump_c_extensions_module.c
@@ -1,15 +1,15 @@
/* Copyright 2007 Google 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 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
@@ -65,11 +65,11 @@ CompressLzo1xAlloc(PyObject *dummy, PyObject *args) {
if (in_len < 0)
return NULL;
if (dcc_compress_lzo1x_alloc(in_buf, in_len, &out_buf, &out_len)) {
- PyErr_SetString(distcc_pump_c_extensionsError,
+ PyErr_SetString(distcc_pump_c_extensionsError,
"Couldn't compress that.");
return NULL;
}
- string_object = PyString_FromStringAndSize(out_buf, out_len);
+ string_object = PyBytes_FromStringAndSize(out_buf, out_len);
free(out_buf);
return string_object;
}
@@ -101,7 +101,7 @@ RCwd(PyObject *dummy, PyObject *args) {
"Couldn't read token string.");
return NULL;
}
- return PyString_FromString(value_str);
+ return PyUnicode_FromString(value_str);
}
@@ -124,11 +124,12 @@ RTokenString(PyObject *dummy, PyObject *args) {
if (!PyArg_ParseTuple(args, "is", &ifd, &expect_token))
return NULL;
if (dcc_r_token_string(ifd, expect_token, &value_str)) {
- PyErr_SetString(distcc_pump_c_extensionsError,
+ PyErr_SetString(distcc_pump_c_extensionsError,
"Couldn't read token string.");
return NULL;
}
- return PyString_FromString(value_str);
+
+ return PyUnicode_FromString(value_str);
}
@@ -158,7 +159,7 @@ RArgv(PyObject *dummy, PyObject *args) {
}
if ((list_object = PyList_New(0)) == NULL) goto error;
for (; argv[i]; i++) {
- string_object = PyString_FromString(argv[i]);
+ string_object = PyUnicode_FromString(argv[i]);
free(argv[i]);
if (!string_object) {
goto error;
@@ -172,7 +173,7 @@ RArgv(PyObject *dummy, PyObject *args) {
error:
Py_XDECREF(list_object);
Py_XDECREF(string_object);
- for (i = i + 1; argv[i]; i++)
+ for (i = i + 1; argv[i]; i++)
free(argv[i]);
free(argv);
return NULL;
@@ -209,8 +210,9 @@ XArgv(PyObject *dummy, PyObject *args) {
for (i = 0; i < len; i++) {
PyObject *string_object;
string_object = PyList_GetItem(list_object, i); /* borrowed ref */
- argv[i] = PyString_AsString(string_object); /* does not increase
- ref count */
+/* TODO do it properly, catch exceptions for fancy Unicode symbols */
+ argv[i] = PyUnicode_AsUTF8(string_object); /* does not increase
+ ref count */
}
ret = dcc_x_argv(ifd, "ARGC", "ARGV", argv);
free(argv);
@@ -233,7 +235,7 @@ static /* const */ char OsPathExists_doc__[] =
" Arguments:\n"
" filepath: a string\n"
" Returns:\n"
-" True or False\n"
+" True or False\n"
;
static PyObject *
@@ -241,20 +243,20 @@ OsPathExists(PyObject *dummy, PyObject *args) {
const char *in;
int len;
int res;
-
+
struct stat buf;
-
+
UNUSED(dummy);
if (!PyArg_ParseTuple(args, "s#", &in, &len))
return NULL;
if (len < 0)
return NULL;
- res = stat(in, &buf);
+ res = stat(in, &buf);
if (res == -1) Py_RETURN_FALSE;
if (res == 0) Py_RETURN_TRUE;
assert(0);
return NULL;
-}
+}
/***********************************************************************
OsPathIsFile
@@ -267,7 +269,7 @@ static /* const */ char OsPathIsFile_doc__[] =
" Arguments:\n"
" filename: a string\n"
" Returns:\n"
-" True or False\n"
+" True or False\n"
;
static PyObject *
@@ -275,20 +277,20 @@ OsPathIsFile(PyObject *dummy, PyObject *args) {
const char *in;
int len;
int res;
-
+
struct stat buf;
-
+
UNUSED(dummy);
if (!PyArg_ParseTuple(args, "s#", &in, &len))
return NULL;
if (len < 0)
return NULL;
- res = stat(in, &buf);
+ res = stat(in, &buf);
if (res == -1) Py_RETURN_FALSE;
if ((res == 0) && S_ISREG(buf.st_mode)) Py_RETURN_TRUE;
if ((res == 0) && !S_ISREG(buf.st_mode)) Py_RETURN_FALSE;
return NULL;
-}
+}
@@ -345,61 +347,93 @@ Realpath(PyObject *dummy, PyObject *args) {
/* On Solaris this result may be a relative path, if the argument was
relative. Fail hard if this happens. */
assert(res[0] == '/');
- result_str = PyString_FromStringAndSize(res, strlen(res));
+ result_str = PyUnicode_FromStringAndSize(res, strlen(res));
if (result_str == NULL)
return PyErr_NoMemory();
return result_str;
- }
+ }
else {
- return PyString_FromStringAndSize(in, strlen(in));
+ return PyUnicode_FromStringAndSize(in, strlen(in));
}
}
/***********************************************************************
-Bindings
+Bindings;
************************************************************************/
-static PyMethodDef methods[] = {
- {"OsPathExists", (PyCFunction)OsPathExists, METH_VARARGS,
+struct module_state {
+ PyObject *error;
+};
+
+#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
+
+static const char module_documentation[]=
+"Various utilities for distcc-pump.\n"
+;
+
+static int module_traverse(PyObject *m, visitproc visit, void *arg) {
+ Py_VISIT(GETSTATE(m)->error);
+ return 0;
+}
+
+static int module_clear(PyObject *m) {
+ Py_CLEAR(GETSTATE(m)->error);
+ return 0;
+}
+
+static PyMethodDef module_methods[] = {
+ {"OsPathExists", (PyCFunction)OsPathExists, METH_VARARGS,
OsPathExists_doc__},
- {"OsPathIsFile", (PyCFunction)OsPathIsFile, METH_VARARGS,
+ {"OsPathIsFile", (PyCFunction)OsPathIsFile, METH_VARARGS,
OsPathIsFile_doc__},
{"Realpath", (PyCFunction)Realpath, METH_VARARGS, Realpath_doc__},
- {"RTokenString",(PyCFunction)RTokenString, METH_VARARGS,
+ {"RTokenString",(PyCFunction)RTokenString, METH_VARARGS,
RTokenString_doc__},
{"RCwd", (PyCFunction)RCwd, METH_VARARGS, RCwd_doc__},
{"RArgv", (PyCFunction)RArgv, METH_VARARGS, RArgv_doc__},
{"XArgv", (PyCFunction)XArgv, METH_VARARGS, XArgv_doc__},
- {"CompressLzo1xAlloc", (PyCFunction)CompressLzo1xAlloc, METH_VARARGS,
+ {"CompressLzo1xAlloc", (PyCFunction)CompressLzo1xAlloc, METH_VARARGS,
CompressLzo1xAlloc_doc__},
{NULL, NULL, 0, NULL}
};
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "distcc_pump_c_extensions", /* m_name */
+ module_documentation, /* m_doc */
+ sizeof(struct module_state),/* m_size */
+ module_methods, /* m_methods */
+ NULL, /* m_reload */
+ module_traverse, /* m_traverse */
+ module_clear, /* m_clear */
+ NULL, /* m_free */
+};
-static /* const */ char module_documentation[]=
-"Various utilities for distcc-pump.\n"
-;
-
-void initdistcc_pump_c_extensions(void) {
- PyObject *module;
+PyObject *
+PyInit_distcc_pump_c_extensions(void) {
+ PyObject *module = PyModule_Create(&moduledef);
PyObject *py_str;
distcc_pump_c_extensionsError = PyErr_NewException(
(char *)"distcc_pump_c_extensions.Error", NULL, NULL);
-
- module = Py_InitModule4("distcc_pump_c_extensions",
- methods,
- module_documentation,
- NULL,
- PYTHON_API_VERSION);
-
- py_str = PyString_FromString("Nils Klarlund");
+
+ if (module == NULL)
+ return NULL;
+
+ struct module_state *st = GETSTATE(module);
+ st->error = distcc_pump_c_extensionsError;
+ if (st->error == NULL) {
+ Py_DECREF(module);
+ return NULL;
+ }
+
+ py_str = PyUnicode_FromString("Nils Klarlund");
+ py_str = PyUnicode_FromString(version);
PyModule_AddObject(module, "__author__", py_str);
- py_str = PyString_FromString(version);
PyModule_AddObject(module, "__version__", py_str);
/* Make the exception class accessible */
PyModule_AddObject(module, "Error",
distcc_pump_c_extensionsError);
-
+ return module;
}
diff --git a/include_server/c_extensions_test.py b/include_server/c_extensions_test.py
index bdb3eb4..c5cbfdb 100755
--- a/include_server/c_extensions_test.py
+++ b/include_server/c_extensions_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-#
+#
"""Tests for distcc_pump_c_extensions.
@@ -55,11 +55,11 @@ def RunTest(random_filename):
# Pack something and try sending it
fd = _MakeTempFile('wb')
- fd.write('ARGC 2')
- fd.write('ARGV 6')
- fd.write('tomato')
- fd.write('ARGV 7')
- fd.write('potatos')
+ fd.write(b'ARGC 2')
+ fd.write(b'ARGV 6')
+ fd.write(b'tomato')
+ fd.write(b'ARGV 7')
+ fd.write(b'potatos')
fd.close()
# Now try to read it back with wrong expectations.
@@ -97,24 +97,24 @@ def RunTest(random_filename):
fd.close()
# Libc functions --- also print out how fast they are compared to
- # Python built-ins.
+ # Python built-ins.
t = time.time()
f = '/'
for unused_i in range(10000):
distcc_pump_c_extensions.OsPathExists(f)
- print 'Stat', time.time() - t
+ print('Stat', time.time() - t)
t = time.time()
for unused_i in range(10000):
os.path.exists(f)
- print 'os.path.exists', time.time() - t
+ print('os.path.exists', time.time() - t)
for unused_i in range(10000):
distcc_pump_c_extensions.Realpath(f)
- print 'c_realpath', time.time() - t
+ print('c_realpath', time.time() - t)
t = time.time()
for unused_i in range(10000):
os.path.realpath(f)
- print 'os.path.realpath', time.time() - t
- print 'c_extenstions_test passed'
+ print('os.path.realpath', time.time() - t)
+ print('c_extenstions_test passed')
def main():
@@ -124,12 +124,12 @@ def main():
try:
if os.path.exists(random_testdir):
os.removedirs(random_testdir)
- os.mkdir(random_testdir, 0700)
- except (IOError, OSError), why:
+ os.mkdir(random_testdir)
+ except (IOError, OSError) as why:
sys.exit('Unable to create test dir %s: %s.' % (random_testdir, why))
random_filename = os.path.join(random_testdir, 'test')
assert not os.path.exists(random_filename), random_filename
-
+
try:
RunTest(random_filename)
finally:
diff --git a/include_server/cache_basics.py b/include_server/cache_basics.py
index 1826ce7..8f4ca2e 100755
--- a/include_server/cache_basics.py
+++ b/include_server/cache_basics.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-#
+#
"""Classes enabling definition and composition of caches.
@@ -347,7 +347,7 @@ class DirnameCache(object):
self.cache[(currdir_idx, searchdir_idx, includepath_idx)] = (dir_idx,
rp_idx)
return (dir_idx, rp_idx)
-
+
class SystemdirPrefixCache(object):
"""A cache of information about whether a file exists in a systemdir.
@@ -389,14 +389,14 @@ class SystemdirPrefixCache(object):
Argument:
realpath_map: a string-to-int map of canonicalized filepaths we know.
-
+
After this function is called, the cache entry is True iff
realpath.startswith(systemdir) is True for any of the systemdirs
passed in to our constructor.
"""
if len(self.cache) >= realpath_map.Length():
return # we're already all full
- for realpath_idx in xrange(len(self.cache), realpath_map.Length()):
+ for realpath_idx in range(len(self.cache), realpath_map.Length()):
realpath = realpath_map.string[realpath_idx]
for systemdir in self.systemdirs:
if realpath.startswith(systemdir):
@@ -560,7 +560,7 @@ class CanonicalMapToIndex(MapToIndex):
"""
return MapToIndex.Index(self, self.canonicalize(filepath))
-
+
def RetrieveDirectoriesExceptSys(directory_map, realpath_map,
systemdir_prefix_cache, directory_idxs):
"""Calculate the set of non-system directories of an index list.
@@ -572,7 +572,7 @@ def RetrieveDirectoriesExceptSys(directory_map, realpath_map,
Returns:
the corresponding tuple of directories except for those whose
realpath has a prefix that is a sysdir
-
+
The directories in the returned list have their trailing '/'
stripped.
"""
@@ -725,14 +725,13 @@ class BuildStatCache(object):
assert searchdir_idx is None or 1 <= searchdir_idx < dir_map.Length()
for sl_idx in searchlist_idxs:
assert sl_idx < dir_map.Length()
- assert os.getcwd() + '/' == dir_map_string[currdir_idx], (
- "'%s/' != '%s'" % (os.getcwd(), dir_map_string[currdir_idx]))
+ assert os.getcwd() + '/' == dir_map_string[currdir_idx]
Debug(DEBUG_TRACE2, "Resolve: includepath: '%s', currdir: '%s', "
"searchdir: '%s', searchlist: %s" %
- (includepath,
- dir_map_string[currdir_idx],
- searchdir_idx and dir_map_string[searchdir_idx],
- " \n".join([dir_map_string[idx] for idx in searchlist_idxs])))
+ (includepath,
+ dir_map_string[currdir_idx],
+ searchdir_idx and dir_map_string[searchdir_idx],
+ " \n".join([dir_map_string[idx] for idx in searchlist_idxs])))
try:
# Locate the array (list) relative to currdir_idx and includepath_idx
searchdir_stats = build_stat[currdir_idx][includepath_idx]
@@ -819,7 +818,7 @@ class SetUpCaches(object):
"""
def __init__(self, client_root):
-
+
# A memoizing (caching) class to canonicalize a path: mostly by
# resolving any symlinks in the path-component.
self.canonical_path = CanonicalPath()
diff --git a/include_server/compiler_defaults.py b/include_server/compiler_defaults.py
index d0c27d5..da4e05a 100755
--- a/include_server/compiler_defaults.py
+++ b/include_server/compiler_defaults.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""Divination of built-in system directories used by compiler installation.
It is undesirable for the distcc-pump to send header files that reside
@@ -48,7 +48,7 @@ DEBUG_TRACE = basics.DEBUG_TRACE
DEBUG_DATA = basics.DEBUG_DATA
NotCoveredError = basics.NotCoveredError
-
+
def _RealPrefixWithinClientRoot(client_root, path):
"""Determine longest directory prefix of PATH and whether PATH contains a symlink.
@@ -215,9 +215,9 @@ def _SystemSearchdirsGCC(compiler, sysroot, language, canonical_lookup):
stdin=None,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
- env=trimmed_env)
+ env=trimmed_env,universal_newlines=True)
out = p.communicate()[0]
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
raise NotCoveredError (
( "Couldn't determine default system include directories\n"
+ "for compiler '%s', language '%s':\n"
@@ -232,7 +232,7 @@ def _SystemSearchdirsGCC(compiler, sysroot, language, canonical_lookup):
(compiler, language, command, p.returncode, out))
match_obj = re.search(
- r"%s\n(.*?)\n%s" # don't ask
+ "%s\n(.*?)\n%s" # don't ask
% ("#include <...> search starts here:", "End of search list"),
out,
re.MULTILINE + re.DOTALL)
diff --git a/include_server/compress_files.py b/include_server/compress_files.py
index 20512fd..880551e 100755
--- a/include_server/compress_files.py
+++ b/include_server/compress_files.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""Compress files in an include closure."""
import os
@@ -67,10 +67,10 @@ class CompressFiles(object):
if len(include_closure[realpath_idx]) > 0:
# Designate by suffix '.abs' that this file is to become known by an
# absolute filepath through a #line directive.
- new_filepath = "%s%s.lzo.abs" % (client_root_keeper.client_root,
+ new_filepath = "%s%s.lzo.abs" % (client_root_keeper.client_root,
realpath)
else:
- new_filepath = "%s%s.lzo" % (client_root_keeper.client_root,
+ new_filepath = "%s%s.lzo" % (client_root_keeper.client_root,
realpath)
files.append(new_filepath)
if not new_filepath in self.files_compressed:
@@ -80,7 +80,7 @@ class CompressFiles(object):
if not os.path.isdir(dirname):
my_root = client_root_keeper.client_root
self.mirror_path.DoPath(realpath, currdir_idx, my_root)
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
# Kill include server
sys.exit("Could not make directory '%s': %s" % (dirname, why))
if new_filepath.endswith('.abs'):
@@ -99,17 +99,17 @@ class CompressFiles(object):
prefix = ""
try:
real_file_fd = open(realpath, "r")
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
sys.exit("Could not open '%s' for reading: %s" % (realpath, why))
try:
new_filepath_fd = open(new_filepath, "wb")
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
sys.exit("Could not open '%s' for writing: %s" % (new_filepath, why))
try:
new_filepath_fd.write(
distcc_pump_c_extensions.CompressLzo1xAlloc(
prefix + real_file_fd.read()))
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
sys.exit("Could not write to '%s': %s" % (new_filepath, why))
new_filepath_fd.close()
real_file_fd.close()
diff --git a/include_server/include_analyzer.py b/include_server/include_analyzer.py
index 450b593..b284bbd 100755
--- a/include_server/include_analyzer.py
+++ b/include_server/include_analyzer.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""The skeleton for an include analyzer.
This module defines the basic caches and helper functions for an
@@ -139,7 +139,7 @@ class IncludeAnalyzer(object):
os.path.join(currdir, fpath),
self.currdir_idx,
self.client_root_keeper.client_root)
-
+
closure = self.RunAlgorithm(fpath_resolved_pair, fpath_real)
return closure
@@ -194,7 +194,7 @@ class IncludeAnalyzer(object):
def DoStatResetTriggers(self):
"""Reset stat caches if a glob evaluates differently from earlier.
-
+
More precisely, if a path of a glob comes in or out of existence or has a
new stamp, then reset stat caches."""
@@ -233,8 +233,8 @@ class IncludeAnalyzer(object):
def DoCompilationCommand(self, cmd, currdir, client_root_keeper):
"""Parse and and process the command; then gather files and links."""
-
- self.translation_unit = "unknown translation unit" # don't know yet
+
+ self.translation_unit = "unknown translation unit" # don't know yet
# Any relative paths in the globs in the --stat_reset_trigger argument
# must be evaluated relative to the include server's original working
@@ -346,7 +346,7 @@ class IncludeAnalyzer(object):
where searchdir_i is an absolute path. realpath_idx is a realpath
index corresponding to a single #include (more exactly, it's the
index of the path that the #include resolves to).
-
+
This include closure calculation omits any system header files,
that is, header files found in a systemdir (recall systemdirs are
those searchdirs that are built into the preprocessor, such as
@@ -396,7 +396,7 @@ class IncludeAnalyzer(object):
This method to be overridden by derived class.
"""
- raise Exception, "RunAlgorithm not implemented."
+ raise Exception("RunAlgorithm not implemented.")
def ClearStatCaches(self):
"""Clear caches used for, or dependent on, stats."""
diff --git a/include_server/include_analyzer_memoizing_node.py b/include_server/include_analyzer_memoizing_node.py
index c7471f5..e870c1c 100755
--- a/include_server/include_analyzer_memoizing_node.py
+++ b/include_server/include_analyzer_memoizing_node.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""A graph-based algorithm for memoizing include closure calculations."""
__author__ = "Nils Klarlund"
@@ -66,9 +66,9 @@ class UnionCache(object):
id_map: the set of frozen sets we have seen mapped to {1, 2, ..}
"""
self.members = {}
- self.cache = {}
+ self.cache = {}
self.id_map = {}
-
+
def SetId(self, members):
"""Memoize the frozenset of members and return set id."""
frozen = frozenset(members)
@@ -82,7 +82,7 @@ class UnionCache(object):
def Elements(self, set_id):
"""The frozenset corresponding to a set id."""
return self.members[set_id]
-
+
def Union(self, set1_id, set2_id):
"""Return the set id of the union of sets represented by set ids."""
try:
@@ -108,7 +108,7 @@ class SupportRecord(object):
def __init__(self, support_master):
"""Constructor.
Argument:
- support_master: a record for holding the reverse mapping from symbols to
+ support_master: a record for holding the reverse mapping from symbols to
support records that contain them.
Instance Variables:
support_master: see above
@@ -122,7 +122,7 @@ class SupportRecord(object):
self.valid = True
self.union_cache = support_master.union_cache
self.support_id = self.union_cache.SetId([])
-
+
def Update(self, set_id):
"""Augment the support record with the set represented by set_id.
"""
@@ -148,7 +148,7 @@ class SupportMaster(object):
A map symbol_to_records is maintained. For each symbol s
self.symbol_to_records[s] is the set of support records r whose support set
contains s."""
-
+
def __init__(self):
"""Constructor.
@@ -171,8 +171,8 @@ class SupportMaster(object):
if symbol in self.symbol_to_records:
for support_record in self.symbol_to_records[symbol]:
support_record.valid = False
-
-
+
+
class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
"""A memoizing algorithm for include analysis based on a graph construction.
@@ -230,18 +230,18 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
directory as understood above must also be taken into account.
In particular, we also use as keys pairs of the form:
-
+
(realpath index of resolved file, real path index of filedir).
This realpath-oriented memoization is not a frivolous attempt at optimization.
It is essential to avoiding infinite loops as in:
-
+
D/mem.h
D/../D/mem.h
D/../D/../D/mem.h
generated by an include of the form "#include ../D/mem.h" in file mem.h.
-
+
One would think that obviosly these prefixes denote the same location. But
they need not! For D of the first line could be a symbolic link to a real
directory dir1_D. And, the second D could be another symbolic link in
@@ -312,13 +312,13 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
lhs, rhs = d_opt[0], "1"
elif len(d_opt) == 2:
[lhs, rhs] = d_opt
- parse_file.InsertMacroDefInTable(lhs, rhs, self.symbol_table,
+ parse_file.InsertMacroDefInTable(lhs, rhs, self.symbol_table,
self.support_master.InvalidateRecords)
else:
# Assume this is a syntax error of some sort.
pass
-
- # Construct or find the node for filepath_resolved.
+
+ # Construct or find the node for filepath_resolved.
node = self.FindNode(nodes_for_incl_config,
filepath_resolved_pair,
RESOLVED,
@@ -391,8 +391,8 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
# file_dir_idx, because the filepath is resolved against file_dir.
key = (fp, resolution_mode, file_dir_idx)
if key in nodes_for_incl_config:
- # Is the support record valid?
- if nodes_for_incl_config[key][self.SUPPORT_RECORD].valid:
+ # Is the support record valid?
+ if nodes_for_incl_config[key][self.SUPPORT_RECORD].valid:
statistics.master_hit_counter += 1
return nodes_for_incl_config[key]
else:
@@ -408,7 +408,7 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
# code below -- we don't want to reuse an earlier result.
[fp_real_idx, fp_resolved_pair, _, support_record] = node
Debug(DEBUG_TRACE,
- "Invalid record for translation unit: %s, file: %s",
+ "Invalid record for translation unit: %s, file: %s",
self.translation_unit, self._PrintableFilePath(fp))
else:
@@ -485,7 +485,7 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
# Now, we've got the resolution: (search directory, include path).
assert (fp and fp_real_idx and fp_resolved_pair)
(searchdir_idx, includepath_idx) = fp_resolved_pair
-
+
# We need the realpath index of the current file directory. That's because
# we are going to ask whether we have really visited this file, despite the
# failure above to recognize it using a possibly relative name. Here,
@@ -501,9 +501,9 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
except KeyError:
(fp_dirname_idx, fp_dirname_real_idx) = (
self.dirname_cache.Lookup(currdir_idx,
- searchdir_idx,
+ searchdir_idx,
includepath_idx))
-
+
if resolution_mode != RESOLVED:
# See whether we know about filepath post-resolution.
if ((fp_real_idx, fp_dirname_real_idx) in nodes_for_incl_config
@@ -522,7 +522,7 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
statistics.master_miss_counter += 1
# If we're revisiting because the support record was invalid, then it is
# time to set it.
- support_record.valid = True
+ support_record.valid = True
# Try to get the cached result of parsing file.
try:
@@ -573,7 +573,7 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer):
self.quote_dirs, self.angle_dirs,
self.symbol_table))
for (fp_resolved_pair_, fp_real_idx_) in files:
- node_ = self.FindNode(nodes_for_incl_config,
+ node_ = self.FindNode(nodes_for_incl_config,
fp_resolved_pair_,
RESOLVED, None, fp_real_idx_)
if node_:
diff --git a/include_server/include_analyzer_memoizing_node_test.py b/include_server/include_analyzer_memoizing_node_test.py
index d3247db..aeeef8e 100755
--- a/include_server/include_analyzer_memoizing_node_test.py
+++ b/include_server/include_analyzer_memoizing_node_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
__author__ = "Nils Klarlund"
import os
@@ -31,7 +31,7 @@ import unittest
NotCoveredError = basics.NotCoveredError
class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
-
+
def _ToString(self, include_closure):
"""Translate the indices in an include closure to their denoted strings."""
return (
@@ -40,7 +40,7 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
self.includepath_map.string[ip_idx])
for (dir_idx, ip_idx) in include_closure[rp_idx] ])
for rp_idx in include_closure))
-
+
def setUp(self):
basics.opt_debug_pattern = 1
client_root_keeper = basics.ClientRootKeeper()
@@ -98,8 +98,8 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
dir_idx = directory_map.Index("/dir")
A_children = []
- A = (realpath_map.Index("/curr/src/a.h"),
- (src_idx, includepath_map.Index("a.h")),
+ A = (realpath_map.Index("/curr/src/a.h"),
+ (src_idx, includepath_map.Index("a.h")),
A_children)
B_children = []
@@ -121,7 +121,7 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
D = (None, None, D_children)
E_children = []
- E = (realpath_map.Index("/dir/e.h"),
+ E = (realpath_map.Index("/dir/e.h"),
(root_idx, includepath_map.Index("dir/e.h")),
E_children)
@@ -135,13 +135,13 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
include_closure = {}
self.include_analyzer._CalculateIncludeClosureExceptSystem(A, include_closure)
stringified_include_closure = self._ToString(include_closure)
-
+
# /curr/src/a.h is not known under absolute pathnames.
self.assertEqual(stringified_include_closure['/curr/src/a.h'], [])
# Neither is /curr/src/b.h.
self.assertEqual(stringified_include_closure['/curr/src/b.h'], [])
# But, /dir/c.h is known under two different absolute names.
- self.assertEqual(stringified_include_closure['/dir/c.h'],
+ self.assertEqual(stringified_include_closure['/dir/c.h'],
[('/dirlink/', 'c.h'), ('/', 'dir/c.h')])
# And, dir/e.h is known under exactly one absolute name.
self.assertEqual(stringified_include_closure['/dir/e.h'], [('/', 'dir/e.h')])
@@ -160,7 +160,7 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
" -Isrc" +
" -I./lzo" +
" -include include_me.h " +
- " -o src/%s.o" +
+ " -o src/%s.o" +
" -c src/%s.c") % (src_stem, src_stem)
def test__CalculateIncludeClosureExceptSystem_on_distcc(self):
@@ -180,12 +180,12 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
parsed_command = (
parse_command.ParseCommandArgs(
parse_command.ParseCommandLine(cmd),
- current_dir,
- include_analyzer.includepath_map,
+ current_dir,
+ include_analyzer.includepath_map,
include_analyzer.directory_map,
include_analyzer.compiler_defaults))
- (include_analyzer.quote_dirs,
+ (include_analyzer.quote_dirs,
include_analyzer.angle_dirs,
include_analyzer.include_files,
translation_unit,
@@ -208,7 +208,7 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
"src/hosts.h",
"src/bulk.h",
"src/emaillog.h"]
-
+
include_closure = (
include_analyzer.ProcessCompilationCommand(current_dir,
parsed_command))
@@ -228,7 +228,7 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase):
# different search path files are reported as absolute. That is,
# provoke pairs (directory_idx, includepath_idx) to exist in
# include_closure[rp_idx].
-
+
def tearDown(self):
pass
diff --git a/include_server/include_analyzer_test.py b/include_server/include_analyzer_test.py
index 4232934..0a6d1d3 100755
--- a/include_server/include_analyzer_test.py
+++ b/include_server/include_analyzer_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -95,7 +95,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
self.CanonicalPathsForTestData(['test_computed_includes/src.c',
'test_computed_includes/helper.c',
'test_computed_includes/incl.h']))
-
+
includes = self.RetrieveCanonicalPaths(
self.ProcessCompilationCommandLine(
"gcc test_data/test_computed_includes/srcA.c",
@@ -117,7 +117,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
def FindNode(self, *_):
self.count += 1
if self.count == 2:
- raise Exception, "Did not expect 2 calls of FindNode."
+ raise Exception("Did not expect 2 calls of FindNode.")
return old_FindNode(*_)
self.include_analyzer.FindNode = mock_FindNode().FindNode
@@ -145,12 +145,12 @@ class IncludeAnalyzerTest(unittest.TestCase):
'test_computed_includes/inclA.h',
'dfoo/foo2.h']))
-
+
# Test: functional macros can be passed on the command line.
includes = self.RetrieveCanonicalPaths(
self.ProcessCompilationCommandLine(
"""gcc -D"STR(X)=# X" """
- + """-D"FINCLUDE(P)=STR(../MY_TEST_DATA/dfoo/P)" """
+ + """-D"FINCLUDE(P)=STR(../MY_TEST_DATA/dfoo/P)" """
+ """-DMY_TEST_DATA=test_data """
+ "test_data/func_macro.c",
os.getcwd()))
@@ -207,16 +207,16 @@ class IncludeAnalyzerTest(unittest.TestCase):
finally:
basics.opt_unsafe_absolute_includes = opt_unsafe_absolute_includes
shutil.rmtree(tmp_dir)
-
+
def test_StatResetTriggers(self):
-
+
"""Check that the include analysis of a file is done from scratch after a
trigger path went from non-existing to existing.
"""
def CheckGeneration(lst, expected):
for f_name in lst:
- self.failUnless(
+ self.assertTrue(
re.match(r"%s/.+[.]include_server[-][0-9]+[-]%s"
% (self.include_analyzer.client_root_keeper.client_tmp,
expected),
@@ -232,7 +232,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
+ '/'
+ f_name.split('/')[-1][:-4]
for f_name in lst if f_name.endswith('.lzo') ]
-
+
self.include_analyzer.stat_reset_triggers = {"seven*": {},
"ate": {"ate": (1,111,2)},
"nine": {} }
@@ -247,10 +247,10 @@ class IncludeAnalyzerTest(unittest.TestCase):
glob.glob = Mock_GlobGlob
real_os_stat = os.stat
- def Mock_OsStat(f):
+ def Mock_OsStat(f, dir_fd=None, follow_symlinks=True):
# Return the same as initial value in two cases below.
if f in ["seven", "nine"]: raise OSError
- if f == 'ate':
+ if f == 'ate':
obj = lambda: None
obj.st_mtime = 1
obj.st_ino = 111
@@ -267,7 +267,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
return f in [ "test_data/stat_triggers.c",
"test_data/dfoo/stat_triggers.h"]
cache_basics._OsPathIsFile = Mock_OsPathIsFile
-
+
files_and_links = self.include_analyzer.DoCompilationCommand(
"gcc -Itest_data/dfoo test_data/stat_triggers.c".split(),
os.getcwd(),
@@ -282,7 +282,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
self.assertEqual(self.include_analyzer.generation, 1)
CheckGeneration(files_and_links, 1)
- def New_Mock_OsStat(f):
+ def New_Mock_OsStat(f, dir_fd=None, follow_symlinks=True):
if f in ["seven", "nine"]: raise OSError
if f == 'ate':
obj = lambda: None
@@ -307,7 +307,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
self.assertEqual(self.include_analyzer.generation, 2)
CheckGeneration(files_and_links, 2)
-
+
# Now, check that we picked up the test_data version of the .h file, not
# the dfoo one!
self.assertEqual(GetFileNamesFromAbsLzoName(files_and_links),
@@ -322,19 +322,19 @@ class IncludeAnalyzerTest(unittest.TestCase):
return real_glob_glob(f)
glob.glob = New_Mock_GlobGlob
- def New_New_Mock_OsStat(f):
+ def New_New_Mock_OsStat(f, dir_fd=None, follow_symlinks=True):
if f in ["seven", "nine"]: raise OSError
if f == 'ate':
obj = lambda: None
obj.st_mtime = 1
obj.st_ino = 111
- obj.st_dev = 3
+ obj.st_dev = 3
return obj
if f == 'seventy':
obj = lambda: None
obj.st_mtime = 2
obj.st_ino = 222
- obj.st_dev = 3
+ obj.st_dev = 3
return obj
return real_os_stat(f)
os.stat = New_New_Mock_OsStat
@@ -351,10 +351,10 @@ class IncludeAnalyzerTest(unittest.TestCase):
self.assertEqual(GetFileNamesFromAbsLzoName(files_and_links),
['test_data/stat_triggers.c',
'dfoo/stat_triggers.h'])
-
+
self.assertEqual(self.include_analyzer.generation, 3)
CheckGeneration(files_and_links, 3)
-
+
finally:
glob.glob = real_glob_glob
os.stat = real_os_stat
@@ -375,7 +375,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
# symlink_farm/sub_farm/link_to_dd_dd_dfoo_include_dotdot_foo
#
# which is a link to ../../dfoo/include_dotdot_foo, that is, to
- #
+ #
# dfoo/include_dotdot_foo
#
# which is a file that contains:
@@ -408,7 +408,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
['dfoo/include_dotdot_foo', 'symlink_farm/foo'],
"test_data"))
-
+
def helper_test_IncludeAnalyzer(self, test_data_dir):
"""Test basic functionality assuming test data is in test_data_dir."""
@@ -523,7 +523,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
'test_include_next/foo/y.h',
'test_include_next/baz/y.h'],
test_data_dir))
-
+
# Test that a directory that has a name matching an include is not picked.
# Here the directory is test_data/i_am_perhaps_a_directory.h, which is in
# the file directory of the translation unit. Instead,
@@ -553,7 +553,7 @@ class IncludeAnalyzerTest(unittest.TestCase):
for algorithm in [ basics.MEMOIZING ]:
try:
- print "TESTING ALGORITHM %s" % algorithm
+ print("TESTING ALGORITHM %s" % algorithm)
unittest.main()
except:
raise
diff --git a/include_server/include_server.py b/include_server/include_server.py
index 039a9ef..3b50247 100755
--- a/include_server/include_server.py
+++ b/include_server/include_server.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -32,7 +32,7 @@ import os
import re
import shutil
import signal
-import SocketServer
+import socketserver
import sys
import tempfile
import traceback
@@ -44,7 +44,7 @@ import include_analyzer_memoizing_node
import statistics
# The default size passed to listen by a streaming socket server of
-# SocketServer is only 5. Make it 128 (which appears to be the hard
+# socketserver is only 5. Make it 128 (which appears to be the hard
# built-in limit for Linux). This enables requests to the include
# server to be buffered better.
REQUEST_QUEUE_SIZE = 128
@@ -61,7 +61,7 @@ NotCoveredTimeOutError = basics.NotCoveredTimeOutError
# USAGE
def Usage():
- print """Usage:
+ print("""Usage:
include_server --port INCLUDE_SERVER_PORT [OPTIONS]
@@ -77,15 +77,15 @@ OPTIONS:
1 = warnings
2 = trace some functions
other powers of two: see basics.py.
-
+
-e, --email Send email to discc-pump developers when include
server gets in trouble.
--email_bound NUMBER Maximal number of emails to send (in addition to
a final email). Default: 3.
-
+
--no-email Do not send email.
-
+
--path_observation_re=RE Issue warning message whenever a filename is
resolved to a realpath that is matched by RE,
which is a regular expression in Python syntax.
@@ -95,9 +95,9 @@ OPTIONS:
--pid_file FILEPATH The pid of the include server is written to file
FILEPATH.
-
+
-s, --statistics Print information to stdout about include analysis.
-
+
--stat_reset_triggers=LIST Flush stat caches when the timestamp of any
filepath in LIST changes or the filepath comes in
or out of existence. LIST is a colon separated
@@ -110,7 +110,7 @@ OPTIONS:
-t, --time Print elapsed, user, and system time to stderr.
- --unsafe_absolute_includes Do preprocessing on the compilation server even if
+ --unsafe_absolute_includes Do preprocessing on the compilation server even if
includes of absolute filepaths are encountered.
Such includes are then ignored for the purposes of
gathering the include closure. See the
@@ -122,17 +122,17 @@ OPTIONS:
some cases, but will break builds which use
include structures like "<foo/../file.h>" without
including other files in foo/.
-
+
-v, --verify Verify that files in CPP closure are contained in
closure calculated by include processor.
-
+
-w, --write_include_closure Write a .d_approx file which lists all the
included files calculated by the include server;
with -x, additionally write the included files
as calculated by CPP to a .d_exact file.
-x, --exact_analysis Use CPP instead, do not omit system headers files.
-"""
+""")
# TODO(klarlund)
# --simple_algorithm not currently implemented
@@ -142,10 +142,10 @@ OPTIONS:
def _PrintStackTrace(fd):
"""Print stacktrace to file object."""
- print >> fd, '------- Include server stack trace -----------'
+ print('------- Include server stack trace -----------', file=fd)
# Limit is 1000 entries.
traceback.print_exc(1000, fd)
- print >> fd, '----------------------------------------------'
+ print('----------------------------------------------', file=fd)
class _EmailSender(object):
@@ -176,7 +176,7 @@ class _EmailSender(object):
basics.EMAIL_SUBJECT,
basics.DCC_EMAILLOG_WHOM_TO_BLAME,
user_addr,
- "Automated email number %d in include server session.\n" %
+ "Automated email number %d in include server session.\n" %
self.number_sent,
fd.read())
s = smtplib.SMTP()
@@ -195,7 +195,7 @@ class _EmailSender(object):
Arguments:
fd: a file object that will be closed.
force: send the mail even if number of emails sent exceed
- basics.opt_email_bound
+ basics.opt_email_bound
"""
fd.seek(0, 0)
Debug(DEBUG_WARNING, "%s", fd.read())
@@ -257,7 +257,7 @@ def ExactDependencies(cmd, realpath_map, systemdir_prefix_cache,
fd_d_.read())))
fd_d_.close()
_delete_temp_files()
- # The sets of dependencies is a set the of realpath indices of the
+ # The sets of dependencies is a set the of realpath indices of the
# absolute filenames corresponding to files in the dotd file.
deps = set([ rp_idx
for filepath in dotd.split()
@@ -282,7 +282,7 @@ def WriteDependencies(deps, result_file, realpath_map):
fd.write("\n".join([realpath_map.string[d] for d in deps]))
fd.write("\n")
fd.close()
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
raise NotCoveredError("Could not write to '%s': %s" % (result_file, why))
@@ -319,12 +319,12 @@ def VerifyExactDependencies(include_closure,
# A SOCKET SERVER
-class QueuingSocketServer(SocketServer.UnixStreamServer):
+class Queuingsocketserver(socketserver.UnixStreamServer):
"""A socket server whose request queue have size REQUEST_QUEUE_SIZE."""
request_queue_size = REQUEST_QUEUE_SIZE
def handle_error(self, _, client_address):
- """Re-raise current exception; overrides SocketServer.handle_error.
+ """Re-raise current exception; overrides socketserver.handle_error.
"""
raise
@@ -337,7 +337,7 @@ def DistccIncludeHandlerGenerator(include_analyzer):
# TODO(klarlund): Can we do this without dynamic type generation?
- class IncludeHandler(SocketServer.StreamRequestHandler):
+ class IncludeHandler(socketserver.StreamRequestHandler):
"""Define a handle() method that invokes the include closure algorithm ."""
def handle(self):
@@ -389,15 +389,14 @@ def DistccIncludeHandlerGenerator(include_analyzer):
# all circumstances.
include_analyzer.timer.Cancel()
- except NotCoveredError, inst:
+ except NotCoveredError as inst:
# Warn user. The 'Preprocessing locally' message is meant to
# assure the user that the build process is otherwise intact.
- fd = os.tmpfile()
- print >> fd, (
- "Preprocessing locally. Include server not covering: %s for "
+ fd = tempfile.TemporaryFile(mode='w+')
+ print(("Preprocessing locally. Include server not covering: %s for "
+ "translation unit '%s'") % (
(inst.args and inst.args[0] or "unknown reason",
- include_analyzer.translation_unit)),
+ include_analyzer.translation_unit)), file=fd, end=' ')
# We don't include a stack trace here.
include_analyzer.email_sender.MaybeSendEmail(fd,
never=not inst.send_email)
@@ -409,7 +408,7 @@ def DistccIncludeHandlerGenerator(include_analyzer):
Debug(DEBUG_TRACE,
"Clearing caches because of include server timeout.")
include_analyzer.ClearStatCaches()
-
+
except SignalSIGTERM:
# Normally, we will get this exception when the include server is no
# longer needed. But we also handle it here, during the servicing of a
@@ -419,32 +418,30 @@ def DistccIncludeHandlerGenerator(include_analyzer):
except KeyboardInterrupt:
# Propagate to the last-chance exception handler in Main.
raise
- except SystemExit, inst:
+ except SystemExit as inst:
# When handler tries to exit (by invoking sys.exit, which in turn raises
# SystemExit), something is really wrong. Terminate the include
# server. But, print out an informative message first.
- fd = os.tmpfile()
- print >> fd, (
- ("Preprocessing locally. Include server fatal error: '%s' for "
+ fd = tempfile.TemporaryFile(mode='w+')
+ print(("Preprocessing locally. Include server fatal error: '%s' for "
+ "translation unit '%s'") % (
- (inst.args, include_analyzer.translation_unit))),
+ (inst.args, include_analyzer.translation_unit)), file=fd, end=' ')
_PrintStackTrace(fd)
include_analyzer.email_sender.MaybeSendEmail(fd, force=True)
distcc_pump_c_extensions.XArgv(self.wfile.fileno(), [])
sys.exit("Now terminating include server.")
# All other exceptions are trapped here.
- except Exception, inst:
+ except Exception as inst:
# Internal error. Better be safe than sorry: terminate include
# server. But show error to user on stderr. We hope this message will be
# reported.
- fd = os.tmpfile()
- print >> fd, (
- ("Preprocessing locally. Include server internal error: '%s: %s' "
- + "for translation unit '%s'") % (
- (inst.__class__, inst.args, include_analyzer.translation_unit))),
+ fd = tempfile.TemporaryFile(mode='w+')
+ print(("Preprocessing locally. Include server internal error: '%s: %s'"
+ + " for translation unit '%s'") % (
+ (inst.__class__, inst.args, include_analyzer.translation_unit)), file=fd)
_PrintStackTrace(fd)
- # Force this email through (if basics.opt_send_email is True), because
- # this is the last one and this is an important case to report.
+ # # Force this email through (if basics.opt_send_email is True), because
+ # # this is the last one and this is an important case to report.
include_analyzer.email_sender.MaybeSendEmail(fd, force=True)
distcc_pump_c_extensions.XArgv(self.wfile.fileno(), [])
raise SignalSIGTERM # to be caught in Main with no further stack trace
@@ -468,7 +465,7 @@ def _ParseCommandLineOptions():
Returns:
(include_server_port, pid_file), where include_server_port
- is a string and pid_file is a string or None
+ is a string and pid_file is a string or None
Modifies:
option variables in module basics
"""
@@ -500,8 +497,8 @@ def _ParseCommandLineOptions():
for opt, arg in opts:
try:
if opt in ("-d", "--debug_pattern"):
- basics.opt_debug_pattern = int(arg)
- if opt in ("--port",):
+ basics.opt_debug_pattern = int(arg)
+ if opt in ("--port", ):
include_server_port = arg
if opt in ("--pid_file",):
pid_file = arg
@@ -541,9 +538,8 @@ def _ParseCommandLineOptions():
sys.exit(1)
# We must have a port!
if not include_server_port:
- print >> sys.stderr, "INCLUDE_SERVER_PORT not provided. Aborting."
- print >> sys.stderr, "-------------------------------------------"
- print >> sys.stderr
+ print("INCLUDE_SERVER_PORT not provided. Aborting.", file=sys.stderr)
+ print("-------------------------------------------", "\n", file=sys.stderr)
Usage()
sys.exit(1)
return (include_server_port, pid_file)
@@ -561,10 +557,9 @@ def _PrintTimes(times_at_start, times_at_fork, times_child):
+ times_child[1] + times_child[1])
total_cpu = total_u + total_s
total_e = times_child[4] - times_at_start[4]
- print >> sys.stderr, "Include server timing. ",
- print >> sys.stderr, (
- "Elapsed: %3.1fs User: %3.1fs System: %3.1fs User + System: %3.1fs" %
- (total_e, total_u, total_s, total_cpu))
+ print("Include server timing. ", sys.stderr)
+ print("Elapsed: %3.1fs User: %3.1fs System: %3.1fs User + System: %3.1fs" %
+ (total_e, total_u, total_s, total_cpu), file=sys.stderr)
class _IncludeServerPortReady(object):
@@ -581,12 +576,12 @@ class _IncludeServerPortReady(object):
def Acquire(self):
"""Acquire the semaphore after fork; blocks until a call of Release."""
- if os.read(self.read_fd, 1) != '\n':
+ if os.read(self.read_fd, 1) != b'\n':
sys.exit("Include server: _IncludeServerPortReady.Acquire failed.")
def Release(self):
"""Release the semaphore after fork."""
- if os.write(self.write_fd, '\n') != 1:
+ if os.write(self.write_fd, b'\n') != 1:
sys.exit("Include server: _IncludeServerPortReady.Release failed.")
@@ -594,7 +589,7 @@ def _SetUp(include_server_port):
"""Setup include_analyzer and socket server.
Returns: (include_analyzer, server)"""
-
+
try:
os.unlink(include_server_port)
except (IOError, OSError):
@@ -615,9 +610,9 @@ def _SetUp(include_server_port):
client_root_keeper,
basics.opt_stat_reset_triggers))
include_analyzer.email_sender = _EmailSender()
-
+
# Wrap it inside a handler that is a part of a UnixStreamServer.
- server = QueuingSocketServer(
+ server = Queuingsocketserver(
include_server_port,
# Now, produce a StreamRequestHandler subclass whose new objects has
# a handler which calls the include_analyzer just made.
@@ -647,12 +642,12 @@ def Main():
# the process id of child to the pid file.
times_at_fork = os.times()
pid = os.fork()
- if pid != 0:
+ if pid != 0:
# In parent.
#
if pid_file:
pid_file_fd = open(pid_file, "w")
- print >> pid_file_fd, pid
+ print(pid, file=pid_file_fd)
pid_file_fd.close()
# Just run to completion now -- after making sure that child is ready.
include_server_port_ready.Acquire()
@@ -673,15 +668,15 @@ def Main():
# gc.set_debug(gc.DEBUG_STATS + gc.DEBUG_COLLECTABLE)
server.serve_forever()
except KeyboardInterrupt:
- print >> sys.stderr, (
- "Include server: keyboard interrupt, quitting after cleaning up.")
+ print("Include server: keyboard interrupt, quitting after cleaning up.",
+ file=sys.stderr)
_CleanOut(include_analyzer, include_server_port)
except SignalSIGTERM:
Debug(DEBUG_TRACE, "Include server shutting down.")
_CleanOut(include_analyzer, include_server_port)
except:
- print >> sys.stderr, (
- "Include server: exception occurred, quitting after cleaning up.")
+ print("Include server: exception occurred, quitting after cleaning up.",
+ file=sys.stderr)
_PrintStackTrace(sys.stderr)
_CleanOut(include_analyzer, include_server_port)
raise # reraise exception
@@ -689,8 +684,8 @@ def Main():
if basics.opt_print_times:
_PrintTimes(times_at_start, times_at_fork, os.times())
-
+
if __name__ == "__main__":
- # Treat SIGTERM (the default of kill) as Ctrl-C.
+ # Treat SIGTERM (the default of kill) as Ctrl-C.
signal.signal(signal.SIGTERM, basics.RaiseSignalSIGTERM)
Main()
diff --git a/include_server/include_server_test.py b/include_server/include_server_test.py
index c1f4a8e..c0b88e3 100755
--- a/include_server/include_server_test.py
+++ b/include_server/include_server_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""Exercise include server handler with respect to exceptions and email.
To do this, we mock out socket servers, c_extensions, email handling, and even
@@ -69,7 +69,7 @@ class IncludeServerTest(unittest.TestCase):
old_XArgv = distcc_pump_c_extensions.XArgv
distcc_pump_c_extensions.XArgv = lambda _, __: None
old_StreamRequestHandler = (
- include_server.SocketServer.StreamRequestHandler)
+ include_server.socketserver.StreamRequestHandler)
class Mock_StreamRequestHandler(object):
def __init__(self):
@@ -78,7 +78,7 @@ class IncludeServerTest(unittest.TestCase):
self.wfile = lambda: None
self.wfile.fileno = lambda: 27
- include_server.SocketServer.StreamRequestHandler = (
+ include_server.socketserver.StreamRequestHandler = (
Mock_StreamRequestHandler)
include_analyzer = (
@@ -111,7 +111,7 @@ class IncludeServerTest(unittest.TestCase):
distcc_pump_c_extensions.RCwd = lambda self: os.getcwd()
def Expect1(txt, force, never):
- self_test.assert_(
+ self_test.assertTrue(
"Include server not covering: " +
"Could not find translation unit 'parse.c'" in txt, txt)
self_test.assertEqual(never, True)
@@ -124,6 +124,7 @@ class IncludeServerTest(unittest.TestCase):
else:
raise AssertionError
+
# Exercise 2: provoke assertion error in cache_basics by providing an
# entirely false value of current directory as provided in RCwd.
@@ -136,18 +137,17 @@ class IncludeServerTest(unittest.TestCase):
# mock out, in a sense, the provoked assertion exception that we
# expect. The variable got_here allows us to filter the provoked exception
# away from unexpected ones.
- got_here = []
+ got_here = []
def Expect2(txt, force, never):
- self_test.assert_("Include server internal error" in txt, txt)
- self_test.assert_("exceptions.AssertionError" in txt, txt)
- self_test.assert_("for translation unit 'parse.c'" in txt, txt)
+ got_here.append(True)
+ self_test.assertTrue("Include server internal error" in txt, txt)
+ self_test.assertTrue("exceptions.AssertionError" in txt, txt)
+ self_test.assertTrue("for translation unit 'parse.c'" in txt, txt)
# This email should be sent.
self_test.assertEqual(never, False)
- got_here.append(True)
-
mock_email_sender.expect = Expect2
try:
include_handler.handle()
@@ -155,7 +155,7 @@ class IncludeServerTest(unittest.TestCase):
os.chdir(oldcwd)
# Make sure that we're catching the induced AssertionError, not one
# produced in Except2.
- self.assert_(got_here)
+ self.assertTrue(got_here)
else:
raise AssertionError
@@ -166,7 +166,7 @@ class IncludeServerTest(unittest.TestCase):
distcc_pump_c_extensions.RCwd = lambda self: os.getcwd()
def Expect3(txt, force, never):
- self_test.assert_(
+ self_test.assertTrue(
"Filepath must be relative but isn't: '/love/of/my/life'."
in txt, txt)
# Now check that this email is scheduled to not be sent.
@@ -181,7 +181,7 @@ class IncludeServerTest(unittest.TestCase):
distcc_pump_c_extensions.RWcd = old_RWcd
distcc_pump_c_extensions.RArgv = old_RArgv
distcc_pump_c_extensions.XArgv = old_XArgv
- include_server.SocketServer.StreamRequestHandler = (
+ include_server.socketserver.StreamRequestHandler = (
old_StreamRequestHandler)
unittest.main()
diff --git a/include_server/macro_eval.py b/include_server/macro_eval.py
index 49dce53..134a54e 100755
--- a/include_server/macro_eval.py
+++ b/include_server/macro_eval.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""Evaluation of macros acccording to an overapproximation semantics.
This module generally follows CPP semantics for the evalution of macros. But we
@@ -114,7 +114,7 @@ of dcc_build_somewhere, will then perform a local compilation.
Symbol Table
------------
-The symbol table is a dictionary, whose entries are of the form
+The symbol table is a dictionary, whose entries are of the form
symbol: definition_list
@@ -188,7 +188,7 @@ def _ParseArgs(string, pos):
return (None, pos)
# Prepare a list of comma and extremal positions. The '(' at the left is the
# first extremal position.
- commas = [pos]
+ commas = [pos]
pos_end = None
inside_quotes = False
for i in range(pos, len(string)):
@@ -241,7 +241,7 @@ def _EvalExprHelper(expr, symbol_table, disabled):
Returns: [ expr_1, expr_2, ...], which is a non-empy list of
strings, namely the expansions of expr.
- """
+ """
def _ReEvalRecursivelyForExpansion(expansion, after):
"""Reevalute the expansion that is the result of finding a match for a
@@ -255,7 +255,7 @@ def _EvalExprHelper(expr, symbol_table, disabled):
after: the string after the expansion
Modifies:
value_set: the set of all possible expansions of expr
-
+
The value set is updated according to recursive evaluations of the string
that results from inserting expansion between expr[:match.start()] and
expr[match.end():] (for symbol-like macro) or expr[args_end:] (for
@@ -325,7 +325,7 @@ def _EvalExprHelper(expr, symbol_table, disabled):
_ReEvalRecursivelyForExpansion(real_expansion, expr[args_end:])
else:
assert False, "Definition '%s' is unexpected." % definition
-
+
# Look for a symbol.
match = SYMBOL_RE.search(expr)
if not match:
@@ -408,8 +408,8 @@ def ResolveExpr(includepath_map_index,
Returns:
a pair(files, symbols), where files is a list of (filepath pair,
realpath index), namely those files that are successful resolutions of
- possible double-quoted and angle-quoted values of expr, and symbols is
- the set of all identifiers occurring in expression or its possible
+ possible double-quoted and angle-quoted values of expr, and symbols is
+ the set of all identifiers occurring in expression or its possible
expansions
Raises:
NotCoveredError
@@ -424,13 +424,11 @@ def ResolveExpr(includepath_map_index,
match_result = parse_file.INCLUDE_STRING_RE.match(val)
if match_result:
if match_result.group('quote'):
- resolved = resolve(includepath_map_index(match_result.group('quote')),
- currdir_idx, searchdir_idx, quote_dirs)
- resolved_files.append(resolved)
+ resolved = resolve(includepath_map_index(match_result.group('quote')),currdir_idx, searchdir_idx, quote_dirs)
+ resolved_files.append(resolved)
elif match_result.group('angle'):
- resolved = resolve(includepath_map_index(match_result.group('angle')),
- currdir_idx, None, angle_dirs)
- resolved_files.append(resolved)
+ resolved = resolve(includepath_map_index(match_result.group('angle')), currdir_idx, None, angle_dirs)
+ resolved_files.append(resolved)
else:
symbols.extend(SYMBOL_RE.findall(val))
if __debug__:
diff --git a/include_server/macro_eval_test.py b/include_server/macro_eval_test.py
index 292cf35..8bc11dc 100755
--- a/include_server/macro_eval_test.py
+++ b/include_server/macro_eval_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
__author__ = "Nils Klarlund"
# See also tests in include_server_test.py.
@@ -140,8 +140,8 @@ class MacroEvalTest(unittest.TestCase):
macro_eval.EvalExpression("myfile(hello)",
{ 'myfile': [(['x'], "myquote(myplace/x)")],
'myquote': [(['y'], """#y""")] }),
- set(['myfile(hello)',
- '"myplace/hello"',
+ set(['myfile(hello)',
+ '"myplace/hello"',
'myquote(myplace/hello)']))
@@ -166,7 +166,7 @@ class MacroEvalTest(unittest.TestCase):
# #define PLUS +
# #define EMPTY
# #define f(x) =x=
- #
+ #
# +PLUS -EMPTY- PLUS+ f(=)
# ==> + + - - + + = = =
#
@@ -177,7 +177,7 @@ class MacroEvalTest(unittest.TestCase):
{ 'PLUS':['+'],
'EMPTY':[""],
'f':[(['x'], '=x=')] }),
- set(['++ -EMPTY- ++ ===',
+ set(['++ -EMPTY- ++ ===',
'++ -EMPTY- PLUS+ ===',
'+PLUS -- ++ f(=)',
'+PLUS -EMPTY- ++ ===',
@@ -233,5 +233,5 @@ class MacroEvalTest(unittest.TestCase):
'AS_STRING', 'AS_STRING_INTERNAL',
'tpl', 'varnames', 'h', 'foo']))
-
+
unittest.main()
diff --git a/include_server/mirror_path.py b/include_server/mirror_path.py
index dcf83eb..f51a62b 100755
--- a/include_server/mirror_path.py
+++ b/include_server/mirror_path.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
# Copyright 2007 Google Inc.
#
diff --git a/include_server/mirror_path_test.py b/include_server/mirror_path_test.py
index 91ae819..9001de1 100755
--- a/include_server/mirror_path_test.py
+++ b/include_server/mirror_path_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
__author__ = "Nils Klarlund"
import os
@@ -108,7 +108,7 @@ class MirrorPathTest(unittest.TestCase):
# Mirror the link /a/link.
self.mirror_path.DoPath('/a/link', 117, '/root')
self.assertEqual(self.mirror_path.Links(), ['/root/a/link'])
- self.assert_(self.simple_build_stat.Lookup('/root/a'))
+ self.assertTrue(self.simple_build_stat.Lookup('/root/a'))
# Check that symlink function is not called again, by verifying
# that mirror_path.Links() doesn't grow.
diff --git a/include_server/parse_command.py b/include_server/parse_command.py
index 718affd..cd02d01 100755
--- a/include_server/parse_command.py
+++ b/include_server/parse_command.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-
+
"""Parsing of C and C++ commands and extraction of search paths."""
__author__ = "opensource@google.com (Craig Silverstein, Nils Klarlund)"
@@ -24,6 +24,7 @@ __author__ = "opensource@google.com (Craig Silverstein, Nils Klarlund)"
import re
import os
import sys
+import glob
import basics
import cache_basics
@@ -99,6 +100,7 @@ CPP_OPTIONS_MAYBE_TWO_WORDS = {
'-MT': lambda ps, arg: None,
'-MQ': lambda ps, arg: None,
'-arch': lambda ps, arg: None,
+ '-target': lambda ps, arg: None,
'-include': lambda ps, arg: ps.include_files.append(arg),
'-imacros': lambda ps, arg: ps.include_files.append(arg),
'-idirafter': lambda ps, arg: ps.after_system_dirs.append(arg),
@@ -112,7 +114,7 @@ CPP_OPTIONS_MAYBE_TWO_WORDS = {
'-isystem': lambda ps, arg: ps.before_system_dirs.append(arg),
'-iquote': lambda ps, arg: ps.quote_dirs.append(arg),
}
-CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS = ('M', 'i', '-', 'a')
+CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS = ('M', 'i', '-', 'a', 't')
# A "compile-time" check to make sure the first-letter list is up-to-date
for key in CPP_OPTIONS_MAYBE_TWO_WORDS.keys():
assert key[1] in CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS
@@ -179,6 +181,7 @@ CPP_OPTIONS_ONE_LETTER = {
# preprocessor-related, they are all noops.
'A': lambda ps, arg: None,
'l': lambda ps, arg: None,
+ 'F': lambda ps, arg: ps.i_dirs.extend(glob.glob(os.path.join(arg,'*', 'Headers'))),
'u': lambda ps, arg: None,
'L': lambda ps, arg: None,
'B': lambda ps, arg: None,
@@ -222,7 +225,7 @@ def ParseCommandLineSlowly(line):
if m_unesc_q:
unesc_q = m_unesc_q.end() - 1
else:
- unesc_q = sys.maxint
+ unesc_q = sys.maxsize
m_nonspc = NONSPACE_RE.search(line, 0)
if not m_nonspc:
return args
@@ -232,10 +235,10 @@ def ParseCommandLineSlowly(line):
# Invariant: (1) start is at the beginning of the next argument
# (perhaps at a quote, which will later be removed). (2) end is
# such that line[start:end] is a prefix of the argument.
- assert start <= unesc_q
+ assert start <= unesc_q
assert start < end <= len(line), (start, end, len(line))
assert not SPACE_RE.match(line, start)
- assert unesc_q == sys.maxint or line[unesc_q] == '"'
+ assert unesc_q == sys.maxsize or line[unesc_q] == '"'
try:
end = SPACE_RE.search(line, end).start()
except AttributeError:
@@ -262,7 +265,7 @@ def ParseCommandLineSlowly(line):
m_unesc_q = NONESC_QUOTE_RE.search(line, unesc_q + 1)
if not m_unesc_q:
raise NotCoveredError("""Missing '"', could not parse command line.""")
- assert m_unesc_q.end() - 1 > unesc_q
+ assert m_unesc_q.end() - 1 > unesc_q
end = m_unesc_q.end()
if end == len(line):
args.append(ESC_QUOTE_RE.sub(
@@ -277,7 +280,7 @@ def ParseCommandLineSlowly(line):
if m_unesc_q:
unesc_q = m_unesc_q.end() - 1
else:
- unesc_q = sys.maxint
+ unesc_q = sys.maxsize
def ParseCommandLine(line):
@@ -344,7 +347,7 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
compiler = args[0]
- i = 1
+ i = 1
while i < len(args):
# First, deal with everything that's not a flag-option
if args[i][0] != '-' or args[i] == '-': # - is the stdin file
@@ -417,7 +420,7 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
i += 1
continue
# Done parsing arguments!
-
+
# Sanity-checking on arguments
# -I- is a special form of the -I command.
if "-" in parse_state.i_dirs:
@@ -429,7 +432,7 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
send_email=False)
source_file = parse_state.file_names[0]
-
+
if parse_state.output_file:
# Use output_file to create prefix
source_file_prefix = re.sub("[.]o$", "", parse_state.output_file)
@@ -484,9 +487,9 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
ignore_absolute_path_warning=True)
for f in parse_state.include_files])
- if __debug__: Debug(DEBUG_TRACE, ("ParseCommand result: %s %s %s %s %s %s" %
+ if __debug__: Debug(DEBUG_TRACE, ("ParseCommand result: %s %s %s %s %s %s" %
(quote_dirs, angle_dirs, include_files,
source_file, source_file_prefix,
parse_state.Dopts)))
- return (quote_dirs, angle_dirs, include_files, source_file, source_file_prefix,
+ return (quote_dirs, angle_dirs, include_files, source_file, source_file_prefix,
parse_state.Dopts)
diff --git a/include_server/parse_command_test.py b/include_server/parse_command_test.py
index b7ef4e6..91a5b3a 100755
--- a/include_server/parse_command_test.py
+++ b/include_server/parse_command_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -55,11 +55,11 @@ class ParseCommandUnitTest(unittest.TestCase):
def Mock_SetSystemDirsDefaults(compiler, sysroot, language, timer=None):
if compiler != mock_compiler:
- raise Exception, "compiler: %s, mock_compiler: %s" % (
- compiler, mock_compiler)
+ raise Exception("compiler: %s, mock_compiler: %s" % (
+ compiler, mock_compiler))
if sysroot != mock_sysroot:
- raise Exception, "sysroot: %s, mock_sysroot: %s" % (
- sysroot, mock_sysroot)
+ raise Exception("sysroot: %s, mock_sysroot: %s" % (
+ sysroot, mock_sysroot))
self.compiler_defaults = lambda x: x
self.compiler_defaults.SetSystemDirsDefaults = Mock_SetSystemDirsDefaults
@@ -141,7 +141,7 @@ class ParseCommandUnitTest(unittest.TestCase):
self.assertEqual(
(self._RetrieveDirectoriesExceptSys(quote_dirs),
- self._RetrieveDirectoriesExceptSys(angle_dirs),
+ self._RetrieveDirectoriesExceptSys(angle_dirs),
[self.includepath_map.String(i) for i in include_files],
filepath),
(('/and', 'mice', '/men', 'system'),
@@ -178,8 +178,8 @@ class ParseCommandUnitTest(unittest.TestCase):
self.directory_map,
self.compiler_defaults))
self.assertEqual(
- (self._RetrieveDirectoriesExceptSys(quote_dirs),
- self._RetrieveDirectoriesExceptSys(angle_dirs),
+ (self._RetrieveDirectoriesExceptSys(quote_dirs),
+ self._RetrieveDirectoriesExceptSys(angle_dirs),
filepath),
(('',
'obj/gcc-4.1.0-glibc-2.2.2-piii-linux-g0-dbg/genfiles/third_party/libxml/third_party/libxml',
diff --git a/include_server/parse_file.py b/include_server/parse_file.py
index ac9720f..5df853f 100755
--- a/include_server/parse_file.py
+++ b/include_server/parse_file.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -70,9 +70,9 @@ NOT_COMMA_OR_PARENS = "([^(),])"
# symbol (something, ..., something), where something is not ',', '(', or ')'
MACRO_EXPR = r"""
(?P<symbol>\w+) # the symbol, named 'symbol'
- ( \s*
+ ( \s*
[(] \s* # beginning parenthesis
- (?P<args> # a parenthesized expression (with no
+ (?P<args> # a parenthesized expression (with no
# containing expressions -- a limitation)
# named 'args'
%(NOT_COMMA_OR_PARENS)s* # the first argument (if it exists)
@@ -184,19 +184,19 @@ class ParseFile(object):
of symbol is parsed. The callback allows an include processor to adjust
its notion of which expressions are still current. If we (the include
processor) already met
-
+
#define A B
-
+
and later meet
-
+
#define B
-
+
whether this is the first definition of B or not, then the possible
meanings of A have changed. We set up a callback to identify such
situations."""
self.define_callback = callback_function
-
+
def _ParseFine(self, poundsign_match, includepath_map_index, file_contents,
symbol_table, quote_includes, angle_includes, expr_includes,
next_includes):
@@ -246,7 +246,7 @@ class ParseFile(object):
lhs = m.group('lhs')
rhs = groupdict['rhs'] and groupdict['rhs'] or None
InsertMacroDefInTable(lhs, rhs, symbol_table, self.define_callback)
- except NotCoveredError, inst:
+ except NotCoveredError as inst:
# Decorate this exception with the filename, by recreating it
# appropriately.
if not inst.source_file:
@@ -279,7 +279,7 @@ class ParseFile(object):
try:
fd = open(filepath, "r")
- except IOError, msg:
+ except IOError as msg:
# This normally does not happen because the file should be known to
# exists. Still there might be, say, a permissions issue that prevents it
# from being read.
@@ -331,7 +331,7 @@ class ParseFile(object):
poundsign_match = POUND_SIGN_RE.match(file_contents, line_start)
if not poundsign_match:
- continue
+ continue
self._ParseFine(poundsign_match, includepath_map_index, file_contents,
symbol_table, quote_includes, angle_includes,
diff --git a/include_server/parse_file_test.py b/include_server/parse_file_test.py
index 660df0e..bf2d691 100755
--- a/include_server/parse_file_test.py
+++ b/include_server/parse_file_test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -67,15 +67,15 @@ class parse_file_Test(unittest.TestCase):
self.assertEqual(parse_file.MACRO_EXPR_RE.match("random()").group('symbol'),
"random")
- self.assert_(parse_file.DIRECTIVE_RE.match(
+ self.assertTrue(parse_file.DIRECTIVE_RE.match(
""" # include <a.c>""").group('angle') == 'a.c')
- self.assert_(parse_file.DIRECTIVE_RE.match(
+ self.assertTrue(parse_file.DIRECTIVE_RE.match(
""" # include mac(a.c, mic)""").group('expr') == 'mac(a.c, mic)')
- self.assert_(parse_file.DIRECTIVE_RE.match(
+ self.assertTrue(parse_file.DIRECTIVE_RE.match(
""" # include "a.c" """).group('quote') == 'a.c')
- self.assert_(parse_file.DIRECTIVE_RE.match(
+ self.assertTrue(parse_file.DIRECTIVE_RE.match(
""" #include "a.c" """).group('quote') == 'a.c')
- self.assert_(parse_file.DIRECTIVE_RE.match(
+ self.assertTrue(parse_file.DIRECTIVE_RE.match(
""" #include"a.c" """).group('quote') == 'a.c')
self.assertEqual(parse_file.DIRECTIVE_RE.match(
@@ -133,9 +133,11 @@ b
self.assertEqual(parse_file_obj.Parse(
"test_data/more_macros.c", symbol_table),
([], [], ['TEMPLATE_VARNAME(foo)'], []))
- self.assertEqual(symbol_table.keys(),
- ['ILLFORMED', 'AS_STRING_INTERNAL',
- 'TEMPLATE_VARNAME', 'AS_STRING'])
+ symbol_table_keys = list(symbol_table.keys())
+ symbol_table_keys.sort()
+ self.assertEqual(symbol_table_keys,
+ ['AS_STRING', 'AS_STRING_INTERNAL',
+ 'ILLFORMED', 'TEMPLATE_VARNAME'])
[([arg], val)] = symbol_table['TEMPLATE_VARNAME']
self.assertEqual(arg, '_filename_')
self.assertEqual(val, 'AS_STRING(maps/_filename_.tpl.varnames.h)')
diff --git a/include_server/run.py b/include_server/run.py
index 5580d68..d2cacca 100755
--- a/include_server/run.py
+++ b/include_server/run.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -48,20 +48,20 @@ Examples:
From anywhere:
# Start include server.
/home/distcc/include_server/run.py include_server.py
-
+
In the include_server directory:
# Run include_server tests.
./run.py include_server_test.py
# Pycheck include_server.
- ./run.py `which pychecker` include_server.py
+ ./run.py `which pychecker` include_server.py
In installed distcc-pump:
# See 'pump' script.
- $include_server_location/run.py --run_in_install include_server.py ..
+ $include_server_location/run.py --run_in_install include_server.py ..
"""
def usage():
- print USAGE
+ print(USAGE)
sys.exit(1)
DEFAULT_PATH = "c_extensions/build/lib.*/*"
@@ -91,7 +91,7 @@ else:
sys.exit("More than one extension module found. "
+ " Cannot determine which one to use.")
lib_directory = os.path.dirname(potential_libs[0])
- print "__________Using Python extension in %s" % lib_directory
+ print("__________Using Python extension in %s" % lib_directory)
# Now, the all important change to PYTHONPATH. Note that we obliterate any
# environmental setting setting as well. This improves performance in
@@ -101,7 +101,6 @@ os.environ['PYTHONPATH'] = lib_directory
try:
os.execv(os.path.join(directory, sys.argv[1]), sys.argv[1:])
except OSError:
- print >> sys.stderr, (
- "Could not run: '%s' with arguments: %s" %
+ print("Could not run: '%s' with arguments: %s" %
(os.path.join(directory, sys.argv[1]),
- sys.argv[1:]))
+ sys.argv[1:]), file=sys.stderr)
diff --git a/include_server/setup.py b/include_server/setup.py
index 03085b0..1cbc9f6 100755
--- a/include_server/setup.py
+++ b/include_server/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -58,7 +58,7 @@ def GetIncludes(flags):
In the doctests below, note that a single quoted backslash takes four
backslashes to represent if it is inside a single quoted string inside this
present triple-quoted string.
-
+
>>> GetIncludes('-I x -X -I"y" -Y')
['x', 'y']
>>> GetIncludes('-Ix -Dfoo -Iy')
@@ -103,7 +103,7 @@ cpp_flags_env = os.getenv('CPPFLAGS', '')
if not cpp_flags_env:
# Don't quit; perhaps the user is asking for help using '--help'.
# CPPFLAGS checking.
- print >> sys.stderr, 'setup.py: CPPFLAGS must be defined.'
+ print('setup.py: CPPFLAGS must be defined.', sys.stderr)
# CPPFLAGS is passed to us as it's used in the Makefile: a string that the shell
# will interpret. GetInclude uses shlex to do the same kind of interpretation
# in order to identify the include directory options.
@@ -112,7 +112,7 @@ cpp_flags_includes = GetIncludes(cpp_flags_env)
# SRCDIR checking.
if not os.getenv('SRCDIR'):
# Don't quit; perhaps the user is asking for help using '--help'.
- print >> sys.stderr, 'setup.py: SRCDIR must be defined.'
+ print('setup.py: SRCDIR must be defined.', sys.stderr)
srcdir = 'UNDEFINED'
srcdir_include_server = 'UNDEFINED'
else:
diff --git a/include_server/statistics.py b/include_server/statistics.py
index 6aae5d5..9677af3 100755
--- a/include_server/statistics.py
+++ b/include_server/statistics.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
#
# Copyright 2007 Google Inc.
#
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-#
+#
"""Statistics gathering for the distcc-pump include server."""
__author__ = "Nils Klarlund"
@@ -38,14 +38,14 @@ min_time = float('Inf')
max_time = 0.0
total_time = 0.0
-parse_file_total_time = 0.0
+parse_file_total_time = 0.0
parse_file_counter = 0 # number of files parsed
parse_file_counter_last = 0 # the number of files parsed after previous
# translation unit
quote_path_total = 0 # total length of quote directory lists
-angle_path_total = 0 # total length of angle directory lists
+angle_path_total = 0 # total length of angle directory lists
len_calculated_closure = 0 # number of all included files
len_calculated_closure_nonsys = 0 # same, but excluding system files
@@ -54,7 +54,7 @@ len_exact_closure = 0 # number of all files in CPP-calculated closure
len_surplus_nonsys = 0 # the difference between
# len_calculated_closure and number of files
# in exact closure that are not known to compiler
-
+
find_node_counter = 0 # number of times FindNode is called
@@ -78,45 +78,45 @@ def PrintStatistics(include_analyzer):
# Avoid division by zero in non-interesting case.
if translation_unit_counter == 0: return
- print "TRANSLATION_UNIT: %s" % include_analyzer.translation_unit
+ print("TRANSLATION_UNIT: %s" % include_analyzer.translation_unit)
print (("TIME: last %-2.3fs, min %-2.3fs, "
- "max %-2.3fs, average %-2.3fs, #: %5d, total: %5.1fs") %
+ "max %-2.3fs, average %-2.3fs, #: %5d, total: %5.1fs") %
(translation_unit_time, min_time, max_time,
total_time/translation_unit_counter,
translation_unit_counter, total_time))
print ("PARSING: total %-5.3fs, total count: %4d, new files: %-5d" %
- (parse_file_total_time, parse_file_counter,
+ (parse_file_total_time, parse_file_counter,
parse_file_counter - parse_file_counter_last))
- print "COUNTER: resolve_expr_counter: %8d" % resolve_expr_counter
- print "COUNTER: master_hit_counter: %8d" % master_hit_counter
- print "COUNTER: master_miss_counter: %8d" % master_miss_counter
- print "SIZE: master_cache %8d" % (
- len(include_analyzer.master_cache))
- print "COUNTER: sys_stat_counter: %10d" % sys_stat_counter
- print "COUNTER: build_stat_counter: %10d" % build_stat_counter
+ print("COUNTER: resolve_expr_counter: %8d" % resolve_expr_counter)
+ print("COUNTER: master_hit_counter: %8d" % master_hit_counter)
+ print("COUNTER: master_miss_counter: %8d" % master_miss_counter)
+ print("SIZE: master_cache %8d" % (
+ len(include_analyzer.master_cache)))
+ print("COUNTER: sys_stat_counter: %10d" % sys_stat_counter)
+ print("COUNTER: build_stat_counter: %10d" % build_stat_counter)
if resolve_counter != 0:
- print "COUNTER: search_counter (average): %4.1f" % (
- float(search_counter)/resolve_counter)
- print "SIZE: include_dir_pairs: %8d" % (
- len(include_analyzer.include_dir_pairs))
+ print("COUNTER: search_counter (average): %4.1f" % (
+ float(search_counter)/resolve_counter))
+ print("SIZE: include_dir_pairs: %8d" % (
+ len(include_analyzer.include_dir_pairs)))
if 'quote_dirs' in include_analyzer.__dict__:
- print "SIZE: quote_path %8d" % (
- len(include_analyzer.quote_dirs))
+ print("SIZE: quote_path %8d" % (
+ len(include_analyzer.quote_dirs)))
if 'angle_dirs' in include_analyzer.__dict__:
- print "SIZE: angle_path %8d" % (
- len(include_analyzer.angle_dirs))
- print "SIZE: quote_path (average) %4.1f" % (
- float(quote_path_total)/translation_unit_counter)
- print "SIZE: angle_path (average) %4.1f" % (
- float(angle_path_total)/translation_unit_counter)
- print "SIZE: quote_dirs_set %8d" % (
- len(include_analyzer.quote_dirs_set))
- print "SIZE: angle_dirs_set: %8d" % (
- len(include_analyzer.angle_dirs_set))
- print
- print "SIZE: calculated_closure: %8d" % len_calculated_closure
- print "SIZE: calculated_closure_nonsys: %8d" % (
- len_calculated_closure_nonsys)
- print "SIZE: exact_closure %8d" % len_exact_closure
- print "SIZE: surplus_nonsys %8d" % len_surplus_nonsys
- print
+ print("SIZE: angle_path %8d" % (
+ len(include_analyzer.angle_dirs)))
+ print("SIZE: quote_path (average) %4.1f" % (
+ float(quote_path_total)/translation_unit_counter))
+ print("SIZE: angle_path (average) %4.1f" % (
+ float(angle_path_total)/translation_unit_counter))
+ print("SIZE: quote_dirs_set %8d" % (
+ len(include_analyzer.quote_dirs_set)))
+ print("SIZE: angle_dirs_set: %8d" % (
+ len(include_analyzer.angle_dirs_set)))
+ print()
+ print("SIZE: calculated_closure: %8d" % len_calculated_closure)
+ print("SIZE: calculated_closure_nonsys: %8d" % (
+ len_calculated_closure_nonsys))
+ print("SIZE: exact_closure %8d" % len_exact_closure)
+ print("SIZE: surplus_nonsys %8d" % len_surplus_nonsys)
+ print()
diff --git a/man/distccd.1 b/man/distccd.1
index f8452e1..41596d8 100644
--- a/man/distccd.1
+++ b/man/distccd.1
@@ -215,6 +215,8 @@ DNS Service Discovery (DNS-SD). This allows distcc clients on the local
network to access this distccd server without explicitly listing its host
name or IP address in their distcc host list: the distcc clients can
just use "+zeroconf" in their distcc host lists.
+Can optionally use -j parameter to specify the maximum number of jobs
+that this server can process concurrently.
.B This option is only available if distccd was compiled with
.B Avahi support enabled.
.TP
diff --git a/packaging/RedHat/conf/clients.allow b/packaging/RedHat/conf/clients.allow
index 61cedff..4591c2f 100644
--- a/packaging/RedHat/conf/clients.allow
+++ b/packaging/RedHat/conf/clients.allow
@@ -21,5 +21,9 @@
# (apart from comments) and thus only allow SSH mode rather than TCP mode.
# However, be aware that SSH mode has poorer performance than TCP mode.
+# For RedHat-like distributions using systemd, you should instead look in:
+# /etc/sysconfig/distccd in order to configure the trusted hosts list
+# See: https://bugzilla.redhat.com/show_bug.cgi?id=1187517
+
# Add your trusted hosts here, e.g. start by uncommented the line below.
# 127.0.0.1
diff --git a/src/access.c b/src/access.c
index c305366..55b7b8a 100644
--- a/src/access.c
+++ b/src/access.c
@@ -52,7 +52,9 @@
*/
static const uint32_t allones = 0xffffffffUL;
+#ifdef ENABLE_RFC2553
static const uint8_t allones8 = 0xffU;
+#endif
/**
* Split a "HOST/BITS" mask specification into HOST and BITS.
diff --git a/src/arg.c b/src/arg.c
index 0e7644e..cd82bf0 100644
--- a/src/arg.c
+++ b/src/arg.c
@@ -212,8 +212,15 @@ int dcc_scan_args(char *argv[], char **input_file, char **output_file,
} else if (!strcmp(a, "-frepo")) {
rs_log_info("compiler will emit .rpo files; must be local");
return EXIT_DISTCC_FAILED;
- } else if (str_startswith("-x", a)) {
- rs_log_info("gcc's -x handling is complex; running locally");
+ } else if (str_startswith("-x", a)
+ && argv[i+1]
+ && !str_startswith("c", argv[i+1])
+ && !str_startswith("c++", argv[i+1])
+ && !str_startswith("objective-c", argv[i+1])
+ && !str_startswith("objective-c++", argv[i+1])
+ && !str_startswith("go", argv[i+1])
+ ) {
+ rs_log_info("gcc's -x handling is complex; running locally for %s", argv[i+1] ? argv[i+1] : "empty");
return EXIT_DISTCC_FAILED;
} else if (str_startswith("-dr", a)) {
rs_log_info("gcc's debug option %s may write extra files; "
diff --git a/src/auth_common.c b/src/auth_common.c
index 471691b..d4f28a6 100644
--- a/src/auth_common.c
+++ b/src/auth_common.c
@@ -64,6 +64,9 @@ void dcc_gssapi_status_to_log(OM_uint32 status_code, int status_type) {
gss_release_buffer(&minor_status, &status_string);
} while (message_ctx != 0);
+
+ (void) major_status;
+ (void) minor_status;
}
/*
@@ -100,6 +103,9 @@ void dcc_gssapi_cleanup(gss_buffer_desc *input_tok,
rs_log_error("Failed to release name.");
}
}
+
+ (void) major_status;
+ (void) minor_status;
}
/*
diff --git a/src/auth_distcc.c b/src/auth_distcc.c
index 4e3947c..42196f8 100644
--- a/src/auth_distcc.c
+++ b/src/auth_distcc.c
@@ -128,7 +128,7 @@ static int dcc_gssapi_establish_secure_context(int to_net_sd,
addr_len = sizeof(addr);
- if ((ret = getpeername(to_net_sd, &addr, &addr_len)) != 0) {
+ if ((ret = getpeername(to_net_sd, (struct sockaddr *)&addr, &addr_len)) != 0) {
rs_log_error("Failed to look up peer address using socket \"%d\": %s.",
to_net_sd,
hstrerror(h_errno));
diff --git a/src/clinet.c b/src/clinet.c
index 010a884..5658fa7 100644
--- a/src/clinet.c
+++ b/src/clinet.c
@@ -35,9 +35,9 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
+#include <poll.h>
#include <signal.h>
-#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/src/dparent.c b/src/dparent.c
index 77a4ac5..f8dc534 100644
--- a/src/dparent.c
+++ b/src/dparent.c
@@ -141,7 +141,7 @@ int dcc_standalone_server(void)
#ifdef HAVE_AVAHI
/* Zeroconf registration */
if (opt_zeroconf) {
- if (!(avahi = dcc_zeroconf_register((uint16_t) arg_port, n_cpus)))
+ if (!(avahi = dcc_zeroconf_register((uint16_t) arg_port, n_cpus, dcc_max_kids)))
return EXIT_CONNECT_FAILED;
}
#endif
diff --git a/src/exec.c b/src/exec.c
index 6b19881..46b377e 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -51,6 +51,7 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
+#include <poll.h>
#include <signal.h>
#include <sys/types.h>
@@ -58,10 +59,11 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
-#include <sys/poll.h>
#ifdef __CYGWIN__
- #define NOGDI
+ /* #define NOGDI */
+ #define RC_INVOKED
+ #define NOWINRES
#include <windows.h>
#endif
diff --git a/src/hosts.c b/src/hosts.c
index a237bd8..3a58366 100644
--- a/src/hosts.c
+++ b/src/hosts.c
@@ -334,6 +334,9 @@ static int dcc_parse_tcp_host(struct dcc_hostdef *hostdef,
const char *token = token_start;
if (token[0] == '[') {
+ /* Skip the leading bracket, which is not part of the address */
+ token++;
+
/* We have an IPv6 Address */
if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/] \t\n\r\f,")))
return ret;
diff --git a/src/lsdistcc.c b/src/lsdistcc.c
index 7b1848c..27c8601 100644
--- a/src/lsdistcc.c
+++ b/src/lsdistcc.c
@@ -88,7 +88,7 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <netinet/in.h>
diff --git a/src/rpc.h b/src/rpc.h
index 5ddf0e3..cfcca8f 100644
--- a/src/rpc.h
+++ b/src/rpc.h
@@ -24,6 +24,9 @@
/* His hand is stretched out, and who shall turn it back?
* -- Isaiah 14:27 */
+#ifndef __DISTCC_RPC_H__
+#define __DISTCC_RPC_H__
+
int dcc_x_result_header(int ofd, enum dcc_protover);
int dcc_r_result_header(int ofd, enum dcc_protover);
@@ -49,3 +52,6 @@ int dcc_r_argv(int ifd,
const char *argc_token,
const char *argv_token,
/*@out@*/ char ***argv);
+
+
+#endif \ No newline at end of file
diff --git a/src/rslave.c b/src/rslave.c
index e756241..f05840a 100644
--- a/src/rslave.c
+++ b/src/rslave.c
@@ -30,7 +30,7 @@
#include <string.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/time.h>
#include "rslave.h"
diff --git a/src/serve.c b/src/serve.c
index 5eb940c..336a491 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -61,15 +61,11 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
-#include <signal.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
-#ifdef HAVE_SYS_SIGNAL_H
-# include <sys/signal.h>
-#endif /* HAVE_SYS_SIGNAL_H */
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -689,13 +685,16 @@ static int dcc_run_job(int in_fd,
if ((ret = dcc_x_result_header(out_fd, protover))
|| (ret = dcc_x_cc_status(out_fd, status))
|| (ret = dcc_x_file(out_fd, err_fname, "SERR", compr, NULL))
- || (ret = dcc_x_file(out_fd, out_fname, "SOUT", compr, NULL))
- || WIFSIGNALED(status)
- || WEXITSTATUS(status)) {
+ || (ret = dcc_x_file(out_fd, out_fname, "SOUT", compr, NULL))) {
+ /* We get a protocol derailment if we send DOTO 0 here */
+
+ if (job_result == -1)
+ job_result = STATS_COMPILE_ERROR;
+ } else if (WIFSIGNALED(status) || WEXITSTATUS(status)) {
/* Something went wrong, so send DOTO 0 */
dcc_x_token_int(out_fd, "DOTO", 0);
- if (job_result == -1)
+ if (job_result == -1)
job_result = STATS_COMPILE_ERROR;
} else {
if (cpp_where == DCC_CPP_ON_SERVER) {
diff --git a/src/ssh.c b/src/ssh.c
index 7cced93..9826b90 100644
--- a/src/ssh.c
+++ b/src/ssh.c
@@ -178,6 +178,12 @@ static int dcc_run_piped_cmd(char **argv,
* nice for us to parse it into an argv[] string by splitting on
* wildcards/quotes, but at the moment this seems redundant. It can be done
* adequately using .ssh/config I think.
+ *
+ * @note the ssh command does need to be tokenized as we have hundreds of
+ * users and a corporate requirement that keeps us from modifying the
+ * system ssh config files. We can at the same time set command-line options
+ * through the tool in use one level above this. - prw 08/09/2016
+ *
**/
int dcc_ssh_connect(char *ssh_cmd,
char *user,
@@ -187,14 +193,26 @@ int dcc_ssh_connect(char *ssh_cmd,
pid_t *ssh_pid)
{
pid_t ret;
- char *child_argv[10];
- int i;
+ const int max_ssh_args = 12;
+ char *ssh_args[max_ssh_args];
+ char *child_argv[10+max_ssh_args];
+ int i,j;
+ int num_ssh_args = 0;
/* We need to cast away constness. I promise the strings in the argv[]
* will not be modified. */
- if (!ssh_cmd)
- ssh_cmd = getenv("DISTCC_SSH");
+ if (!ssh_cmd) {
+ char *ssh_cmd_in = getenv("DISTCC_SSH");
+ ssh_cmd = strtok(ssh_cmd_in, " ");
+ char *token = strtok(NULL, " ");
+ while (token != NULL) {
+ ssh_args[num_ssh_args++] = token;
+ token = strtok(NULL, " ");
+ if (num_ssh_args == max_ssh_args)
+ break;
+ }
+ }
if (!ssh_cmd)
ssh_cmd = (char *) dcc_default_ssh;
@@ -207,6 +225,10 @@ int dcc_ssh_connect(char *ssh_cmd,
i = 0;
child_argv[i++] = ssh_cmd;
+ for (j=0; j<num_ssh_args; ) {
+ child_argv[i++] = ssh_args[j++];
+ }
+
if (user) {
child_argv[i++] = (char *) "-l";
child_argv[i++] = user;
diff --git a/src/stats.c b/src/stats.c
index c1661f7..98bcd85 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -469,6 +469,7 @@ static void dcc_stats_process(struct statsdata *sd) {
break;
case STATS_COMPILE_OK:
dcc_stats_update_compile_times(sd);
+ /* fallthrough */
case STATS_COMPILE_ERROR:
case STATS_COMPILE_TIMEOUT:
case STATS_CLI_DISCONN:
diff --git a/src/zeroconf-reg.c b/src/zeroconf-reg.c
index 8511315..744c868 100644
--- a/src/zeroconf-reg.c
+++ b/src/zeroconf-reg.c
@@ -52,6 +52,7 @@ struct context {
AvahiEntryGroup *group;
uint16_t port;
int n_cpus;
+ int n_jobs;
};
static void publish_reply(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata);
@@ -73,9 +74,10 @@ static void register_stuff(struct context *ctx) {
}
if (avahi_entry_group_is_empty(ctx->group)) {
- char cpus[32], machine[64] = "cc_machine=", version[64] = "cc_version=", *m, *v;
+ char cpus[32], jobs[32], machine[64] = "cc_machine=", version[64] = "cc_version=", *m, *v;
snprintf(cpus, sizeof(cpus), "cpus=%i", ctx->n_cpus);
+ snprintf(jobs, sizeof(jobs), "jobs=%i", ctx->n_jobs);
v = dcc_get_gcc_version(version+11, sizeof(version)-11);
m = dcc_get_gcc_machine(machine+11, sizeof(machine)-11);
@@ -93,11 +95,12 @@ static void register_stuff(struct context *ctx) {
ctx->port,
"txtvers=1",
cpus,
+ jobs,
"distcc="PACKAGE_VERSION,
"gnuhost="GNU_HOST,
v ? version : NULL,
m ? machine : NULL,
- NULL) < 0) {
+ (void*)NULL) < 0) {
rs_log_crit("Failed to add service: %s\n", avahi_strerror(avahi_client_errno(ctx->client)));
goto fail;
}
@@ -222,8 +225,8 @@ static void client_callback(AvahiClient *client, AvahiClientState state, void *u
}
}
-/* register a distcc service in DNS-SD/mDNS with the given port and number of CPUs */
-void* dcc_zeroconf_register(uint16_t port, int n_cpus) {
+/* register a distcc service in DNS-SD/mDNS with the given port, number of CPUs, and maximum concurrent jobs */
+void* dcc_zeroconf_register(uint16_t port, int n_cpus, int n_jobs) {
struct context *ctx = NULL;
char service[256] = "distcc@";
int error;
@@ -235,6 +238,7 @@ void* dcc_zeroconf_register(uint16_t port, int n_cpus) {
ctx->threaded_poll = NULL;
ctx->port = port;
ctx->n_cpus = n_cpus;
+ ctx->n_jobs = n_jobs;
/* Prepare service name */
gethostname(service+7, sizeof(service)-8);
diff --git a/src/zeroconf.c b/src/zeroconf.c
index 652cc1d..cdb6ea3 100644
--- a/src/zeroconf.c
+++ b/src/zeroconf.c
@@ -25,6 +25,7 @@
#include <sys/select.h>
#include <signal.h>
#include <sys/file.h>
+#include <fcntl.h>
#include <sys/time.h>
#include <time.h>
#include <sys/stat.h>
@@ -33,6 +34,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
+#include <fcntl.h>
#include <avahi-common/domain.h>
#include <avahi-common/error.h>
@@ -77,6 +79,7 @@ struct host {
AvahiAddress address;
uint16_t port;
int n_cpus;
+ int n_jobs;
AvahiServiceResolver *resolver;
};
@@ -163,9 +166,9 @@ static int write_hosts(struct daemon_data *d) {
/* Not yet fully resolved */
continue;
if (h->address.proto == AVAHI_PROTO_INET6)
- snprintf(t, sizeof(t), "[%s]:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, d->n_slots * h->n_cpus);
+ snprintf(t, sizeof(t), "[%s]:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, h->n_jobs);
else
- snprintf(t, sizeof(t), "%s:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, d->n_slots * h->n_cpus);
+ snprintf(t, sizeof(t), "%s:%u/%i\n", avahi_address_snprint(a, sizeof(a), &h->address), h->port, h->n_jobs);
if (dcc_writex(d->fd, t, strlen(t)) != 0) {
rs_log_crit("write() failed: %s\n", strerror(errno));
@@ -276,6 +279,21 @@ static void resolve_reply(
avahi_free(value);
}
+ /* Look for the number of jobs in TXT RRs, and if not found, then set n_jobs = 4 * n_cpus */
+ for (i = txt; i; i = i->next) {
+ char *key, *value;
+
+ if (avahi_string_list_get_pair(i, &key, &value, NULL) < 0)
+ continue;
+
+ if (!strcmp(key, "jobs"))
+ if ((h->n_jobs = atoi(value)) <= 0)
+ h->n_jobs = 4 * h->n_cpus;
+
+ avahi_free(key);
+ avahi_free(value);
+ }
+
h->address = *a;
h->port = port;
@@ -350,6 +368,7 @@ static void browse_reply(
h->protocol = protocol;
h->next = d->hosts;
h->n_cpus = 1;
+ h->n_jobs = 4;
d->hosts = h;
}
diff --git a/src/zeroconf.h b/src/zeroconf.h
index a152659..ea1f807 100644
--- a/src/zeroconf.h
+++ b/src/zeroconf.h
@@ -25,7 +25,7 @@
int dcc_zeroconf_add_hosts(struct dcc_hostdef **re_list, int *ret_nhosts, int slots, struct dcc_hostdef **ret_prev);
-void *dcc_zeroconf_register(uint16_t port, int n_cpus);
+void *dcc_zeroconf_register(uint16_t port, int n_cpus, int n_jobs);
int dcc_zeroconf_unregister(void*);
char* dcc_get_gcc_version(char *s, size_t nbytes);
diff --git a/test/comfychair.py b/test/comfychair.py
index 2e5a111..12c72ef 100755
--- a/test/comfychair.py
+++ b/test/comfychair.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Copyright (C) 2002, 2003 by Martin Pool <mbp@samba.org>
# Copyright (C) 2003 by Tim Potter <tpot@samba.org>
@@ -105,13 +105,14 @@ class TestCase:
"""
while self._cleanups:
try:
- apply(self._cleanups.pop())
+ clean_task = self._cleanups.pop()
+ clean_task()
except KeyboardInterrupt:
- print "interrupted during cleanups"
+ print("interrupted during cleanups")
_report_error(self, debugger)
return 2
except:
- print "error during cleanups"
+ print("error during cleanups")
_report_error(self, debugger)
return 1
return 0
@@ -130,7 +131,7 @@ class TestCase:
If the predicate value is not true, the test is skipped with a message explaining
why."""
if not predicate:
- raise NotRunError, message
+ raise NotRunError(message)
def require_root(self):
"""Skip this test unless run by root."""
@@ -146,11 +147,11 @@ why."""
def assert_equal(self, a, b):
if not a == b:
- raise AssertionError("assertEquals failed: %s" % `(a, b)`)
+ raise AssertionError("assertEquals failed: %s %s" % (repr(a), repr(b)))
def assert_notequal(self, a, b):
if a == b:
- raise AssertionError("assertNotEqual failed: %s" % `(a, b)`)
+ raise AssertionError("assertNotEqual failed: %s %s" % (repr(a), repr(b)))
def assert_re_match(self, pattern, s):
"""Assert that a string matches a particular pattern
@@ -165,7 +166,7 @@ why."""
if not re.match(pattern, s):
raise AssertionError("string does not match regexp\n"
" string: %s\n"
- " re: %s" % (`s`, `pattern`))
+ " re: %s" % (repr(s), repr(pattern)))
def assert_re_search(self, pattern, s):
"""Assert that a string *contains* a particular pattern
@@ -180,7 +181,7 @@ why."""
if not re.search(pattern, s):
raise AssertionError("string does not contain regexp\n"
" string: %s\n"
- " re: %s" % (`s`, `pattern`))
+ " re: %s" % (repr(s), repr(pattern)))
def assert_no_file(self, filename):
@@ -191,7 +192,7 @@ why."""
# Methods for running programs
def runcmd_background(self, cmd):
- self.test_log = self.test_log + "Run in background:\n" + `cmd` + "\n"
+ self.test_log = self.test_log + "Run in background:\n" + repr(cmd) + "\n"
pid = os.fork()
if pid == 0:
# child
@@ -223,23 +224,22 @@ stderr:
Based in part on popen2.py
Returns (waitstatus, stdout, stderr)."""
- import types
pid = os.fork()
if pid == 0:
# child
- try:
+ try:
pid = os.getpid()
openmode = os.O_WRONLY|os.O_CREAT|os.O_TRUNC
- outfd = os.open('%d.out' % pid, openmode, 0666)
+ outfd = os.open('%d.out' % pid, openmode)
os.dup2(outfd, 1)
os.close(outfd)
- errfd = os.open('%d.err' % pid, openmode, 0666)
+ errfd = os.open('%d.err' % pid, openmode)
os.dup2(errfd, 2)
os.close(errfd)
- if isinstance(cmd, types.StringType):
+ if isinstance(cmd, str):
cmd = ['/bin/sh', '-c', cmd]
os.execvp(cmd[0], cmd)
@@ -257,7 +257,7 @@ stderr:
"""Invoke a command; return (exitcode, stdout, stderr)"""
waitstatus, stdout, stderr = self.run_captured(cmd)
assert not os.WIFSIGNALED(waitstatus), \
- ("%s terminated with signal %d" % (`cmd`, os.WTERMSIG(waitstatus)))
+ ("%s terminated with signal %d" % (repr(cmd), os.WTERMSIG(waitstatus)))
rc = os.WEXITSTATUS(waitstatus)
self.test_log = self.test_log + ("""Run command: %s
Wait status: %#x (exit code %d, signal %d)
@@ -270,13 +270,13 @@ stderr:
# Either we could not execute the command or the command
# returned exit code 127. According to system(3) we can't
# tell the difference.
- raise NotRunError, "could not execute %s" % `cmd`
+ raise NotRunError("could not execute %s" % repr(cmd))
return rc, stdout, stderr
def explain_failure(self, exc_info = None):
- print "test_log:"
- print self.test_log
+ print("test_log:")
+ print(self.test_log)
def log(self, msg):
@@ -300,12 +300,12 @@ def _report_error(case, debugger):
debugger if true, a debugger function to be applied to the traceback
"""
ex = sys.exc_info()
- print "-----------------------------------------------------------------"
+ print("-----------------------------------------------------------------")
if ex:
import traceback
traceback.print_exc(file=sys.stdout)
case.explain_failure()
- print "-----------------------------------------------------------------"
+ print("-----------------------------------------------------------------")
if debugger:
tb = ex[2]
@@ -330,12 +330,12 @@ def runtest(testcase_class, ret, verbose=0, debugger=None, subtest=0):
test progress is not printed.
"""
if not subtest:
- print "%-30s" % _test_name(testcase_class),
+ print("%-30s" % _test_name(testcase_class), end=' ')
def failure_print(message):
- print message
+ print(message)
else:
def failure_print(message):
- print '[%s %s]' % (_test_name(testcase_class), message)
+ print('[%s %s]' % (_test_name(testcase_class), message))
# flush now so that long running tests are easier to follow
sys.stdout.flush()
@@ -348,13 +348,13 @@ def runtest(testcase_class, ret, verbose=0, debugger=None, subtest=0):
obj.setup()
obj.runtest()
if not subtest:
- print "OK"
+ print("OK")
except KeyboardInterrupt:
failure_print("INTERRUPT")
if obj:
_report_error(obj, debugger)
raise
- except NotRunError, msg:
+ except NotRunError as msg:
failure_print("NOTRUN, %s" % msg.value)
except:
failure_print("FAIL")
@@ -399,12 +399,12 @@ def _test_name(test_class):
try:
return test_class.__name__
except:
- return `test_class`
+ return repr(test_class)
def print_help():
"""Help for people running tests"""
- print """%s: software test suite based on ComfyChair
+ print("""%s: software test suite based on ComfyChair
usage:
To run all tests, just run this program. To run particular tests,
@@ -415,13 +415,13 @@ options:
--list list available tests
--verbose, -v show more information while running tests
--post-mortem, -p enter Python debugger on error
-""" % sys.argv[0]
+""" % sys.argv[0])
def print_list(test_list):
"""Show list of available tests"""
for test_class in test_list:
- print " %s" % _test_name(test_class)
+ print(" %s" % _test_name(test_class))
def main(tests, extra_tests=[]):
@@ -478,4 +478,4 @@ Calls sys.exit() on completion.
if __name__ == '__main__':
- print __doc__
+ print(__doc__)
diff --git a/test/onetest.py b/test/onetest.py
index cf33ba3..ef630a0 100755
--- a/test/onetest.py
+++ b/test/onetest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
#
# Copyright 2007 Google Inc.
#
diff --git a/test/testdistcc.py b/test/testdistcc.py
index 69bbc6f..ef0e351 100755
--- a/test/testdistcc.py
+++ b/test/testdistcc.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2.2
+#! /usr/bin/env python3
# Copyright (C) 2002, 2003, 2004 by Martin Pool <mbp@samba.org>
# Copyright 2007 Google Inc.
@@ -169,7 +169,7 @@ EXIT_ACCESS_DENIED = 113
DISTCC_TEST_PORT = 42000
-_gcc = None # full path to gcc
+_cc = None # full path to gcc
_valgrind_command = "" # Command to invoke valgrind (or other
# similar debugging tool).
# e.g. "valgrind --quiet --num-callsers=20 "
@@ -183,7 +183,7 @@ def _ShellSafe(s):
# Some tests only make sense for certain object formats
def _FirstBytes(filename, count):
'''Returns the first count bytes from the given file.'''
- f = open(filename)
+ f = open(filename, 'rb')
try:
return f.read(count)
finally:
@@ -195,7 +195,7 @@ def _IsElf(filename):
taken from /usr/share/file/magic on an ubuntu machine.
'''
contents = _FirstBytes(filename, 5)
- return contents.startswith('\177ELF')
+ return contents.startswith(b'\177ELF')
def _IsMachO(filename):
'''Given a filename, determine if it's an Mach-O object file or
@@ -203,22 +203,22 @@ def _IsMachO(filename):
is taken from /usr/share/file/magic on an ubuntu machine.
'''
contents = _FirstBytes(filename, 10)
- return (contents.startswith('\xCA\xFE\xBA\xBE') or
- contents.startswith('\xFE\xED\xFA\xCE') or
- contents.startswith('\xCE\xFA\xED\xFE') or
+ return (contents.startswith(b'\xCA\xFE\xBA\xBE') or
+ contents.startswith(b'\xFE\xED\xFA\xCE') or
+ contents.startswith(b'\xCE\xFA\xED\xFE') or
# The magic file says '4-bytes (BE) & 0xfeffffff ==
# 0xfeedface' and '4-bytes (LE) & 0xfffffffe ==
# 0xfeedface' are also mach-o.
- contents.startswith('\xFF\xED\xFA\xCE') or
- contents.startswith('\xCE\xFA\xED\xFF'))
-
+ contents.startswith(b'\xFF\xED\xFA\xCE') or
+ contents.startswith(b'\xCE\xFA\xED\xFF'))
+
def _IsPE(filename):
'''Given a filename, determine if it's a Microsoft PE object file or
executable. The magic number used ('MZ') is taken from
/usr/share/file/magic on an ubuntu machine.
'''
- contents = _FirstBytes(filename, 5)
- return contents.startswith('MZ')
+ contents = _FirstBytes(filename, 5)
+ return contents.startswith(b'MZ')
def _Touch(filename):
'''Update the access and modification time of the given file,
@@ -235,11 +235,15 @@ class SimpleDistCC_Case(comfychair.TestCase):
'''Abstract base class for distcc tests'''
def setup(self):
self.stripEnvironment()
+ self.initCompiler()
+
+ def initCompiler(self):
+ self._cc = self._get_compiler()
def stripEnvironment(self):
"""Remove all DISTCC variables from the environment, so that
the test is not affected by the development environment."""
- for key in os.environ.keys():
+ for key in list(os.environ.keys()):
if key[:7] == 'DISTCC_':
# NOTE: This only works properly on Python 2.2: on
# earlier versions, it does not call unsetenv() and so
@@ -265,6 +269,34 @@ class SimpleDistCC_Case(comfychair.TestCase):
def distcc_without_fallback(self):
return "DISTCC_FALLBACK=0 " + self.distcc()
+ def _get_compiler(self):
+ cc = self._find_compiler("cc")
+ if self.is_clang(cc):
+ return self._find_compiler("clang")
+ elif self.is_gcc(cc):
+ return self._find_compiler("gcc")
+ raise AssertionError("Unknown compiler")
+
+ def _find_compiler(self, compiler):
+ for path in os.environ['PATH'].split (':'):
+ abs_path = os.path.join (path, compiler)
+
+ if os.path.isfile (abs_path):
+ return abs_path
+ return None
+
+ def is_gcc(self, compiler):
+ out, err = self.runcmd(compiler + " --version")
+ if re.search('Free Software Foundation', out):
+ return True
+ return False
+
+ def is_clang(self, compiler):
+ out, err = self.runcmd(compiler + " --version")
+ if re.search('clang', out):
+ return True
+ return False
+
class WithDaemon_Case(SimpleDistCC_Case):
"""Start the daemon, and then run a command locally against it.
@@ -369,7 +401,7 @@ class VersionOption_Case(SimpleDistCC_Case):
out, err = self.runcmd("%s --version" % prog)
assert out[-1] == '\n'
out = out[:-1]
- line1,line2,trash = string.split(out, '\n', 2)
+ line1,line2,trash = out.split('\n', 2)
self.assert_re_match(r'^%s [\w.-]+ [.\w-]+$'
% prog, line1)
self.assert_re_match(r'^[ \t]+\(protocol.*\) \(default port 3632\)$'
@@ -390,22 +422,27 @@ class BogusOption_Case(SimpleDistCC_Case):
Now that we support implicit compilers, this is passed to gcc,
which returns a non-zero status."""
def runtest(self):
- error_rc, _, _ = self.runcmd_unchecked(_gcc + " --bogus-option")
+ error_rc, _, _ = self.runcmd_unchecked(self._cc + " --bogus-option")
assert error_rc != 0
- self.runcmd(self.distcc() + _gcc + " --bogus-option", error_rc)
- self.runcmd(self.distccd() + _gcc + " --bogus-option",
+ self.runcmd(self.distcc() + self._cc + " --bogus-option", error_rc)
+ self.runcmd(self.distccd() + self._cc + " --bogus-option",
EXIT_BAD_ARGUMENTS)
-class GccOptionsPassed_Case(SimpleDistCC_Case):
+class CompilerOptionsPassed_Case(SimpleDistCC_Case):
"""Test that options following the compiler name are passed to the compiler."""
def runtest(self):
out, err = self.runcmd("DISTCC_HOSTS=localhost "
+ self.distcc()
- + _gcc + " --help")
+ + self._cc + " --help")
if re.search('distcc', out):
- raise ("gcc help contains \"distcc\": \"%s\"" % out)
- self.assert_re_match(r"^Usage: [^ ]*gcc", out)
+ raise AssertionError("compiler help contains \"distcc\": \"%s\"" % out)
+ if self.is_gcc(self._cc):
+ self.assert_re_match(r"Usage: [^ ]*gcc", out)
+ elif self.is_clang(self._cc):
+ self.assert_re_match(r"OVERVIEW: [^ ]*clang", out)
+ else:
+ raise AssertionError("Unknown compiler found")
class StripArgs_Case(SimpleDistCC_Case):
@@ -461,7 +498,7 @@ class IsSource_Case(SimpleDistCC_Case):
expected = ("%s %s\n" % (issrc, iscpp))
if o != expected:
raise AssertionError("issource %s gave %s, expected %s" %
- (f, `o`, `expected`))
+ (f, repr(o), repr(expected)))
@@ -484,11 +521,10 @@ class ScanArgs_Case(SimpleDistCC_Case):
("gcc -S -c hello.c", "distribute", "hello.c", "hello.s"),
("gcc -M hello.c", "local"),
("gcc -ME hello.c", "local"),
-
("gcc -MD -c hello.c", "distribute", "hello.c", "hello.o"),
("gcc -MMD -c hello.c", "distribute", "hello.c", "hello.o"),
- # Assemble to stdout (thanks Alexandre).
+ # Assemble to stdout (thanks Alexandre).
("gcc -S foo.c -o -", "local"),
("-S -o - foo.c", "local"),
("-c -S -o - foo.c", "local"),
@@ -519,20 +555,20 @@ class ScanArgs_Case(SimpleDistCC_Case):
("gcc -dr -c foo.c", "local"),
]
for tup in cases:
- apply(self.checkScanArgs, tup)
+ self.checkScanArgs(*tup)
def checkScanArgs(self, ccmd, mode, input=None, output=None):
o, err = self.runcmd("h_scanargs %s" % ccmd)
o = o[:-1] # trim \n
- os = string.split(o)
+ os = o.split()
if mode != os[0]:
self.fail("h_scanargs %s gave %s mode, expected %s" %
(ccmd, os[0], mode))
if mode == 'distribute':
- if os[1] <> input:
+ if os[1] != input:
self.fail("h_scanargs %s gave %s input, expected %s" %
(ccmd, os[1], input))
- if os[2] <> output:
+ if os[2] != output:
self.fail("h_scanargs %s gave %s output, expected %s" %
(ccmd, os[2], output))
@@ -554,7 +590,7 @@ class DotD_Case(SimpleDistCC_Case):
#
# - The expected target name (or None).
#
-
+
# The dotd_name is thus divined by examination of the compilation
# directory where we actually run gcc.
@@ -577,7 +613,7 @@ class DotD_Case(SimpleDistCC_Case):
# These C++ cases fail if your gcc installation doesn't support C++.
error_rc, _, _ = self.runcmd_unchecked("touch testtmp.cpp; " +
- _gcc + " -c testtmp.cpp -o /dev/null")
+ self._cc + " -c testtmp.cpp -o /dev/null")
if error_rc == 0:
cases.extend([("foo.cpp -o hello.o", "*.d", 0, None),
("foo.cpp -o hello", "*.d", 0, None)])
@@ -588,7 +624,7 @@ class DotD_Case(SimpleDistCC_Case):
map_out['needs_dotd'],
map_out['sets_dotd_target'],
map_out['dotd_target'])
-
+
for (args, dep_glob, how_many, target) in cases:
# Determine what gcc says.
@@ -601,7 +637,7 @@ int main(void) { return 0; }
def sourceFilename(self):
return args.split()[0]
def compileCmd(self):
- return _gcc + " -c " + args
+ return self._cc + " -c " + args
def runtest(self):
self.compile()
glob_result = glob.glob(dep_glob)
@@ -660,7 +696,7 @@ int main(void) { return 0; }
class Compile_c_Case(SimpleDistCC_Case):
"""Unit tests for source file 'compile.c.'
-
+
Currently, only the functions dcc_fresh_dependency_exists() and
dcc_discrepancy_filename() are tested.
"""
@@ -733,7 +769,7 @@ foo_bar""",
# Line is non-blank
checked_deps[self.getDep(line)] = 1
deps_list = deps[:]
- checked_deps_list = checked_deps.keys()
+ checked_deps_list = list(checked_deps.keys())
deps_list.sort()
checked_deps_list.sort()
self.assert_equal(checked_deps_list, deps_list)
@@ -759,8 +795,8 @@ class ImplicitCompilerScan_Case(ScanArgs_Case):
for tup in cases:
# NB use "apply" rather than new syntax for compatibility with
# venerable Pythons.
- apply(self.checkScanArgs, tup)
-
+ self.checkScanArgs(*tup)
+
class ExtractExtension_Case(SimpleDistCC_Case):
def runtest(self):
@@ -787,7 +823,7 @@ class DaemonBadPort_Case(SimpleDistCC_Case):
class InvalidHostSpec_Case(SimpleDistCC_Case):
def runtest(self):
"""Test various invalid DISTCC_HOSTS
-
+
See also test_parse_host_spec, which tests valid specifications."""
for spec in ["", " ", "\t", " @ ", ":", "mbp@", "angry::", ":4200"]:
self.runcmd(("DISTCC_HOSTS=\"%s\" " % spec) + self.valgrind()
@@ -836,7 +872,7 @@ class ParseHostSpec_Case(SimpleDistCC_Case):
"""
out, err = self.runcmd(("DISTCC_HOSTS=\"%s\" " % spec) + self.valgrind()
+ "h_hosts")
- assert out == expected, "expected %s\ngot %s" % (`expected`, `out`)
+ assert out == expected, "expected %s\ngot %s" % (repr(expected), repr(out))
class Compilation_Case(WithDaemon_Case):
@@ -873,22 +909,22 @@ class Compilation_Case(WithDaemon_Case):
cmd = self.compileCmd()
out, err = self.runcmd(cmd)
if out != '':
- self.fail("compiler command %s produced output:\n%s" % (`cmd`, out))
+ self.fail("compiler command %s produced output:\n%s" % (repr(cmd), out))
if err != '':
- self.fail("compiler command %s produced error:\n%s" % (`cmd`, err))
+ self.fail("compiler command %s produced error:\n%s" % (repr(cmd), err))
def link(self):
cmd = self.linkCmd()
out, err = self.runcmd(cmd)
if out != '':
- self.fail("command %s produced output:\n%s" % (`cmd`, `out`))
+ self.fail("command %s produced output:\n%s" % (repr(cmd), repr(out)))
if err != '':
- self.fail("command %s produced error:\n%s" % (`cmd`, `err`))
+ self.fail("command %s produced error:\n%s" % (repr(cmd), repr(err)))
def compileCmd(self):
"""Return command to compile source"""
return self.distcc_without_fallback() + \
- _gcc + " -o testtmp.o " + self.compileOpts() + \
+ self._cc + " -o testtmp.o " + self.compileOpts() + \
" -c %s" % (self.sourceFilename())
def compileOpts(self):
@@ -898,16 +934,15 @@ class Compilation_Case(WithDaemon_Case):
def linkCmd(self):
"""Return command to link object files"""
return self.distcc() + \
- _gcc + " -o testtmp testtmp.o " + self.libraries()
+ self._cc + " -o testtmp testtmp.o " + self.libraries()
def libraries(self):
"""Returns any '-l' options needed to link the program."""
return ""
def checkCompileMsgs(self, msgs):
- if msgs <> '':
- self.fail("expected no compiler messages, got \"%s\""
- % msgs)
+ if len(msgs) > 0:
+ self.fail("expected no compiler messages, got \"%s\"" % msgs)
def checkBuiltProgram(self):
'''Check compile/link results. By default, just try to execute.'''
@@ -966,8 +1001,8 @@ int main(void) {
class BackslashInMacro_Case(ComputedInclude_Case):
def source(self):
return """
+#include <stdio.h>
#if FALSE
- #include <stdio.h>
#define HEADER MAKE_HEADER(testhdr)
#define MAKE_HEADER(header_name) STRINGIZE(foobar\)
#define STRINGIZE(x) STRINGIZE2(x)
@@ -1016,7 +1051,7 @@ class LanguageSpecific_Case(Compilation_Case):
error_rc, _, _ = self.runcmd_unchecked(
"touch " + source + "; " +
"rm -f testtmp.o; " +
- _gcc + " -x " + lang + " " + self.compileOpts() +
+ self._cc + " -x " + lang + " " + self.compileOpts() +
" -c " + source + " " + self.libraries() + " && " +
"test -f testtmp.o" )
if error_rc != 0:
@@ -1148,7 +1183,7 @@ class SystemIncludeDirectories_Case(Compilation_Case):
def compileOpts(self):
if os.path.exists("/usr/include/sys/types.h"):
- return "-I/usr/include/sys"
+ return "-I/usr/include/"
else:
raise comfychair.NotRunError (
"This test requires /usr/include/sys/types.h")
@@ -1160,12 +1195,13 @@ class SystemIncludeDirectories_Case(Compilation_Case):
def source(self):
return """
-#include "types.h" /* Should resolve to /usr/incude/sys/types.h. */
+#include "sys/types.h" /* Should resolve to /usr/incude/sys/types.h. */
#include <stdio.h>
#include "testhdr.h"
int main(void) {
+ uint val = 1u;
puts(HELLO_WORLD);
- return 0;
+ return val == 1 ? 0 : 1;
}
"""
@@ -1214,7 +1250,7 @@ class Gdb_Case(CompileHello_Case):
def compiler(self):
"""Command for compiling and linking."""
- return _gcc + " -g ";
+ return self._cc + " -g ";
def compileCmd(self):
"""Return command to compile source"""
@@ -1236,9 +1272,9 @@ class Gdb_Case(CompileHello_Case):
" -o link/testtmp obj/testtmp.o")
out, err = self.runcmd(cmd)
if out != '':
- self.fail("command %s produced output:\n%s" % (`cmd`, `out`))
+ self.fail("command %s produced output:\n%s" % (repr(cmd), repr(out)))
if err != '':
- self.fail("command %s produced error:\n%s" % (`cmd`, `err`))
+ self.fail("command %s produced error:\n%s" % (repr(cmd), repr(err)))
def runtest(self):
# Don't try to run the test if gdb is not installed
@@ -1266,7 +1302,7 @@ class Gdb_Case(CompileHello_Case):
if os.path.exists('link/testtmp.exe'):
testtmp_exe = 'testtmp.exe'
else:
- testtmp_exe = 'testtmp'
+ testtmp_exe = 'testtmp'
# Run gdb and verify that it is able to correctly locate the
# testtmp.c source file. We write the gdb commands to a file
@@ -1355,17 +1391,17 @@ class Gdb_Case(CompileHello_Case):
class GdbOpt1_Case(Gdb_Case):
def compiler(self):
"""Command for compiling and linking."""
- return _gcc + " -g -O1 ";
+ return self._cc + " -g -O1 ";
class GdbOpt2_Case(Gdb_Case):
def compiler(self):
"""Command for compiling and linking."""
- return _gcc + " -g -O2 ";
+ return self._cc + " -g -O2 ";
class GdbOpt3_Case(Gdb_Case):
def compiler(self):
"""Command for compiling and linking."""
- return _gcc + " -g -O3 ";
+ return self._cc + " -g -O3 ";
class CompressedCompile_Case(CompileHello_Case):
"""Test compilation with compression.
@@ -1392,7 +1428,7 @@ int main(void) {
class DashONoSpace_Case(CompileHello_Case):
def compileCmd(self):
return self.distcc_without_fallback() + \
- _gcc + " -otesttmp.o -c %s" % (self.sourceFilename())
+ self._cc + " -otesttmp.o -c %s" % (self.sourceFilename())
def runtest(self):
if sys.platform == 'sunos5':
@@ -1406,9 +1442,9 @@ class DashONoSpace_Case(CompileHello_Case):
class WriteDevNull_Case(CompileHello_Case):
def runtest(self):
self.compile()
-
+
def compileCmd(self):
- return self.distcc_without_fallback() + _gcc + \
+ return self.distcc_without_fallback() + self._cc + \
" -c -o /dev/null -c %s" % (self.sourceFilename())
@@ -1425,13 +1461,13 @@ int main(void) {
return 0;
}
""")
-
+
def runtest(self):
self.runcmd(self.distcc()
- + _gcc + " -c test1.c test2.c")
+ + self._cc + " -c test1.c test2.c")
self.runcmd(self.distcc()
- + _gcc + " -o test test1.o test2.o")
-
+ + self._cc + " -o test test1.o test2.o")
+
class CppError_Case(CompileHello_Case):
@@ -1440,7 +1476,7 @@ class CppError_Case(CompileHello_Case):
return '#error "not tonight dear"\n'
def runtest(self):
- cmd = self.distcc() + _gcc + " -c testtmp.c"
+ cmd = self.distcc() + self._cc + " -c testtmp.c"
msgs, errs = self.runcmd(cmd, expectedResult=1)
self.assert_re_search("not tonight dear", errs)
self.assert_equal(msgs, '')
@@ -1465,10 +1501,10 @@ class BadInclude_Case(Compilation_Case):
# is exacerbated by distcc's pump mode because we always
# pass -MMD, even when the user didn't. TODO(klarlund):
# change error_rc back to 1 once that FIXME is fixed.
- error_rc, _, _ = self.runcmd_unchecked(_gcc + " -MMD -E testtmp.c")
+ error_rc, _, _ = self.runcmd_unchecked(self._cc + " -MMD -E testtmp.c")
else:
error_rc = 1
- self.runcmd(self.distcc() + _gcc + " -o testtmp.o -c testtmp.c",
+ self.runcmd(self.distcc() + self._cc + " -o testtmp.o -c testtmp.c",
error_rc)
@@ -1477,6 +1513,7 @@ class PreprocessPlainText_Case(Compilation_Case):
def setup(self):
self.stripEnvironment()
self.createSource()
+ self.initCompiler()
def source(self):
return """#define FOO 3
@@ -1491,7 +1528,7 @@ large foo!
def runtest(self):
# -P means not to emit linemarkers
self.runcmd(self.distcc()
- + _gcc + " -E testtmp.c -o testtmp.out")
+ + self._cc + " -E testtmp.c -o testtmp.out")
out = open("testtmp.out").read()
# It's a bit hard to know the exact value, because different versions of
# GNU cpp seem to handle the whitespace differently.
@@ -1500,7 +1537,7 @@ large foo!
def teardown(self):
# no daemon is run for this test
pass
-
+
class NoDetachDaemon_Case(CompileHello_Case):
"""Test the --no-detach option."""
@@ -1516,7 +1553,7 @@ class NoDetachDaemon_Case(CompileHello_Case):
self.pid = self.runcmd_background(cmd)
self.add_cleanup(self.killDaemon)
# Wait until the server is ready for connections.
- time.sleep(0.2) # Give distccd chance to start listening on the port
+ time.sleep(0.2) # Give distccd chance to start listening on the port
sock = socket.socket()
while sock.connect_ex(('127.0.0.1', self.server_port)) != 0:
time.sleep(0.2)
@@ -1573,7 +1610,9 @@ class DashMD_DashMF_DashMT_Case(CompileHello_Case):
"""Test -MD -MFfoo -MTbar"""
def compileOpts(self):
- return "-MD -MFdotd_filename -MTtarget_name_42"
+ opts = "-MD -MFdotd_filename -MTtarget_name_42"
+ opts += " -Qunused-arguments" if self.is_clang(self._cc) else ""
+ return opts
def runtest(self):
try:
@@ -1589,7 +1628,9 @@ class DashWpMD_Case(CompileHello_Case):
"""Test -Wp,-MD,depfile"""
def compileOpts(self):
- return "-Wp,-MD,depsfile"
+ opts = "-Wp,-MD,depsfile"
+ opts += " -Qunused-arguments" if self.is_clang(self._cc) else ""
+ return opts
def runtest(self):
try:
@@ -1623,7 +1664,7 @@ class ScanIncludes_Case(CompileHello_Case):
def compileCmd(self):
return self.distcc_without_fallback() + "--scan-includes " + \
- _gcc + " -o testtmp.o " + self.compileOpts() + \
+ self._cc + " -o testtmp.o " + self.compileOpts() + \
" -c %s" % (self.sourceFilename())
def runtest(self):
@@ -1633,9 +1674,9 @@ class ScanIncludes_Case(CompileHello_Case):
pump_mode = _server_options.find('cpp') != -1
if pump_mode:
if err != '':
- self.fail("distcc command %s produced stderr:\n%s" % (`cmd`, err))
+ self.fail("distcc command %s produced stderr:\n%s" % (repr(cmd), err))
if rc != 0:
- self.fail("distcc command %s failed:\n%s" % (`cmd`, rc))
+ self.fail("distcc command %s failed:\n%s" % (repr(cmd), rc))
self.assert_re_search(
r"FILE /.*/ScanIncludes_Case/testtmp.c", out);
self.assert_re_search(
@@ -1662,10 +1703,10 @@ class AbsSourceFilename_Case(CompileHello_Case):
def compileCmd(self):
return (self.distcc()
- + _gcc
+ + self._cc
+ " -c -o testtmp.o %s/testtmp.c"
% _ShellSafe(os.getcwd()))
-
+
class HundredFold_Case(CompileHello_Case):
"""Try repeated simple compilations.
@@ -1677,24 +1718,24 @@ class HundredFold_Case(CompileHello_Case):
def daemon_lifetime(self):
return 120
-
+
def runtest(self):
- for unused_i in xrange(100):
+ for unused_i in range(100):
self.runcmd(self.distcc()
- + _gcc + " -o testtmp.o -c testtmp.c")
+ + self._cc + " -o testtmp.o -c testtmp.c")
class Concurrent_Case(CompileHello_Case):
"""Try many compilations at the same time"""
def daemon_lifetime(self):
return 120
-
+
def runtest(self):
# may take about a minute or so
pids = {}
- for unused_i in xrange(50):
+ for unused_i in range(50):
kid = self.runcmd_background(self.distcc() +
- _gcc + " -o testtmp.o -c testtmp.c")
+ self._cc + " -o testtmp.o -c testtmp.c")
pids[kid] = kid
while len(pids):
pid, status = os.wait()
@@ -1715,15 +1756,15 @@ class BigAssFile_Case(Compilation_Case):
# source. Picking the size is kind of hard -- something that
# will properly exercise distcc may be too big for small/old
# machines.
-
+
f.write("int main() {}\n")
- for i in xrange(200000):
+ for i in range(200000):
f.write("int i%06d = %d;\n" % (i, i))
f.close()
def runtest(self):
- self.runcmd(self.distcc() + _gcc + " -c %s" % "testtmp.c")
- self.runcmd(self.distcc() + _gcc + " -o testtmp testtmp.o")
+ self.runcmd(self.distcc() + self._cc + " -c %s" % "testtmp.c")
+ self.runcmd(self.distcc() + self._cc + " -o testtmp testtmp.o")
def daemon_lifetime(self):
@@ -1745,7 +1786,7 @@ class BinFalse_Case(Compilation_Case):
"""
def createSource(self):
open("testtmp.i", "wt").write("int main() {}")
-
+
def runtest(self):
# On Solaris and IRIX 6, 'false' returns exit status 255
if sys.platform == 'sunos5' or \
@@ -1771,7 +1812,7 @@ class BinTrue_Case(Compilation_Case):
"""
def createSource(self):
open("testtmp.i", "wt").write("int main() {}")
-
+
def runtest(self):
self.runcmd(self.distcc()
+ "true -c testtmp.i", 0)
@@ -1785,13 +1826,13 @@ class SBeatsC_Case(CompileHello_Case):
# XXX: Are other compilers the same?
def runtest(self):
self.runcmd(self.distcc() +
- _gcc + " -c -S testtmp.c")
+ self._cc + " -c -S testtmp.c")
if os.path.exists("testtmp.o"):
self.fail("created testtmp.o but should not have")
if not os.path.exists("testtmp.s"):
self.fail("did not create testtmp.s but should have")
-
+
class NoServer_Case(CompileHello_Case):
"""Invalid server name"""
def setup(self):
@@ -1800,19 +1841,20 @@ class NoServer_Case(CompileHello_Case):
self.distcc_log = 'distcc.log'
os.environ['DISTCC_LOG'] = self.distcc_log
self.createSource()
-
+ self.initCompiler()
+
def runtest(self):
self.runcmd(self.distcc()
- + _gcc + " -c -o testtmp.o testtmp.c")
+ + self._cc + " -c -o testtmp.o testtmp.c")
msgs = open(self.distcc_log, 'r').read()
self.assert_re_search(r'failed to distribute.*running locally instead',
- msgs)
-
-
+ msgs)
+
+
class ImpliedOutput_Case(CompileHello_Case):
"""Test handling absence of -o"""
def compileCmd(self):
- return self.distcc() + _gcc + " -c testtmp.c"
+ return self.distcc() + self._cc + " -c testtmp.c"
class SyntaxError_Case(Compilation_Case):
@@ -1857,7 +1899,7 @@ class NoHosts_Case(CompileHello_Case):
def compileCmd(self):
"""Return command to compile source and run tests"""
return self.distcc_with_fallback() + \
- _gcc + " -o testtmp.o -c %s" % (self.sourceFilename())
+ self._cc + " -o testtmp.o -c %s" % (self.sourceFilename())
@@ -1877,7 +1919,7 @@ class MissingCompiler_Case(CompileHello_Case):
+ "nosuchcc -c testtmp.i",
expectedResult=EXIT_COMPILER_MISSING)
self.assert_re_search(r'failed to exec', errs)
-
+
class RemoteAssemble_Case(WithDaemon_Case):
@@ -1892,13 +1934,13 @@ class RemoteAssemble_Case(WithDaemon_Case):
.globl msg
.section .rodata
.LC0:
- .string "hello world"
+ .string "hello world"
.data
- .align 4
- .type msg,object
- .size msg,4
+ .align 4
+ .type msg,object
+ .size msg,4
msg:
- .long .LC0
+ .long .LC0
"""
asm_filename = 'test2.s'
@@ -1909,7 +1951,7 @@ msg:
def compile(self):
# Need to build both the C file and the assembly file
- self.runcmd(self.distcc() + _gcc + " -o test2.o -c test2.s")
+ self.runcmd(self.distcc() + self._cc + " -o test2.o -c test2.s")
@@ -1921,13 +1963,13 @@ gcc2_compiled.:
.globl msg
.section .rodata
.LC0:
- .string MSG
+ .string MSG
.data
- .align 4
- .type msg,object
- .size msg,4
+ .align 4
+ .type msg,object
+ .size msg,4
msg:
- .long .LC0
+ .long .LC0
"""
def setup(self):
@@ -1950,8 +1992,8 @@ msg:
class ModeBits_Case(CompileHello_Case):
"""Check distcc obeys umask"""
def runtest(self):
- self.runcmd("umask 0; distcc " + _gcc + " -c testtmp.c")
- self.assert_equal(S_IMODE(os.stat("testtmp.o")[ST_MODE]), 0666)
+ self.runcmd("umask 0; distcc " + self._cc + " -c testtmp.c")
+ self.assert_equal(S_IMODE(os.stat("testtmp.o")[ST_MODE]), 0o666)
class CheckRoot_Case(SimpleDistCC_Case):
@@ -1980,7 +2022,7 @@ class EmptySource_Case(Compilation_Case):
def compile(self):
rc, out, errs = self.runcmd_unchecked(self.distcc()
- + _gcc + " -c %s" % self.sourceFilename())
+ + self._cc + " -c %s" % self.sourceFilename())
if not re.search("internal compiler error", errs):
self.assert_equal(rc, 0)
@@ -1993,7 +2035,7 @@ class BadLogFile_Case(CompileHello_Case):
self.runcmd("chmod 0 distcc.log")
msgs, errs = self.runcmd("DISTCC_LOG=distcc.log " + \
self.distcc() + \
- _gcc + " -c testtmp.c", expectedResult=0)
+ self._cc + " -c testtmp.c", expectedResult=0)
self.assert_re_search("failed to open logfile", errs)
@@ -2013,9 +2055,9 @@ class AccessDenied_Case(CompileHello_Case):
def compileCmd(self):
"""Return command to compile source and run tests"""
return self.distcc_with_fallback() + \
- _gcc + " -o testtmp.o -c %s" % (self.sourceFilename())
+ self._cc + " -o testtmp.o -c %s" % (self.sourceFilename())
+
-
def runtest(self):
self.compile()
errs = open('distcc.log').read()
@@ -2155,14 +2197,6 @@ class Getline_Case(comfychair.TestCase):
self.assert_equal(msg_parts[3], " line = '%s'" % line);
self.assert_equal(msg_parts[4], " rest = '%s'\n" % rest);
-# When invoking compiler, use absolute path so distccd can find it
-for path in os.environ['PATH'].split (':'):
- abs_path = os.path.join (path, 'gcc')
-
- if os.path.isfile (abs_path):
- _gcc = abs_path
- break
-
# All the tests defined in this suite
tests = [
CompileHello_Case,
@@ -2205,7 +2239,7 @@ tests = [
HelpOption_Case,
BogusOption_Case,
MultipleCompile_Case,
- GccOptionsPassed_Case,
+ CompilerOptionsPassed_Case,
IsSource_Case,
ExtractExtension_Case,
ImplicitCompiler_Case,