From f11f7eb40e1831f647635e85354be896a4d27016 Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Wed, 3 Apr 2019 09:07:12 +0100 Subject: [PATCH 1/5] Modernizing autoconf utilities --- config.guess | 993 ++++++++------- config.sub | 2771 +++++++++++++++++++++--------------------- lib/src/json_xpath.c | 126 -- 3 files changed, 1935 insertions(+), 1955 deletions(-) delete mode 100644 lib/src/json_xpath.c diff --git a/config.guess b/config.guess index 2cee4281..79d1317f 100644 --- a/config.guess +++ b/config.guess @@ -1,14 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. +# Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2012-08-14' +timestamp='2019-03-04' # 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 @@ -17,24 +15,22 @@ timestamp='2012-08-14' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # 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. Please send patches (context -# diff format) to and include a 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"). # -# 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. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + me=`echo "$0" | sed -e 's,.*/,,'` @@ -43,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -54,9 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -Free Software Foundation, Inc. +Copyright 1992-2019 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." @@ -90,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -102,34 +94,38 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { 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" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi @@ -138,22 +134,37 @@ 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 -# Detect uclibc systems. +case "$UNAME_SYSTEM" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu -LIBC="gnu" -if [ -f /usr/include/bits/uClibc_config.h ] -then + set_cc_for_build + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) LIBC=uclibc - if [ -n `grep "#define __UCLIBC_CONFIG_VERSION__" /usr/include/bits/uClibc_config.h` ] + #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'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl then - UCLIBC_SUBVER=`sed -n "/#define __UCLIBC_CONFIG_VERSION__ /s///p" /usr/include/bits/uClibc_config.h` - LIBC=$LIBC$UCLIBC_SUBVER + LIBC=musl fi -fi + ;; +esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -166,21 +177,31 @@ 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)` - case "${UNAME_MACHINE_ARCH}" in + 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 ;; - *) machine=${UNAME_MACHINE_ARCH}-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. - case "${UNAME_MACHINE_ARCH}" in + # 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 + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -195,44 +216,67 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in os=netbsd ;; esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) 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}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + 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 ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -249,63 +293,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 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" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -317,9 +352,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -344,38 +379,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + 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/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + 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 [ "$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) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + 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/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -384,25 +419,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -413,44 +448,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # 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} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -459,23 +494,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $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} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -501,17 +536,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -528,7 +563,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -540,14 +575,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -558,7 +593,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -572,26 +607,27 @@ EOF 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 + 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} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -606,28 +642,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 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 + 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 + if [ "$HP_ARCH" = "" ]; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -660,13 +696,13 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (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" ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + 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 @@ -677,23 +713,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -718,11 +754,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -731,7 +767,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -739,9 +775,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -766,127 +802,120 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + 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/ /_/'` + 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/ /_/'` + 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} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + 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 + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + 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 '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + 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 + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -899,125 +928,169 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + 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} + 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-gnueabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + 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} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + 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 + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1031,34 +1104,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-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} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1068,12 +1141,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1083,9 +1156,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1093,7 +1166,7 @@ EOF # 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 configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1105,9 +1178,9 @@ EOF 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 + 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 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1127,9 +1200,9 @@ EOF 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; } + && { 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; } ;; + && { 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; } ;; @@ -1138,28 +1211,28 @@ EOF 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; } + && { 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; } + && { 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; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1170,7 +1243,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1190,23 +1263,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1225,65 +1298,93 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + 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} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - 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 - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + 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} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1292,18 +1393,19 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + # shellcheck disable=SC2154 + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1324,14 +1426,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1340,24 +1442,31 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" exit ;; esac -eval $set_cc_for_build -cat >$dummy.c < "$dummy.c" < -# include +#include +#include #endif main () { @@ -1370,22 +1479,14 @@ main () #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); 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" @@ -1425,39 +1526,49 @@ main () #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); + 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 -# 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 +#if !defined (ultrix) +#include +#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(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) /* >= ULTRIX4 */ + printf ("mips-dec-ultrix4\n"); exit (0); +#else +#if defined(ULTRIX3) || defined(ultrix3) || defined(SIGLOST) + printf ("mips-dec-ultrix3\n"); exit (0); +#endif +#endif +#endif #endif #if defined (alliant) && defined (i860) @@ -1468,54 +1579,38 @@ main () } EOF -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } +echo "$0: unable to guess system type" >&2 -# Convex versions that predate uname can use getsysinfo(1) +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 < 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 @@ -1534,16 +1629,16 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/config.sub b/config.sub index b15df575..a44fd8ae 100644 --- a/config.sub +++ b/config.sub @@ -1,36 +1,31 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. +# Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2012-07-31' +timestamp='2019-01-05' -# 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, see . +# along with this program; if not, see . # # 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 . Submit a context -# diff and a properly formatted GNU ChangeLog entry. +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -38,7 +33,7 @@ timestamp='2012-07-31' # 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;hb=HEAD +# https://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 @@ -58,12 +53,11 @@ timestamp='2012-07-31' 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. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -73,9 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -Free Software Foundation, Inc. +Copyright 1992-2019 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." @@ -97,12 +89,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -118,1200 +110,1166 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) - os= - basic_machine=$1 + *-*-*-*) + basic_machine=$field1-$field2 + os=$field3-$field4 ;; - -bluegene*) - os=-cnk + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ + | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + os=linux-android + ;; + *) + basic_machine=$field1-$field2 + os=$field3 + ;; + esac ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac + ;; + esac ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + os=bsd + ;; + a29khif) + basic_machine=a29k-amd + os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=scout + ;; + alliant) + basic_machine=fx80-alliant + os= + ;; + altos | altos3068) + basic_machine=m68k-altos + os= + ;; + am29k) + basic_machine=a29k-none + os=bsd + ;; + amdahl) + basic_machine=580-amdahl + os=sysv + ;; + amiga) + basic_machine=m68k-unknown + os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=bsd + ;; + aros) + basic_machine=i386-pc + os=aros + ;; + aux) + basic_machine=m68k-apple + os=aux + ;; + balance) + basic_machine=ns32k-sequent + os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=linux + ;; + cegcc) + basic_machine=arm-unknown + os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=bsd + ;; + convex-c2) + basic_machine=c2-convex + os=bsd + ;; + convex-c32) + basic_machine=c32-convex + os=bsd + ;; + convex-c34) + basic_machine=c34-convex + os=bsd + ;; + convex-c38) + basic_machine=c38-convex + os=bsd + ;; + cray) + basic_machine=j90-cray + os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + os= + ;; + da30) + basic_machine=m68k-da30 + os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + os= + ;; + delta88) + basic_machine=m88k-motorola + os=sysv3 + ;; + dicos) + basic_machine=i686-pc + os=dicos + ;; + djgpp) + basic_machine=i586-pc + os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=ose + ;; + gmicro) + basic_machine=tron-gmicro + os=sysv + ;; + go32) + basic_machine=i386-pc + os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=hms + ;; + harris) + basic_machine=m88k-harris + os=sysv3 + ;; + hp300) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=hpux + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=proelf + ;; + i386mach) + basic_machine=i386-mach + os=mach + ;; + vsta) + basic_machine=i386-pc + os=vsta + ;; + isi68 | isi) + basic_machine=m68k-isi + os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=sysv + ;; + merlin) + basic_machine=ns32k-utek + os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + os=coff + ;; + morphos) + basic_machine=powerpc-unknown + os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=moxiebox + ;; + msdos) + basic_machine=i386-pc + os=msdos + ;; + msys) + basic_machine=i686-pc + os=msys + ;; + mvs) + basic_machine=i370-ibm + os=mvs + ;; + nacl) + basic_machine=le32-unknown + os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=newsos + ;; + news1000) + basic_machine=m68030-sony + os=newsos + ;; + necv70) + basic_machine=v70-nec + os=sysv + ;; + nh3000) + basic_machine=m68k-harris + os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=cxux + ;; + nindy960) + basic_machine=i960-intel + os=nindy + ;; + mon960) + basic_machine=i960-intel + os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=ose + ;; + os68k) + basic_machine=m68k-none + os=os68k + ;; + paragon) + basic_machine=i860-intel + os=osf + ;; + parisc) + basic_machine=hppa-unknown + os=linux + ;; + pw32) + basic_machine=i586-unknown + os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=rdos + ;; + rdos32) + basic_machine=i386-pc + os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=coff + ;; + sa29200) + basic_machine=a29k-amd + os=udi + ;; + sei) + basic_machine=mips-sei + os=seiux + ;; + sequent) + basic_machine=i386-sequent + os= + ;; + sps7) + basic_machine=m68k-bull + os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + os= + ;; + stratus) + basic_machine=i860-stratus + os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + os= + ;; + sun2os3) + basic_machine=m68000-sun + os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + os= + ;; + sun3os3) + basic_machine=m68k-sun + os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + os= + ;; + sun4os3) + basic_machine=sparc-sun + os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + os= + ;; + sv1) + basic_machine=sv1-cray + os=unicos + ;; + symmetry) + basic_machine=i386-sequent + os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=unicos + ;; + t90) + basic_machine=t90-cray + os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + os=tpf + ;; + udi29k) + basic_machine=a29k-amd + os=udi + ;; + ultra3) + basic_machine=a29k-nyu + os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=none + ;; + vaxv) + basic_machine=vax-dec + os=sysv + ;; + vms) + basic_machine=vax-dec + os=vms + ;; + vxworks960) + basic_machine=i960-wrs + os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=vxworks + ;; + xbox) + basic_machine=i686-pc + os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + os=unicos + ;; + *) + basic_machine=$1 + os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 \ - | ns16k | ns32k \ - | open8 \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - c54x) - basic_machine=tic54x-unknown + op50n) + cpu=hppa1.1 + vendor=oki ;; - c55x) - basic_machine=tic55x-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - c6x) - basic_machine=tic6x-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - ms1) - basic_machine=mt-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - strongarm | thumb | xscale) - basic_machine=arm-unknown + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + 3b*) + cpu=we32k + vendor=att ;; - xscaleeb) - basic_machine=armeb-unknown + bluegene*) + cpu=powerpc + vendor=ibm + os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + os=${os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + os=${os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $os in + irix*) + ;; + *) + os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + os=nextstep2 + ;; + *) + os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + os=${os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + os=proelf + ;; + none) + cpu=none + vendor=none + ;; + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine + ;; + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - xscaleel) - basic_machine=armel-unknown + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i386-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 + cpu=$basic_machine + vendor=pc ;; + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" pc98) - basic_machine=i386-pc + cpu=i386 + vendor=pc ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + os=${os:-unicosmp} ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + c90-unknown | c90-cray) + vendor=cray + os=${os:-unicos} ;; - pentium4) - basic_machine=i786-pc + fx80-unknown) + vendor=alliant ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + romp-unknown) + vendor=ibm ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + mmix-unknown) + vendor=knuth ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + rs6000-unknown) + vendor=ibm ;; - pn) - basic_machine=pn-gould + vax-unknown) + vendor=dec ;; - power) basic_machine=power-ibm + pdp11-unknown) + vendor=dec ;; - ppc | ppcbe) basic_machine=powerpc-unknown + we32k-unknown) + vendor=att ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + cydra-unknown) + vendor=cydrome ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown + i370-ibm*) + vendor=ibm ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + orion-unknown) + vendor=highlevel ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + os=${os:-bosx} ;; - op50n) - basic_machine=hppa1.1-oki + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - op60c) - basic_machine=hppa1.1-oki + blackfin-*) + cpu=bfin + os=linux ;; - romp) - basic_machine=romp-ibm + c54x-*) + cpu=tic54x ;; - mmix) - basic_machine=mmix-knuth + c55x-*) + cpu=tic55x ;; - rs6000) - basic_machine=rs6000-ibm + c6x-*) + cpu=tic6x ;; - vax) - basic_machine=vax-dec + e500v[12]-*) + cpu=powerpc + os=$os"spe" ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown + mips3*-*) + cpu=mips64 ;; - pdp11) - basic_machine=pdp11-dec + ms1-*) + cpu=mt ;; - we32k) - basic_machine=we32k-att + m68knommu-*) + cpu=m68k + os=linux ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun + openrisc-*) + cpu=or32 ;; - cydra) - basic_machine=cydra-cydrome + parisc-*) + cpu=hppa + os=linux ;; - orion) - basic_machine=orion-highlevel + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - orion105) - basic_machine=clipper-highlevel + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + pentium4-*) + cpu=i786 ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + pc98-*) + cpu=i386 ;; + ppc-* | ppcbe-*) + cpu=powerpc + ;; + ppcle-* | powerpclittle-*) + cpu=powerpcle + ;; + ppc64-*) + cpu=powerpc64 + ;; + ppc64le-* | powerpc64little-*) + cpu=powerpc64le + ;; + sb1-*) + cpu=mipsisa64sb1 + ;; + sb1el-*) + cpu=mipsisa64sb1el + ;; + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` + ;; + spur-*) + cpu=spur + ;; + strongarm-* | thumb-*) + cpu=arm + ;; + tx39-*) + cpu=mipstx39 + ;; + tx39el-*) + cpu=mipstx39el + ;; + x64-*) + cpu=x86_64 + ;; + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` + ;; + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + os=${os:-elf} + ;; + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis + ;; + cris-* | etrax*-*) + cpu=cris + vendor=axis + ;; + crx-*) + os=${os:-elf} + ;; + neo-tandem) + cpu=neo + vendor=tandem + ;; + nse-tandem) + cpu=nse + vendor=tandem + ;; + nsr-tandem) + cpu=nsr + vendor=tandem + ;; + nsv-tandem) + cpu=nsv + vendor=tandem + ;; + nsx-tandem) + cpu=nsx + vendor=tandem + ;; + s390-*) + cpu=s390 + vendor=ibm + ;; + s390x-*) + cpu=s390x + vendor=ibm + ;; + tile*-*) + os=${os:-linux-gnu} + ;; + *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv64 \ + | rl78 | romp | rs6000 | rx \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 | wasm32 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1319,200 +1277,246 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if [ x$os != x ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + # 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.*) + bluegene*) + os=cnk + ;; + solaris1 | solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; - -solaris) - os=-solaris2 + solaris) + os=solaris2 ;; - -svr4*) - os=-sysv4 + unixware*) + os=sysv4.2uw ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) + gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose + ;; + # Some version numbers need modification + chorusos*) + os=chorusos + ;; + isc) + os=isc2.2 + ;; + sco6) + os=sco5v6 + ;; + sco5) + os=sco3.2v5 + ;; + sco4) + os=sco3.2v4 + ;; + sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + ;; + sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + scout) + # Don't match below + ;; + sco*) + os=sco3.2v2 + ;; + psos*) + os=psos + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # 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* | esix* | aix* | cnk* | sunos | sunos[34]*\ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | kopensolaris* | plan9* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | 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* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | 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* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* \ + | morphos* | superux* | rtmk* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten*) # Remember, each alternative MUST END IN *, to match a version number. ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) + qnx*) + case $cpu in + x86 | i*86) ;; *) - os=-nto$os + os=nto-$os ;; esac ;; - -nto-qnx*) + hiux*) + os=hiuxwe2 ;; - -nto*) + nto-qnx*) + ;; + nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + sim | xray | os68k* | v88r* \ + | windows* | osx | abug | netware* | os9* \ + | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + linux-dietlibc) + os=linux-dietlibc ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) + linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + lynx*178) + os=lynxos178 ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + lynx*5) + os=lynxos5 ;; - -opened*) - os=-openedition + lynx*) + os=lynxos ;; - -os400*) - os=-os400 + mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -wince*) - os=-wince + opened*) + os=openedition ;; - -osfrose*) - os=-osfrose + os400*) + os=os400 ;; - -osf*) - os=-osf + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -utek*) - os=-bsd + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -dynix*) - os=-bsd + wince*) + os=wince ;; - -acis*) - os=-aos + utek*) + os=bsd ;; - -atheos*) - os=-atheos + dynix*) + os=bsd ;; - -syllable*) - os=-syllable + acis*) + os=aos ;; - -386bsd) - os=-bsd + atheos*) + os=atheos ;; - -ctix* | -uts*) - os=-sysv + syllable*) + os=syllable ;; - -nova*) - os=-rtmk-nova + 386bsd) + os=bsd ;; - -ns2 ) - os=-nextstep2 + ctix* | uts*) + os=sysv ;; - -nsk*) - os=-nsk + nova*) + os=rtmk-nova + ;; + ns2) + os=nextstep2 + ;; + nsk*) + os=nsk ;; # Preserve the version number of sinix5. - -sinix5.*) + sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; - -sinix*) - os=-sysv4 + sinix*) + os=sysv4 ;; - -tpf*) - os=-tpf + tpf*) + os=tpf ;; - -triton*) - os=-sysv3 + triton*) + os=sysv3 ;; - -oss*) - os=-sysv3 + oss*) + os=sysv3 ;; - -svr4) - os=-sysv4 + svr4*) + os=sysv4 ;; - -svr3) - os=-sysv3 + svr3) + os=sysv3 ;; - -sysvr4) - os=-sysv4 + sysvr4) + os=sysv4 ;; - # This must come after -sysvr4. - -sysv*) + # This must come after sysvr4. + sysv*) ;; - -ose*) - os=-ose + ose*) + os=ose ;; - -es1800*) - os=-ose + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -xenix) - os=-xenix + zvmoe) + os=zvmoe ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + dicos*) + os=dicos ;; - -aros*) - os=-aros + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $cpu in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; - -kaos*) - os=-kaos + nacl*) ;; - -zvmoe) - os=-zvmoe + ios) ;; - -dicos*) - os=-dicos + none) ;; - -nacl*) - ;; - -none) + *-eabi) ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1528,258 +1532,265 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + os=linux ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff + ;; + c8051-*) + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 + ;; + pru-*) + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs + os=luna ;; *-next) - os=-nextstep3 + os=nextstep + ;; + *-sequent) + os=ptx + ;; + *-crds) + os=unos + ;; + *-ns) + os=genix + ;; + i370-*) + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) +case $vendor in + unknown) case $os in - -riscix*) + riscix*) vendor=acorn ;; - -sunos*) + sunos*) vendor=sun ;; - -cnk*|-aix*) + cnk*|-aix*) vendor=ibm ;; - -beos*) + beos*) vendor=be ;; - -hpux*) + hpux*) vendor=hp ;; - -mpeix*) + mpeix*) vendor=hp ;; - -hiux*) + hiux*) vendor=hitachi ;; - -unos*) + unos*) vendor=crds ;; - -dgux*) + dgux*) vendor=dg ;; - -luna*) + luna*) vendor=omron ;; - -genix*) + genix*) vendor=ns ;; - -mvs* | -opened*) + clix*) + vendor=intergraph + ;; + mvs* | opened*) vendor=ibm ;; - -os400*) + os400*) vendor=ibm ;; - -ptx*) + ptx*) vendor=sequent ;; - -tpf*) + tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + vxsim* | vxworks* | windiss*) vendor=wrs ;; - -aux*) + aux*) vendor=apple ;; - -hms*) + hms*) vendor=hitachi ;; - -mpw* | -macos*) + mpw* | macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) vendor=atari ;; - -vos*) + vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/lib/src/json_xpath.c b/lib/src/json_xpath.c deleted file mode 100644 index 9f7c5a54..00000000 --- a/lib/src/json_xpath.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Utility debug tool - * Static Compile: gcc -Wall json_xpath.c -o json_xpath -l clixon -gcc -O2 -o json_xpath json_xpath.c clixon_log.o clixon_err.o clixon_json.o clixon_xml.o clixon_xsl.o clixon_json_parse.tab.o clixon_xml_parse.tab.o lex.clixon_json_parse.o lex.clixon_xml_parse.o ../../../cligen/cligen_buf.o ../../../cligen/cligen_var.o ../../../cligen/cligen_gen.o ../../../cligen/cligen_cvec.o ../../../cligen/cligen_handle.o ../../../cligen/getline.o ../../../cligen/cligen_read.o ../../../cligen/cligen_match.o ../../../cligen/cligen_expand.o ../../../cligen/cligen_print.o - */ -#include -#include -#include -#include - -/* cligen */ -#include - -/* clicon */ -#include - -static int -usage(char *argv0) -{ - fprintf(stderr, "usage:%s # XML/JSON expected on stdin\n" - "\t-h Help\n" - "\t-b Strip to body value (eg \"val\" --> \"val\"\n" - "\t-j json input (not xml)\n", - argv0); - exit(0); -} - -int -main(int argc, char **argv) -{ - int i; - cxobj **xv; - cxobj *x; - cxobj *xn; - cxobj *xb; - char *xpath; - int body = 0; - int json = 0; - size_t xlen = 0; - size_t len; - size_t buflen = 128; - char *buf; - char *p; - int retval; - int c; - - while ((c = getopt(argc, argv, "?hbj")) != -1) - switch (c) { - case '?': - case 'h': - usage(argv[0]); - break; - case 'b': - body++; - break; - case 'j': - json++; - break; - default: - usage(argv[0]); - } - if (optind >= argc) - usage(argv[0]); - xpath=argv[optind]; - - clicon_log_init("xpath", 0, CLICON_LOG_STDERR); - if ((buf = malloc(buflen)) == NULL){ - perror("malloc"); - return -1; - } - /* |---------------|-------------| - * buf p buf+buflen - */ - p = buf; - memset(p, 0, buflen); - while (1){ - if ((retval = read(0, p, buflen-(p-buf))) < 0){ - perror("read"); - return -1; - } - if (retval == 0) - break; - p += retval; - len = p-buf; - - if (buf+buflen-p < 10){ /* allocate more */ - buflen *= 2; - if ((buf = realloc(buf, buflen)) == NULL){ - perror("realloc"); - return -1; - } - p = buf+len; - memset(p, 0, (buf+buflen)-p); - } - } - if (json){ - if (json_parse_str(buf, &x) < 0) - return -1; - } - else - if (xml_parse_string(buf, &x) < 0) - return -1; - - if (xpath_vec(x, xpath, &xv, &xlen) < 0) - return -1; - if (xv){ - for (i=0; i Date: Wed, 3 Apr 2019 09:29:49 +0100 Subject: [PATCH 2/5] Adaptions for ARMv7 --- example/main/README.md | 7 ++++--- example/main/example_backend.c | 2 +- example/main/example_restconf.c | 3 +-- test/README.md | 8 +++++--- test/lib.sh | 4 ++-- test/test_openconfig.sh | 2 +- test/test_yangmodels.sh | 2 +- util/README.md | 4 +++- 8 files changed, 18 insertions(+), 14 deletions(-) diff --git a/example/main/README.md b/example/main/README.md index e55d46eb..76f9eb02 100644 --- a/example/main/README.md +++ b/example/main/README.md @@ -141,11 +141,12 @@ server { ``` Start nginx daemon ``` -sudo /etc/init.d/nginx start + sudo /etc/init.d/nginx start + sudo systemctl start nginx.service # alternative using systemd ``` Start the clixon restconf daemon ``` -sudo su -c "/www-data/clixon_restconf -f /usr/local/etc/example.xml " -s /bin/sh www-data + sudo su -c "/www-data/clixon_restconf -f /usr/local/etc/example.xml " -s /bin/sh www-data ``` then access using curl or wget: ``` @@ -322,4 +323,4 @@ static clixon_plugin_api api = { .ca_suspend=NULL, /* cligen_susp_cb_t */ .ca_interrupt=NULL, /* cligen_interrupt_cb_t */ }; -``` \ No newline at end of file +``` diff --git a/example/main/example_backend.c b/example/main/example_backend.c index 377b87da..31a14d21 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -542,7 +542,7 @@ clixon_plugin_init(clicon_handle h) struct timeval retention = {0,0}; int argc; /* command-line options (after --) */ char **argv; - char c; + int c; clicon_debug(1, "%s backend", __FUNCTION__); diff --git a/example/main/example_restconf.c b/example/main/example_restconf.c index 9a245d19..71bdd391 100644 --- a/example/main/example_restconf.c +++ b/example/main/example_restconf.c @@ -40,7 +40,6 @@ #include #include #include -#include /* cligen */ #include @@ -329,7 +328,7 @@ clixon_plugin_init(clicon_handle h) { int argc; /* command-line options (after --) */ char **argv = NULL; - char c; + int c; clicon_debug(1, "%s restconf", __FUNCTION__); /* Get user command-line options (after --) */ diff --git a/test/README.md b/test/README.md index 27349b26..d11a62ef 100644 --- a/test/README.md +++ b/test/README.md @@ -26,9 +26,11 @@ You need to build and install the clixon utility programs before running the tes sudo make install ``` -You need to start nginx for some of the text. There are instructions in +You need to configure and start nginx for the restconf tests: +* The [example](../example/main/README.md) has instructions on how to edit your nginx config files * If you run systemd: `sudo systemctl start nginx.service` -* The [example](../example/README.md) has instructions + +You may need to install the `time` utility (`/usr/bin/time`). ## Prefix variable @@ -65,7 +67,7 @@ You may add your site-specific modifications in a `site.sh` file. Example: # Add test to this list that you dont want run SKIPLIST="test_openconfig.sh test_yangmodels.sh" # Parse yang openconfig models from https://github.com/openconfig/public - OPENCONFIG=/home/olof/src/clixon/test/public + OPENCONFIG=/usr/local/share/openconfig/public # Parse yangmodels from https://github.com/YangModels/yang YANGMODELS=/usr/local/share/yangmodels # Standard IETF RFC yang files. diff --git a/test/lib.sh b/test/lib.sh index 02728155..32b11f96 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -78,10 +78,10 @@ testname= # Parse yangmodels from https://github.com/YangModels/yang # Recommended: checkout yangmodels elsewhere in the tree and set the env # to that -: ${YANGMODELS=$(pwd)/yang} +#: ${YANGMODELS=$(pwd)/yang} # just skip if not set # Parse yang openconfig models from https://github.com/openconfig/public -: ${OPENCONFIG=$(pwd)/public} +#: ${OPENCONFIG=$(pwd)/public} # just skip if not set # Standard IETF RFC yang files. : ${IETFRFC=../yang/standard} diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh index 387b25c9..c3b491a7 100755 --- a/test/test_openconfig.sh +++ b/test/test_openconfig.sh @@ -18,7 +18,7 @@ fyang=$dir/test.yang new "openconfig" if [ ! -d "$OPENCONFIG" ]; then # err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" - exit + if [ "$s" = $0 ]; then exit 0; else return 0; fi fi OCDIR=$OPENCONFIG/release/models diff --git a/test/test_yangmodels.sh b/test/test_yangmodels.sh index 9acfc191..91bfcc0e 100755 --- a/test/test_yangmodels.sh +++ b/test/test_yangmodels.sh @@ -27,7 +27,7 @@ fyang=$dir/test.yang if [ ! -d "$YANGMODELS" ]; then # err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?" - exit + if [ "$s" = $0 ]; then exit 0; else return 0; fi fi # Experimental IEEE diff --git a/util/README.md b/util/README.md index 542cb620..917edc41 100644 --- a/util/README.md +++ b/util/README.md @@ -2,4 +2,6 @@ This directory contains Clixon utility programs, ie, programs that are good to have for testing, analysis, etc, but not an actual part of -delivered code. \ No newline at end of file +delivered code. + +Note, streams utility may need: libcurl4-openssl-dev or corresponding. From 5b78abccdc9131be8d3fb7fd9a493e188d97c1f2 Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Wed, 3 Apr 2019 18:19:14 +0200 Subject: [PATCH 3/5] NACM read default rule did not work properly if nacm was enabled AND no group\ s were defined --- CHANGELOG.md | 1 + lib/src/clixon_nacm.c | 28 ++++-- test/test_nacm_default.sh | 193 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+), 10 deletions(-) create mode 100755 test/test_nacm_default.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index bd925207..fdebce47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,6 +105,7 @@ * Added libgen.h for baseline() ### Corrected Bugs +* NACM read default rule did not work properly if nacm was enabled AND no groups were defined * Re-inserted `cli_output_reset` for what was erroneuos thought to be an obsolete function * See in 3.9.0 minro changes: Replaced all calls to (obsolete) `cli_output` with `fprintf` * Allowed Yang extended Xpath functions (syntax only): diff --git a/lib/src/clixon_nacm.c b/lib/src/clixon_nacm.c index 9060dc6a..3737561a 100644 --- a/lib/src/clixon_nacm.c +++ b/lib/src/clixon_nacm.c @@ -567,22 +567,27 @@ nacm_datanode_read(cxobj *xt, /* User's group */ if (xpath_vec(xnacm, "groups/group[user-name='%s']", &gvec, &glen, username) < 0) goto done; - /* 4. If no groups are found, continue with step 9. */ - if (glen == 0) - goto step9; + /* 4. If no groups are found (glen=0), continue and check read-default + in step 11. */ /* 5. Process all rule-list entries, in the order they appear in the configuration. If a rule-list's "group" leaf-list does not match any of the user's groups, proceed to the next rule-list entry. */ if (xpath_vec(xnacm, "rule-list", &rlistvec, &rlistlen) < 0) goto done; + /* read-default has default permit so should never be NULL */ + if ((read_default = xml_find_body(xnacm, "read-default")) == NULL){ + clicon_err(OE_XML, EINVAL, "No nacm read-default rule"); + goto done; + } for (i=0; i $cfg + + $cfg + /usr/local/share/clixon + $IETFRFC + $fyang + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/restconf + /usr/local/lib/$APPNAME/cli + $APPNAME + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/lib/$APPNAME/backend + /usr/local/var/$APPNAME/$APPNAME.pidfile + 1 + $dir + /usr/local/lib/xmldb/text.so + false + internal + +EOF + +cat < $fyang +module nacm-example{ + yang-version 1.1; + namespace "urn:example:nacm"; + prefix nacm; + import clixon-example { + prefix ex; + } + import ietf-netconf-acm { + prefix nacm; + } + leaf x{ + type int32; + description "something to edit"; + } +} +EOF + +# +# startup db with default values: +# 1: enable-nacm (true|false) +# 2: read-default (deny|permit) +# 3: write-default (deny|permit) +# 4: exec-defautl (deny|permit) +# 5: expected return value of test1 +# 6: expected return value of test2 +# 7: expected return value of test3 +testrun(){ + enablenacm=$1 + readdefault=$2 + writedefault=$3 + execdefault=$4 + ret1=$5 + ret2=$6 + ret3=$7 + + # NACM in startup + sudo tee $dir/startup_db > /dev/null << EOF + + + ${enablenacm} + ${readdefault} + ${writedefault} + ${execdefault} + true + + 42 + +EOF + if [ $BE -ne 0 ]; then # Bring your own backend + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend -s init -f $cfg" + start_backend -s startup -f $cfg + else + new "Restart backend as eg follows: -Ff $cfg -s startup" + sleep $BETIMEOUT + fi + + new "kill old restconf daemon" + sudo pkill -u www-data -f "/www-data/clixon_restconf" + + sleep 1 + new "start restconf daemon (-a is enable basic authentication)" + start_restconf -f $cfg -- -a + + new "waiting" + sleep $RCWAIT + + #----------- First get + case "$ret1" in + 0) ret='{"nacm-example:x": 42} + ' + ;; + 1) ret='{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' + ;; + 2) ret='null + ' + ;; + esac + new "get startup 42" + expecteq "$(curl -u guest:bar -sS -X GET http://localhost/restconf/data/nacm-example:x)" 0 "$ret" + + #----------- Then edit + case "$ret2" in + 0) ret='' + ;; + 1) ret='{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' + ;; + esac + new "edit new 99" + expecteq "$(curl -u guest:bar -sS -X PUT -d '{"nacm-example:x": 99}' http://localhost/restconf/data/nacm-example:x)" 0 "$ret" + + #----------- Then second get + case "$ret3" in + 0) ret='{"nacm-example:x": 99} + ' + ;; + 1) ret='{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' + ;; + 2) ret='null + ' + ;; + 3) ret='{"nacm-example:x": 42} + ' + esac + new "get 99" + expecteq "$(curl -u guest:bar -sS -X GET http://localhost/restconf/data/nacm-example:x)" 0 "$ret" + + new "Kill restconf daemon" + stop_restconf + + if [ $BE -ne 0 ]; then # Bring your own backend + new "Kill backend" + # Check if premature kill + pid=`pgrep -u root -f clixon_backend` + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg + fi +} # testrun + +# Run a lot of tests with different settings of default read/write/exec +new "nacm enabled and all defaults permit" +testrun true permit permit permit 0 0 0 + +new "nacm disabled and all defaults permit" +testrun false permit permit permit 0 0 0 + +new "nacm disabled and all defaults deny" +testrun false deny deny deny 0 0 0 + +new "nacm enabled, all defaults deny (expect fail)" +testrun true deny deny deny 1 1 1 + +new "nacm enabled, exec default deny - read permit (expect fail)" +testrun true permit deny deny 1 1 1 + +new "nacm enabled, exec default deny - write permit (expect fail)" +testrun true deny permit deny 1 1 1 + +new "nacm enabled, exec default deny read/write permit (expect fail)" +testrun true permit permit deny 1 1 1 + +new "nacm enabled, exec default permit, all others deny (expect fail)" +testrun true deny deny permit 2 1 2 + +new "nacm enabled, exec default permit, read permit (expect fail)" +testrun true permit deny permit 0 1 3 + +new "nacm enabled, exec default permit, write permit (expect fail)" +testrun true deny permit permit 2 0 2 + + +rm -rf $dir From 2d7e303341d9510f2298deb28b69c1d5e960ef2c Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 5 Apr 2019 20:08:54 +0200 Subject: [PATCH 4/5] List ordering bug - lists with ints as keys behaved wrongly and slow --- CHANGELOG.md | 1 + lib/clixon/clixon_xml_sort.h | 5 - lib/src/clixon_xml_sort.c | 261 ++++++++++------------------------- 3 files changed, 76 insertions(+), 191 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdebce47..4dc97fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,6 +105,7 @@ * Added libgen.h for baseline() ### Corrected Bugs +* List ordering bug - lists with ints as keys behaved wrongly and slow. * NACM read default rule did not work properly if nacm was enabled AND no groups were defined * Re-inserted `cli_output_reset` for what was erroneuos thought to be an obsolete function * See in 3.9.0 minro changes: Replaced all calls to (obsolete) `cli_output` with `fprintf` diff --git a/lib/clixon/clixon_xml_sort.h b/lib/clixon/clixon_xml_sort.h index d38b91cf..65908e22 100644 --- a/lib/clixon/clixon_xml_sort.h +++ b/lib/clixon/clixon_xml_sort.h @@ -41,11 +41,6 @@ */ int xml_child_spec(cxobj *x, cxobj *xp, yang_spec *yspec, yang_stmt **yp); int xml_sort(cxobj *x0, void *arg); -cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval); -int xml_insert_pos(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword, - int keynr, char **keyvec, char **keyval, int low, - int upper); -cxobj *xml_match(cxobj *x0, char *name, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval); int xml_sort_verify(cxobj *x, void *arg); int match_base_child(cxobj *x0, cxobj *x1c, yang_stmt *yc, cxobj **x0cp); diff --git a/lib/src/clixon_xml_sort.c b/lib/src/clixon_xml_sort.c index 99f1d474..91ca9428 100644 --- a/lib/src/clixon_xml_sort.c +++ b/lib/src/clixon_xml_sort.c @@ -92,7 +92,7 @@ xml_cv_cache(cxobj *x, if ((cv = xml_cv(x)) != NULL) goto ok; if ((y = xml_spec(x)) == NULL) - goto done; + goto ok; if (yang_type_get(y, NULL, &yrestype, &options, NULL, NULL, &fraction) < 0) goto done; yang2cv_type(yrestype->ys_argument, &cvtype); @@ -331,13 +331,16 @@ xml_cmp1(cxobj *x, int keynr, char **keyvec, char **keyval, + cg_var **keycvec, int *userorder) { char *b; + cxobj *xb; int i; char *keyname; char *key; int match = 0; + cg_var *cv; /* state data = userorder */ if (userorder && yang_config(y)==0) @@ -353,8 +356,15 @@ xml_cmp1(cxobj *x, *userorder=1; if ((b=xml_body(x)) == NULL) match = 1; - else - match = strcmp(keyval[0], b); + else{ + if (keycvec[0]){ + if (xml_cv_cache(x, b, &cv) < 0) /* error case */ + goto done; + match = cv_cmp(keycvec[0], cv); + } + else + match = strcmp(keyval[0], b); + } break; case Y_LIST: /* Match with array of key values */ if (userorder && yang_find((yang_node*)y, Y_ORDERED_BY, "user") != NULL) @@ -363,18 +373,26 @@ xml_cmp1(cxobj *x, for (i=0; ie0 given "name" */ - if ((b = xml_find_body(x, keyname)) == NULL) + if ((xb = xml_find(x, keyname)) == NULL) break; /* error case */ - if ((match = strcmp(key, b)) != 0) - break; + if ((b = xml_body(xb)) == NULL) + break; /* error case */ + if (xml_cv_cache(xb, b, &cv) < 0) /* error case */ + goto done; + if (keycvec[i]){ + if ((match = cv_cmp(keycvec[i], cv)) != 0) + break; + } + else + if ((match = strcmp(key, b)) != 0) + break; } break; default: break; } - // done: - return match; /* should not reach here */ + done: + return match; } /*! Sort children of an XML node @@ -411,7 +429,8 @@ xml_search_userorder(cxobj *x0, enum rfc_6020 keyword, int keynr, char **keyvec, - char **keyval) + char **keyval, + cg_var **keycvec) { int i; cxobj *xc; @@ -421,7 +440,7 @@ xml_search_userorder(cxobj *x0, y = xml_spec(xc); if (yangi!=yang_order(y)) break; - if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, NULL) == 0) + if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, keycvec, NULL) == 0) return xc; } for (i=mid-1; i>=0; i--){ /* Then decrement */ @@ -429,7 +448,7 @@ xml_search_userorder(cxobj *x0, y = xml_spec(xc); if (yangi!=yang_order(y)) break; - if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, NULL) == 0) + if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, keycvec, NULL) == 0) return xc; } return NULL; /* Not found */ @@ -451,6 +470,7 @@ xml_search1(cxobj *x0, int keynr, char **keyvec, char **keyval, + cg_var **keycvec, int low, int upper) { @@ -470,18 +490,18 @@ xml_search1(cxobj *x0, return NULL; cmp = yangi-yang_order(y); if (cmp == 0){ - cmp = xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, &userorder); + cmp = xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, keycvec, &userorder); if (userorder && cmp) /* Look inside this yangi order */ - return xml_search_userorder(x0, y, name, yangi, mid, keyword, keynr, keyvec, keyval); + return xml_search_userorder(x0, y, name, yangi, mid, keyword, keynr, keyvec, keyval, keycvec); } if (cmp == 0) return xc; else if (cmp < 0) return xml_search1(x0, name, yangi, keyword, - keynr, keyvec, keyval, low, mid-1); + keynr, keyvec, keyval, keycvec, low, mid-1); else return xml_search1(x0, name, yangi, keyword, - keynr, keyvec, keyval, mid+1, upper); + keynr, keyvec, keyval, keycvec, mid+1, upper); return NULL; } @@ -491,173 +511,30 @@ xml_search1(cxobj *x0, * @param[in] keyvec Array of of yang key identifiers * @param[in] keyval Array of of yang key values */ -cxobj * +static cxobj * xml_search(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, - char **keyval) + char **keyval, + cg_var **keycvec) { - return xml_search1(x0, name, yangi, keyword, keynr, keyvec, keyval, - 0, xml_child_nr(x0)); + cxobj *xa; + int low = 0; + int high = xml_child_nr(x0); + + /* Assume if there are any attributes, they are first in the list, mask + them by raising low to skip them */ + for (low=0; low= xml_child_nr(x0)) - return xml_child_nr(x0); /* upper range */ - xc = xml_child_i(x0, mid); - y = xml_spec(xc); - cmp = yangi-yang_order(y); - if (cmp == 0){ - cmp = xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, &userorder); - if (userorder){ /* Look inside this yangi order */ - /* Special case: append last of equals if ordered by user */ - for (i=mid+1;ikeyword, name - * list: x0, y->keyword, y->key, name - * - * The function needs a vector of key values (or single for LEAF_LIST). - * What format? - * 1) argc/argv:: "val1","val2" <<== - * 2) cv-list? - * 3) va-list? - * - * yc - LIST (interface) - - * ^ - * | - * x0-->x0c-->(name=interface)+->x(name=name)->xb(value="eth0") <==this is - * | - * v - * x1c->name (interface) - * x1c->x(name=name)->xb(value="eth0") - * - * CONTAINER:name - * LEAF: name - * LEAFLIST: name/body... #b0 - * LIST: name/key0/key1... #b2vec+b0 -> x0c - - * eth0 - * eth1 - * eth2 - * @param[in] x0 XML node. Find child of this node. - * @param[in] keyword Yang keyword. Relevant: container, list, leaf, leaf_list - * @param[in] keynr Length of keyvec/keyval vector when applicable - * @param[in] keyvec Array of of yang key identifiers - * @param[in] keyval Array of of yang key values - * @param[out] xp Return value on success, pointer to XML child node - * @note If keyword is: - * - list, keyvec and keyval should be an array with keynr length - * - leaf_list, keyval should be 1 and keyval should contain one element - * - otherwise, keyval should be 0 and keyval and keyvec should be both NULL. - */ -cxobj * -xml_match(cxobj *x0, - char *name, - enum rfc_6020 keyword, - int keynr, - char **keyvec, - char **keyval) -{ - char *key; - char *keyname; - char *b0; - cxobj *x = NULL; - int equal; - int i; - - x = NULL; - switch (keyword){ - case Y_CONTAINER: /* Match with name */ - case Y_LEAF: /* Match with name */ - if (keynr != 0){ - clicon_err(OE_XML, EINVAL, "Expected no key argument to CONTAINER or LEAF"); - goto ok; - } - x = xml_find(x0, name); - break; - case Y_LEAF_LIST: /* Match with name and value */ - if (keynr != 1) - goto ok; - x = xml_find_body_obj(x0, name, keyval[0]); - break; - case Y_LIST: /* Match with array of key values */ - i = 0; - while ((x = xml_child_each(x0, x, CX_ELMNT)) != NULL){ - equal = 0; - if (strcmp(xml_name(x), name)) - continue; - /* Must be inner loop */ - for (i=0; iys_keyword){ @@ -750,6 +628,12 @@ match_base_child(cxobj *x0, } if ((keyval[0] = xml_body(x1c)) == NULL) goto ok; + if ((keycvec = calloc(keynr+1, sizeof(cg_var*))) == NULL){ + clicon_err(OE_UNIX, errno, "calloc"); + goto done; + } + if (xml_cv_cache(x1c, keyval[0], &keycvec[0]) < 0) /* error case */ + goto done; break; case Y_LIST: /* Match with key values */ cvk = yc->ys_cvec; /* Use Y_LIST cache, see ys_populate_list() */ @@ -768,28 +652,33 @@ match_base_child(cxobj *x0, clicon_err(OE_UNIX, errno, "calloc"); goto done; } + if ((keycvec = calloc(keynr+1, sizeof(char*))) == NULL){ + clicon_err(OE_UNIX, errno, "calloc"); + goto done; + } cvi = NULL; i = 0; while ((cvi = cvec_each(cvk, cvi)) != NULL) { keyname = cv_string_get(cvi); keyvec[i] = keyname; - if ((b = xml_find_body(x1c, keyname)) == NULL) - goto ok; /* not found */ - keyval[i++] = b; + if ((xb = xml_find(x1c, keyname)) == NULL) + goto ok; + if ((b = xml_body(xb)) == NULL) + goto ok; + keyval[i] = b; + if (xml_cv_cache(xb, b, &keycvec[i]) < 0) /* error case */ + goto done; + i++; } break; default: break; } - /* Get match. Sorting mode(optimized) or not?*/ - if (xml_child_nr(x0)==0 || xml_spec(xml_child_i(x0,0))!=NULL){ - yorder = yang_order(yc); - x0c = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval); - } - else{ - x0c = xml_match(x0, xml_name(x1c), yc->ys_keyword, keynr, keyvec, keyval); - } - *x0cp = x0c; + /* Get match. + */ + yorder = yang_order(yc); + x0c = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval, keycvec); ok: + *x0cp = x0c; retval = 0; done: if (keyval) From 473d65c5116aafa0f9d478baa83754d55acc6d94 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 4 Apr 2019 11:08:28 +0200 Subject: [PATCH 5/5] * Optimized validation by making xml_diff work on raw cache tree (not copies) * xmldb_get() removed unnecessary config option --- CHANGELOG.md | 6 +- apps/backend/backend_client.c | 4 +- apps/backend/backend_commit.c | 49 +- apps/backend/backend_startup.c | 2 +- doc/DEVELOP.md | 1 - docker/system/start.sh | 1 - example/main/example.xml | 1 - lib/clixon/clixon_datastore.h | 4 +- lib/clixon/clixon_xml.h | 2 + lib/clixon/clixon_xml_map.h | 4 +- lib/clixon/clixon_xml_sort.h | 5 - lib/src/clixon_datastore.c | 38 +- lib/src/clixon_datastore_read.c | 205 +++++- lib/src/clixon_datastore_read.h | 4 +- lib/src/clixon_datastore_write.c | 18 +- lib/src/clixon_nacm.c | 2 +- lib/src/clixon_xml.c | 13 + lib/src/clixon_xml_map.c | 168 ++--- lib/src/clixon_xml_sort.c | 276 ++++---- lib/src/clixon_xpath.c | 4 +- test/long.sh | 1 - test/plot_perf.sh | 1 - test/test_augment.sh | 1 - test/test_choice.sh | 1 - test/test_cli.sh | 1 - test/test_cli_history.sh | 1 - test/test_copy_config.sh | 1 - test/test_feature.sh | 1 - test/test_identity.sh | 1 - test/test_leafref.sh | 1 - test/test_list.sh | 1 - test/test_nacm.sh | 1 - test/test_nacm_ext.sh | 1 - test/test_nacm_module_read.sh | 3 +- test/test_nacm_module_write.sh | 1 - test/test_nacm_protocol.sh | 1 - test/test_netconf.sh | 1 - test/test_openconfig.sh | 1 - test/test_order.sh | 1 - test/test_perf.sh | 1 - test/test_restconf.sh | 1 - test/test_restconf2.sh | 1 - test/test_rpc.sh | 1 - test/test_startup.sh | 1 - test/test_stream.sh | 1 - test/test_type.sh | 5 +- test/test_type_nocache.sh | 588 ++++++++++++++++++ test/test_union.sh | 1 - test/test_upgrade.sh | 1 - test/test_upgrade_auto.sh | 1 - test/test_upgrade_interfaces.sh | 1 - test/test_upgrade_repair.sh | 1 - test/test_when_must.sh | 1 - test/test_yang.sh | 1 - test/test_yang_load.sh | 8 - ...test_yangmodels.sh => test_yang_models.sh} | 1 - test/test_yang_namespace.sh | 1 - util/clixon_util_datastore.c | 4 +- 58 files changed, 1057 insertions(+), 391 deletions(-) create mode 100755 test/test_type_nocache.sh rename test/{test_yangmodels.sh => test_yang_models.sh} (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd925207..aaa42484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,9 +33,10 @@ * CLICON_XML_CHANGELOG enables the yang changelog feature * CLICON_XML_CHANGELOG_FILE where the changelog resides - ### API changes on existing features (you may need to change your code) -* Structural change: removed datastore plugin and directory, and merged into regulat clixon lib code. +* xmldb_get() removed unnecessary config option: + * Change all calls to dbget from: `xmldb_get(h, db, xpath, 0|1, &xret, msd)` to `xmldb_get(h, db, xpath, &xret, msd)` +* Structural change: removed datastore plugin and directory, and merged into regular clixon lib code. * The CLICON_XMLDB_PLUGIN config option is obsolete, you should remove it from your config file * The datastore directory is removed, code is moved to lib/src/clixon_datastore*.c * removed clixon_backend -x command-line options @@ -83,6 +84,7 @@ ``` ### Minor changes +* Optimized validation by making xml_diff work on raw cache tree (not copies) * Added syntactic check for yang status: current, deprecated or obsolete. * Added `xml_wrap` function that adds an XML node above a node as a wrapper * also renamed `xml_insert` to `xml_wrap_all`. diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index 16855189..ab69b683 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -314,7 +314,7 @@ from_client_get_config(clicon_handle h, if ((xfilter = xml_find(xe, "filter")) != NULL) if ((xpath = xml_find_value(xfilter, "select"))==NULL) xpath="/"; - if (xmldb_get(h, db, xpath, 1, &xret, NULL) < 0){ + if (xmldb_get(h, db, xpath, &xret, NULL) < 0){ if (netconf_operation_failed(cbret, "application", "read registry")< 0) goto done; goto ok; @@ -773,7 +773,7 @@ from_client_get(clicon_handle h, if ((xpath = xml_find_value(xfilter, "select"))==NULL) xpath="/"; /* Get config */ - if (xmldb_get(h, "running", xpath, 0, &xret, NULL) < 0){ + if (xmldb_get(h, "running", xpath, &xret, NULL) < 0){ if (netconf_operation_failed(cbret, "application", "read registry")< 0) goto done; goto ok; diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index deffd9fd..8f04eb14 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -180,7 +180,7 @@ startup_common(clicon_handle h, if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE")) if ((msd = modstate_diff_new()) == NULL) goto done; - if (xmldb_get(h, db, "/", 1, &xt, msd) < 0) + if (xmldb_get(h, db, "/", &xt, msd) < 0) goto done; if (msd){ if ((ret = clixon_module_upgrade(h, xt, msd, cbret)) < 0) @@ -350,11 +350,9 @@ from_validate_common(clicon_handle h, clicon_err(OE_FATAL, 0, "No DB_SPEC"); goto done; } - /* This is the state we are going to */ - if (xmldb_get(h, candidate, "/", 1, &td->td_target, NULL) < 0) + if (xmldb_get1(h, candidate, "/", &td->td_target, NULL) < 0) goto done; - /* Validate the target state. It is not completely clear this should be done * here. It is being made in generic_validate below. * But xml_diff requires some basic validation, at least check that yang-specs @@ -367,9 +365,9 @@ from_validate_common(clicon_handle h, /* 2. Parse xml trees * This is the state we are going from */ - if (xmldb_get(h, "running", "/", 1, &td->td_src, NULL) < 0) + if (xmldb_get1(h, "running", "/", &td->td_src, NULL) < 0) goto done; - + /* 3. Compute differences */ if (xml_diff(yspec, td->td_src, @@ -469,7 +467,14 @@ candidate_commit(clicon_handle h, if (plugin_transaction_commit(h, td) < 0) goto done; - /* Optionally write (potentially modified) tree back to candidate */ + /* Clear cached trees from default values and marking */ + if (xmldb_get1_clear(h, candidate) < 0) + goto done; + if (xmldb_get1_clear(h, "running") < 0) + goto done; + + /* Optionally write (potentially modified) tree back to candidate + */ if (clicon_option_bool(h, "CLICON_TRANSACTION_MOD")){ if ((ret = xmldb_put(h, candidate, OP_REPLACE, td->td_target, clicon_username_get(h), cbret)) < 0) @@ -490,8 +495,14 @@ candidate_commit(clicon_handle h, /* In case of failure (or error), call plugin transaction termination callbacks */ if (retval < 1 && td) plugin_transaction_abort(h, td); - if (td) + if (td){ + if (clicon_option_bool(h, "CLICON_XMLDB_CACHE")){ + /* xmldb_get1 requires free only if not cache */ + td->td_target = NULL; + td->td_src = NULL; + } transaction_free(td); + } return retval; fail: retval = 0; @@ -662,7 +673,7 @@ from_client_validate(clicon_handle h, } clicon_debug(1, "Validate %s", db); - /* 1. Start transaction */ + /* 1. Start transaction */ if ((td = transaction_new()) == NULL) goto done; /* Common steps (with commit) */ @@ -674,6 +685,12 @@ from_client_validate(clicon_handle h, } goto ok; } + /* Clear cached trees from default values and marking */ + if (xmldb_get1_clear(h, db) < 0) + goto done; + if (xmldb_get1_clear(h, "running") < 0) + goto done; + /* Optionally write (potentially modified) tree back to candidate */ if (clicon_option_bool(h, "CLICON_TRANSACTION_MOD")){ if ((ret = xmldb_put(h, "candidate", OP_REPLACE, td->td_target, @@ -685,10 +702,16 @@ from_client_validate(clicon_handle h, ok: retval = 0; done: - if (retval < 0 && td) - plugin_transaction_abort(h, td); - if (td) - transaction_free(td); + if (retval < 0 && td) + plugin_transaction_abort(h, td); + if (td){ + if (clicon_option_bool(h, "CLICON_XMLDB_CACHE")){ + /* xmldb_get1 requires free only if not cache */ + td->td_target = NULL; + td->td_src = NULL; + } + transaction_free(td); + } return retval; } /* from_client_validate */ diff --git a/apps/backend/backend_startup.c b/apps/backend/backend_startup.c index 17ead1cc..a3e20fcf 100644 --- a/apps/backend/backend_startup.c +++ b/apps/backend/backend_startup.c @@ -102,7 +102,7 @@ db_merge(clicon_handle h, cxobj *xt = NULL; /* Get data as xml from db1 */ - if (xmldb_get(h, (char*)db1, NULL, 1, &xt, NULL) < 0) + if (xmldb_get(h, (char*)db1, NULL, &xt, NULL) < 0) goto done; /* Merge xml into db2. Without commit */ retval = xmldb_put(h, (char*)db2, OP_MERGE, xt, clicon_username_get(h), cbret); diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md index cb59647e..7e17d086 100644 --- a/doc/DEVELOP.md +++ b/doc/DEVELOP.md @@ -83,7 +83,6 @@ cat < /tmp/myconf.xml /usr/local/var/example/example.sock /usr/local/var/example/example.pidfile /usr/local/var/example - /usr/local/lib/xmldb/text.so EOF sudo clixon_backend -F -s init -f /tmp/myconf.xml -y /tmp/my.yang diff --git a/docker/system/start.sh b/docker/system/start.sh index af20ae1d..909f72fd 100755 --- a/docker/system/start.sh +++ b/docker/system/start.sh @@ -39,7 +39,6 @@ CONFIG0=$(cat <1 VARS /usr/local/var/example - /usr/local/lib/xmldb/text.so 0 init disabled diff --git a/example/main/example.xml b/example/main/example.xml index 3d3cf99b..a7c13214 100644 --- a/example/main/example.xml +++ b/example/main/example.xml @@ -14,7 +14,6 @@ 1 VARS /usr/local/var/example - /usr/local/lib/xmldb/text.so 0 init disabled diff --git a/lib/clixon/clixon_datastore.h b/lib/clixon/clixon_datastore.h index 89b7d1f1..61ec86a2 100644 --- a/lib/clixon/clixon_datastore.h +++ b/lib/clixon/clixon_datastore.h @@ -48,7 +48,9 @@ int xmldb_db2file(clicon_handle h, const char *db, char **filename); int xmldb_validate_db(const char *db); int xmldb_connect(clicon_handle h); int xmldb_disconnect(clicon_handle h); -int xmldb_get(clicon_handle h, const char *db, char *xpath, int config, cxobj **xtop, modstate_diff_t *msd); +int xmldb_get(clicon_handle h, const char *db, char *xpath, cxobj **xtop, modstate_diff_t *msd); /* in clixon_datastore_read.[ch] */ +int xmldb_get1(clicon_handle h, const char *db, char *xpath, cxobj **xtop, modstate_diff_t *msd); /* in clixon_datastore_read.[ch] */ +int xmldb_get1_clear(clicon_handle h, const char *db); int xmldb_put(clicon_handle h, const char *db, enum operation_type op, cxobj *xt, char *username, cbuf *cbret); /* in clixon_datastore_write.[ch] */ int xmldb_copy(clicon_handle h, const char *from, const char *to); int xmldb_lock(clicon_handle h, const char *db, int pid); diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h index 4933115b..6a94d5c9 100644 --- a/lib/clixon/clixon_xml.h +++ b/lib/clixon/clixon_xml.h @@ -85,6 +85,7 @@ typedef int (xml_applyfn_t)(cxobj *x, void *arg); #define XML_FLAG_DEL 0x04 /* Node is deleted (commits) or parent deleted rec */ #define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */ #define XML_FLAG_NONE 0x10 /* Node is added as NONE */ +#define XML_FLAG_DEFAULT 0x20 /* Added as default value @see xml_default*/ /* * Prototypes @@ -137,6 +138,7 @@ int xml_rootchild(cxobj *xp, int i, cxobj **xcp); int xml_rootchild_node(cxobj *xp, cxobj *xc); int xml_enumerate_children(cxobj *xp); +int xml_enumerate_reset(cxobj *xp); int xml_enumerate_get(cxobj *x); char *xml_body(cxobj *xn); diff --git a/lib/clixon/clixon_xml_map.h b/lib/clixon/clixon_xml_map.h index afc04b3c..da9d87ca 100644 --- a/lib/clixon/clixon_xml_map.h +++ b/lib/clixon/clixon_xml_map.h @@ -51,10 +51,10 @@ int xml_yang_validate_all(cxobj *xt, cbuf *cbret); int xml_yang_validate_all_top(cxobj *xt, cbuf *cbret); int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0); int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0); -int xml_diff(yang_spec *yspec, cxobj *xt1, cxobj *xt2, +int xml_diff(yang_spec *yspec, cxobj *x0, cxobj *x1, cxobj ***first, size_t *firstlen, cxobj ***second, size_t *secondlen, - cxobj ***changed1, cxobj ***changed2, size_t *changedlen); + cxobj ***changed_x0, cxobj ***changed_x1, size_t *changedlen); int yang2api_path_fmt(yang_stmt *ys, int inclkey, char **api_path_fmt); int api_path_fmt2api_path(char *api_path_fmt, cvec *cvv, char **api_path); int api_path_fmt2xpath(char *api_path_fmt, cvec *cvv, char **xpath); diff --git a/lib/clixon/clixon_xml_sort.h b/lib/clixon/clixon_xml_sort.h index d38b91cf..65908e22 100644 --- a/lib/clixon/clixon_xml_sort.h +++ b/lib/clixon/clixon_xml_sort.h @@ -41,11 +41,6 @@ */ int xml_child_spec(cxobj *x, cxobj *xp, yang_spec *yspec, yang_stmt **yp); int xml_sort(cxobj *x0, void *arg); -cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval); -int xml_insert_pos(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword, - int keynr, char **keyvec, char **keyval, int low, - int upper); -cxobj *xml_match(cxobj *x0, char *name, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval); int xml_sort_verify(cxobj *x, void *arg); int match_base_child(cxobj *x0, cxobj *x1c, yang_stmt *yc, cxobj **x0cp); diff --git a/lib/src/clixon_datastore.c b/lib/src/clixon_datastore.c index e85270bc..149cf49d 100644 --- a/lib/src/clixon_datastore.c +++ b/lib/src/clixon_datastore.c @@ -172,42 +172,6 @@ xmldb_disconnect(clicon_handle h) return retval; } -/*! Get content of database using xpath. return a set of matching sub-trees - * The function returns a minimal tree that includes all sub-trees that match - * xpath. - * @param[in] h Clicon handle - * @param[in] dbname Name of database to search in (filename including dir path - * @param[in] xpath String with XPATH syntax. or NULL for all - * @param[in] config If set only configuration data, else also state - * @param[out] xret Single return XML tree. Free with xml_free() - * @param[out] msd If set, return modules-state differences - * @retval 0 OK - * @retval -1 Error - * @code - * cxobj *xt; - * if (xmldb_get(xh, "running", "/interfaces/interface[name="eth"]", 1, &xt, NULL) < 0) - * err; - * xml_free(xt); - * @endcode - * @note if xvec is given, then purge tree, if not return whole tree. - * @see xpath_vec - */ -int -xmldb_get(clicon_handle h, - const char *db, - char *xpath, - int config, - cxobj **xret, - modstate_diff_t *msd) -{ - int retval = -1; - - if (clicon_option_bool(h, "CLICON_XMLDB_CACHE")) - retval = xmldb_get_cache(h, db, xpath, config, xret, msd); - else - retval = xmldb_get_nocache(h, db, xpath, config, xret, msd); - return retval; -} /*! Copy database from db1 to db2 * @param[in] h Clicon handle @@ -264,11 +228,11 @@ xmldb_copy(clicon_handle h, clicon_db_elmnt_set(h, to, &de0); } } + /* Copy the files themselves (above only in-memory cache) */ if (xmldb_db2file(h, from, &fromfile) < 0) goto done; if (xmldb_db2file(h, to, &tofile) < 0) goto done; - /* Copy the files themselves (above only in-memory cache) */ if (clicon_file_copy(fromfile, tofile) < 0) goto done; retval = 0; diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c index 3515f4f2..79c3872d 100644 --- a/lib/src/clixon_datastore_read.c +++ b/lib/src/clixon_datastore_read.c @@ -374,18 +374,16 @@ xmldb_readfile(clicon_handle h, * @param[in] h Clicon handle * @param[in] db Name of database to search in (filename including dir path * @param[in] xpath String with XPATH syntax. or NULL for all - * @param[in] config If set only configuration data, else also state * @param[out] xret Single return XML tree. Free with xml_free() * @param[out] msd If set, return modules-state differences * @retval 0 OK * @retval -1 Error * @see xmldb_get the generic API function */ -int +static int xmldb_get_nocache(clicon_handle h, const char *db, char *xpath, - int config, cxobj **xtop, modstate_diff_t *msd) { @@ -457,15 +455,6 @@ xmldb_get_nocache(clicon_handle h, if (xml_apply(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0) goto done; - /* filter out state (operations) data if config not set. Mark all nodes - that are not config data */ - if (config){ - if (xml_apply(xt, CX_ELMNT, xml_non_config_data, NULL) < 0) - goto done; - /* Remove (prune) nodes that are marked (that does not pass test) */ - if (xml_tree_prune_flagged(xt, XML_FLAG_MARK, 1) < 0) - goto done; - } /* Add default values (if not set) */ if (xml_apply(xt, CX_ELMNT, xml_default, NULL) < 0) goto done; @@ -497,20 +486,18 @@ xmldb_get_nocache(clicon_handle h, * @param[in] h Clicon handle * @param[in] db Name of database to search in (filename including dir path * @param[in] xpath String with XPATH syntax. or NULL for all - * @param[in] config If set only configuration data, else also state * @param[out] xret Single return XML tree. Free with xml_free() * @param[out] msd If set, return modules-state differences * @retval 0 OK * @retval -1 Error * @see xmldb_get the generic API function */ -int +static int xmldb_get_cache(clicon_handle h, - const char *db, - char *xpath, - int config, - cxobj **xtop, - modstate_diff_t *msd) + const char *db, + char *xpath, + cxobj **xtop, + modstate_diff_t *msd) { int retval = -1; yang_spec *yspec; @@ -591,3 +578,183 @@ xmldb_get_cache(clicon_handle h, return retval; } +/*! Get the raw cache of whole tree + * Useful for some higer level usecases for optimized access + * This is a clixon datastore plugin of the the xmldb api + * @param[in] h Clicon handle + * @param[in] db Name of database to search in (filename including dir path + * @param[in] xpath String with XPATH syntax. or NULL for all + * @param[in] config If set only configuration data, else also state + * @param[out] xret Single return XML tree. Free with xml_free() + * @param[out] msd If set, return modules-state differences + * @retval 0 OK + * @retval -1 Error + */ +static int +xmldb_get1_cache(clicon_handle h, + const char *db, + char *xpath, + cxobj **xtop, + modstate_diff_t *modst) +{ + int retval = -1; + yang_spec *yspec; + cxobj *x0t = NULL; /* (cached) top of tree */ + cxobj **xvec = NULL; + size_t xlen; + int i; + cxobj *x0; + db_elmnt *de = NULL; + db_elmnt de0 = {0,}; + + if (!clicon_option_bool(h, "CLICON_XMLDB_CACHE")){ + clicon_err(OE_CFG, 0, "CLICON_XMLDB_CACHE must be set"); + goto done; + } + if ((yspec = clicon_dbspec_yang(h)) == NULL){ + clicon_err(OE_YANG, ENOENT, "No yang spec"); + goto done; + } + de = clicon_db_elmnt_get(h, db); + if (de == NULL || de->de_xml == NULL){ /* Cache miss, read XML from file */ + /* If there is no xml x0 tree (in cache), then read it from file */ + if (xmldb_readfile(h, db, yspec, &x0t, modst) < 0) + goto done; + /* XXX: should we validate file if read from disk? + * Argument against: we may want to have a semantically wrong file and wish + * to edit? + */ + de0.de_xml = x0t; + clicon_db_elmnt_set(h, db, &de0); + } /* x0t == NULL */ + else + x0t = de->de_xml; + /* Here xt looks like: ... */ + if (xpath_vec(x0t, "%s", &xvec, &xlen, xpath?xpath:"/") < 0) + goto done; + /* Iterate through the match vector + * For every node found in x0, mark the tree up to t1 + */ + for (i=0; i1) + clicon_xml2file(stderr, x0t, 0, 1); + *xtop = x0t; + retval = 0; + done: + clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); + if (xvec) + free(xvec); + return retval; +} + +/*! Get content of database using xpath. return a set of matching sub-trees + * The function returns a minimal tree that includes all sub-trees that match + * xpath. + * @param[in] h Clicon handle + * @param[in] db Name of database to search in (filename including dir path + * @param[in] xpath String with XPATH syntax. or NULL for all + * @param[out] xret Single return XML tree. Free with xml_free() + * @param[out] msd If set, return modules-state differences + * @retval 0 OK + * @retval -1 Error + * @code + * cxobj *xt; + * if (xmldb_get(xh, "running", "/interfaces/interface[name="eth"]", &xt, NULL) < 0) + * err; + * xml_free(xt); + * @endcode + * @note if xvec is given, then purge tree, if not return whole tree. + * @see xpath_vec + */ +int +xmldb_get(clicon_handle h, + const char *db, + char *xpath, + cxobj **xret, + modstate_diff_t *msd) +{ + int retval = -1; + + if (clicon_option_bool(h, "CLICON_XMLDB_CACHE")) + retval = xmldb_get_cache(h, db, xpath, xret, msd); + else + retval = xmldb_get_nocache(h, db, xpath, xret, msd); + return retval; +} + +/*! Get content of database using xpath. return a set of matching sub-trees + * The function returns a minimal tree that includes all sub-trees that match + * xpath. + * @param[in] h Clicon handle + * @param[in] db Name of database to search in (filename including dir path + * @param[in] xpath String with XPATH syntax. or NULL for all + * @param[out] xret Single return XML tree. see note + * @param[out] msd If set, return modules-state differences + * @retval 0 OK + * @retval -1 Error + * @code + * cxobj *xt; + * if (xmldb_get(xh, "running", "/interfaces/interface[name="eth"]", &xt, NULL) < 0) + * err; + * xml_free(xt); + * @endcode + * @note if xvec is given, then purge tree, if not return whole tree. + * @see xmldb_get This version uses direct cache access and needs to be + * cleanued up after use + * @see xmldb_get1_clean Must call after use + * @note If !CLICON_XMLDB_CACHE you need to free xret after use + * This should probably replace xmldb_get completely + */ +int +xmldb_get1(clicon_handle h, + const char *db, + char *xpath, + cxobj **xret, + modstate_diff_t *msd) +{ + int retval = -1; + + if (clicon_option_bool(h, "CLICON_XMLDB_CACHE")) + retval = xmldb_get1_cache(h, db, xpath, xret, msd); + else + retval = xmldb_get_nocache(h, db, xpath, xret, msd); + return retval; +} + +/*! Clear cached tree after accessed by xmldb_get1 + * + * @param[in] h Clicon handle + * @param[in] dbname Name of database to search in (filename including dir path + * @see xmldb_get1 + */ +int +xmldb_get1_clear(clicon_handle h, + const char *db) +{ + int retval = -1; + db_elmnt *de = NULL; + + if (!clicon_option_bool(h, "CLICON_XMLDB_CACHE")) + goto ok; /* dont bother, tree is a copy */ + de = clicon_db_elmnt_get(h, db); + if (de != NULL && de->de_xml != NULL){ + /* clear XML tree of defaults */ + if (xml_tree_prune_flagged(de->de_xml, XML_FLAG_DEFAULT, 1) < 0) + goto done; + /* clear mark and change */ + xml_apply0(de->de_xml, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, + (void*)(0xff)); + } + ok: + retval = 0; + done: + return retval; + +} diff --git a/lib/src/clixon_datastore_read.h b/lib/src/clixon_datastore_read.h index b7a20ff6..283ca8d7 100644 --- a/lib/src/clixon_datastore_read.h +++ b/lib/src/clixon_datastore_read.h @@ -39,8 +39,6 @@ /* * Prototypes */ -int xmldb_get_cache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd); -int xmldb_get_nocache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd); -int xmldb_readfile(clicon_handle h, const char *db, yang_spec *yspec, cxobj **xp, modstate_diff_t *msd); +int xmldb_readfile(clicon_handle h, const char *db, yang_spec *yspec, cxobj **xp, modstate_diff_t *msd); #endif /* _CLIXON_DATASTORE_READ_H */ diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 1e604f9b..1948cbaa 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -30,15 +30,6 @@ the terms of any one of the Apache License version 2 or the GPL. ***** END LICENSE BLOCK ***** -1000 entries -valgrind --tool=callgrind datastore_client -d candidate -b /tmp/text -p ../datastore/text/text.so -y /tmp -m ietf-ip mget 300 /x/y[a=574][b=574] > /dev/null - xml_copy_marked 87% 200x - yang_key_match 81% 600K - yang_arg2cvec 52% 400K - cvecfree 23% 400K - -10000 entries -valgrind --tool=callgrind datastore_client -d candidate -b /tmp/text -p ../datastore/text/text.so -y /tmp -m ietf-ip mget 10 /x/y[a=574][b=574] > /dev/null */ @@ -136,6 +127,7 @@ text_modify(clicon_handle h, cxobj **x0vec = NULL; int i; int ret; + int changed = 0; /* Only if x0p's children have changed-> sort is necessary */ assert(x1 && xml_type(x1) == CX_ELMNT); assert(y0); @@ -167,6 +159,7 @@ text_modify(clicon_handle h, // int iamkey=0; if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL) goto done; + changed++; /* Copy xmlns attributes */ x1a = NULL; @@ -291,6 +284,7 @@ text_modify(clicon_handle h, } if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL) goto done; + changed++; /* Copy xmlns attributes */ x1a = NULL; while ((x1a = xml_child_each(x1, x1a, CX_ATTR)) != NULL) @@ -368,13 +362,15 @@ text_modify(clicon_handle h, } if (xml_purge(x0) < 0) goto done; + changed++; } break; default: break; } /* CONTAINER switch op */ } /* else Y_CONTAINER */ - xml_sort(x0p, NULL); + if (changed) + xml_sort(x0p, NULL); retval = 1; done: if (x0vec) @@ -671,7 +667,7 @@ xmldb_put(clicon_handle h, if (xml_tree_prune_flagged_sub(x0, XML_FLAG_NONE, 0, NULL) <0) goto done; if (xml_apply(x0, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, - (void*)XML_FLAG_NONE) < 0) + (void*)(XML_FLAG_NONE|XML_FLAG_MARK)) < 0) goto done; /* Mark non-presence containers that do not have children */ if (xml_apply(x0, CX_ELMNT, (xml_applyfn_t*)xml_container_presence, NULL) < 0) diff --git a/lib/src/clixon_nacm.c b/lib/src/clixon_nacm.c index 9060dc6a..61cb2895 100644 --- a/lib/src/clixon_nacm.c +++ b/lib/src/clixon_nacm.c @@ -882,7 +882,7 @@ nacm_access_pre(clicon_handle h, goto done; } else if (strcmp(mode, "internal")==0){ - if (xmldb_get(h, "running", "nacm", 0, &xnacm0, NULL) < 0) + if (xmldb_get(h, "running", "nacm", &xnacm0, NULL) < 0) goto done; } } diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 4043e66f..0679d7af 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -811,6 +811,7 @@ xml_find(cxobj *x_up, * @retval 0 OK * @retval -1 Error * @see xml_wrap + * @note xc is not sorted correctly, need to call xml_sort on parent */ int xml_addsub(cxobj *xp, @@ -1094,6 +1095,18 @@ xml_enumerate_children(cxobj *xp) return 0; } +/*! Reset enumeration as done by xml_enumerate_children + */ +int +xml_enumerate_reset(cxobj *xp) +{ + cxobj *x = NULL; + + while ((x = xml_child_each(xp, x, -1)) != NULL) + x->_x_i = 0; + return 0; +} + /*! Get the enumeration of a single child set by enumeration of parent * @see xml_children_enumerate * @note that it has to be called right after xml_children_enumerate. If not, diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 8a79bdac..97035d1b 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -1051,96 +1051,98 @@ cvec2xml_1(cvec *cvv, } /*! Recursive help function to compute differences between two xml trees - * @param[in] x1 First XML tree - * @param[in] x2 Second XML tree - * @param[out] x1vec Pointervector to XML nodes existing in only first tree - * @param[out] x1veclen Length of first vector - * @param[out] x2vec Pointervector to XML nodes existing in only second tree - * @param[out] x2veclen Length of x2vec vector - * @param[out] changed_x1 Pointervector to XML nodes changed orig value - * @param[out] changed_x2 Pointervector to XML nodes changed wanted value + * @param[in] x0 First XML tree + * @param[in] x1 Second XML tree + * @param[out] x0vec Pointervector to XML nodes existing in only first tree + * @param[out] x0veclen Length of first vector + * @param[out] x1vec Pointervector to XML nodes existing in only second tree + * @param[out] x1veclen Length of x1vec vector + * @param[out] changed_x0 Pointervector to XML nodes changed orig value + * @param[out] changed_x1 Pointervector to XML nodes changed wanted value * @param[out] changedlen Length of changed vector */ static int xml_diff1(yang_stmt *ys, - cxobj *x1, - cxobj *x2, + cxobj *x0, + cxobj *x1, + cxobj ***x0vec, + size_t *x0veclen, cxobj ***x1vec, size_t *x1veclen, - cxobj ***x2vec, - size_t *x2veclen, + cxobj ***changed_x0, cxobj ***changed_x1, - cxobj ***changed_x2, size_t *changedlen) { int retval = -1; + cxobj *x0c = NULL; /* x0 child */ cxobj *x1c = NULL; /* x1 child */ - cxobj *x2c = NULL; /* x2 child */ yang_stmt *yc; char *b1; char *b2; clicon_debug(2, "%s: %s", __FUNCTION__, ys->ys_argument?ys->ys_argument:"yspec"); - /* Check nodes present in x1 and x2 + nodes only in x1 - * Loop over x1 + /* Check nodes present in x0 and x1 + nodes only in x0 + * Loop over x0 * XXX: room for improvement. Compare with match_base_child() */ + x0c = NULL; + while ((x0c = xml_child_each(x0, x0c, CX_ELMNT)) != NULL){ + if ((yc = xml_spec(x0c)) == NULL){ + clicon_err(OE_UNIX, errno, "Unknown element: %s", xml_name(x0c)); + goto done; + } + /* Does x1 have a child matching x0c? */ + if (match_base_child(x1, x0c, yc, &x1c) < 0) + goto done; + if (x1c == NULL){ + if (cxvec_append(x0c, x0vec, x0veclen) < 0) + goto done; + } + else if (yang_choice(yc)){ + /* if x0c and x1c are choice/case, then they are changed */ + if (cxvec_append(x0c, changed_x0, changedlen) < 0) + goto done; + (*changedlen)--; /* append two vectors */ + if (cxvec_append(x1c, changed_x1, changedlen) < 0) + goto done; + } + else{ /* if x0c and x1c are leafs w bodies, then they are changed */ + if (yc->ys_keyword == Y_LEAF){ + if ((b1 = xml_body(x0c)) == NULL) /* empty type */ + break; + if ((b2 = xml_body(x1c)) == NULL) /* empty type */ + break; + if (strcmp(b1, b2)){ + if (cxvec_append(x0c, changed_x0, changedlen) < 0) + goto done; + (*changedlen)--; /* append two vectors */ + if (cxvec_append(x1c, changed_x1, changedlen) < 0) + goto done; + } + } + if (xml_diff1(yc, x0c, x1c, + x0vec, x0veclen, + x1vec, x1veclen, + changed_x0, changed_x1, changedlen)< 0) + goto done; + } + } /* while x0 */ + /* Check nodes present only in x1 + * Loop over x1 + */ x1c = NULL; while ((x1c = xml_child_each(x1, x1c, CX_ELMNT)) != NULL){ if ((yc = xml_spec(x1c)) == NULL){ clicon_err(OE_UNIX, errno, "Unknown element: %s", xml_name(x1c)); goto done; } - if (match_base_child(x2, x1c, yc, &x2c) < 0) + /* Does x0 have a child matching x1c? */ + if (match_base_child(x0, x1c, yc, &x0c) < 0) goto done; - if (x2c == NULL){ + if (x0c == NULL) if (cxvec_append(x1c, x1vec, x1veclen) < 0) goto done; - } - else if (yang_choice(yc)){ - /* if x1c and x2c are choice/case, then they are changed */ - if (cxvec_append(x1c, changed_x1, changedlen) < 0) - goto done; - (*changedlen)--; /* append two vectors */ - if (cxvec_append(x2c, changed_x2, changedlen) < 0) - goto done; - } - else{ /* if x1c and x2c are leafs w bodies, then they are changed */ - if (yc->ys_keyword == Y_LEAF){ - if ((b1 = xml_body(x1c)) == NULL) /* empty type */ - break; - if ((b2 = xml_body(x2c)) == NULL) /* empty type */ - break; - if (strcmp(b1, b2)){ - if (cxvec_append(x1c, changed_x1, changedlen) < 0) - goto done; - (*changedlen)--; /* append two vectors */ - if (cxvec_append(x2c, changed_x2, changedlen) < 0) - goto done; - } - } - if (xml_diff1(yc, x1c, x2c, - x1vec, x1veclen, - x2vec, x2veclen, - changed_x1, changed_x2, changedlen)< 0) - goto done; - } - } /* while x1 */ - /* Check nodes present only in x2 - * Loop over x2 - */ - x2c = NULL; - while ((x2c = xml_child_each(x2, x2c, CX_ELMNT)) != NULL){ - if ((yc = xml_spec(x2c)) == NULL){ - clicon_err(OE_UNIX, errno, "Unknown element: %s", xml_name(x2c)); - goto done; - } - if (match_base_child(x1, x2c, yc, &x1c) < 0) - goto done; - if (x1c == NULL) - if (cxvec_append(x2c, x2vec, x2veclen) < 0) - goto done; - } /* while x1 */ + } /* while x0 */ retval = 0; done: return retval; @@ -1148,28 +1150,28 @@ xml_diff1(yang_stmt *ys, /*! Compute differences between two xml trees * @param[in] yspec Yang specification - * @param[in] x1 First XML tree - * @param[in] x2 Second XML tree + * @param[in] x0 First XML tree + * @param[in] x1 Second XML tree * @param[out] first Pointervector to XML nodes existing in only first tree * @param[out] firstlen Length of first vector * @param[out] second Pointervector to XML nodes existing in only second tree * @param[out] secondlen Length of second vector - * @param[out] changed1 Pointervector to XML nodes changed orig value - * @param[out] changed2 Pointervector to XML nodes changed wanted value + * @param[out] changed_x0 Pointervector to XML nodes changed orig value + * @param[out] changed_x1 Pointervector to XML nodes changed wanted value * @param[out] changedlen Length of changed vector * All xml vectors should be freed after use. * Bot xml trees should be freed with xml_free() */ int xml_diff(yang_spec *yspec, - cxobj *x1, - cxobj *x2, + cxobj *x0, + cxobj *x1, cxobj ***first, size_t *firstlen, cxobj ***second, size_t *secondlen, - cxobj ***changed1, - cxobj ***changed2, + cxobj ***changed_x0, + cxobj ***changed_x1, size_t *changedlen) { int retval = -1; @@ -1177,22 +1179,22 @@ xml_diff(yang_spec *yspec, *firstlen = 0; *secondlen = 0; *changedlen = 0; - if (x1 == NULL && x2 == NULL) + if (x0 == NULL && x1 == NULL) return 0; - if (x2 == NULL){ - if (cxvec_append(x1, first, firstlen) < 0) - goto done; - goto ok; - } if (x1 == NULL){ - if (cxvec_append(x1, second, secondlen) < 0) + if (cxvec_append(x0, first, firstlen) < 0) goto done; goto ok; } - if (xml_diff1((yang_stmt*)yspec, x1, x2, + if (x0 == NULL){ + if (cxvec_append(x0, second, secondlen) < 0) + goto done; + goto ok; + } + if (xml_diff1((yang_stmt*)yspec, x0, x1, first, firstlen, second, secondlen, - changed1, changed2, changedlen) < 0) + changed_x0, changed_x1, changedlen) < 0) goto done; ok: retval = 0; @@ -1565,14 +1567,13 @@ xml_tree_prune_flagged_sub(cxobj *xt, return retval; } - /*! Prune everything that passes test * @param[in] xt XML tree with some node marked * @param[in] flag Which flag to test for * @param[in] test 1: test that flag is set, 0: test that flag is not set * The function removes all branches that does not pass test * @code - * xml_tree_prune_flagged(xt, XML_FLAG_MARK, 1, NULL); + * xml_tree_prune_flagged(xt, XML_FLAG_MARK, 1); * @endcode */ int @@ -1638,6 +1639,7 @@ xml_default(cxobj *xt, if (!xml_find(xt, y->ys_argument)){ if ((xc = xml_new(y->ys_argument, xt, y)) == NULL) goto done; + xml_flag_set(xc, XML_FLAG_DEFAULT); if ((xb = xml_new("body", xc, NULL)) == NULL) goto done; xml_type_set(xb, CX_BODY); @@ -1652,7 +1654,7 @@ xml_default(cxobj *xt, } } } - // xml_sort(xt, NULL); + xml_sort(xt, NULL); retval = 0; done: return retval; diff --git a/lib/src/clixon_xml_sort.c b/lib/src/clixon_xml_sort.c index 99f1d474..04a9841d 100644 --- a/lib/src/clixon_xml_sort.c +++ b/lib/src/clixon_xml_sort.c @@ -76,7 +76,6 @@ */ static int xml_cv_cache(cxobj *x, - char *body, cg_var **cvp) { int retval = -1; @@ -88,11 +87,13 @@ xml_cv_cache(cxobj *x, char *reason=NULL; int options = 0; uint8_t fraction = 0; - + char *body; + + body = xml_body(x); if ((cv = xml_cv(x)) != NULL) goto ok; if ((y = xml_spec(x)) == NULL) - goto done; + goto ok; if (yang_type_get(y, NULL, &yrestype, &options, NULL, NULL, &fraction) < 0) goto done; yang2cv_type(yrestype->ys_argument, &cvtype); @@ -186,24 +187,21 @@ xml_child_spec(cxobj *x, return retval; } -/*! Help function to qsort for sorting entries in xml child vector - * @param[in] arg1 - actually cxobj** - * @param[in] arg2 - actually cxobj** +/*! Help function to qsort for sorting entries in xml child vector same parent + * @param[in] xml object 1 + * @param[in] xml object 2 * @retval 0 If equal - * @retval <0 if arg1 is less than arg2 - * @retval >0 if arg1 is greater than arg2 - * @note args are pointer ot pointers, to fit into qsort cmp function + * @retval <0 if x1 is less than x2 + * @retval >0 if x1 is greater than x2 * @see xml_cmp1 Similar, but for one object * @note empty value/NULL is smallest value * @note xml_enumerate_children must have been called prior to this call * @note some error cases return as -1 (qsort cant handle errors) */ static int -xml_cmp(const void* arg1, - const void* arg2) +xml_cmp(cxobj *x1, + cxobj *x2) { - cxobj *x1 = *(struct xml**)arg1; - cxobj *x2 = *(struct xml**)arg2; yang_stmt *y1; yang_stmt *y2; int yi1 = 0; @@ -242,7 +240,6 @@ xml_cmp(const void* arg1, equal = 1; goto done; } - e=2; if (y1 != y2){ yi1 = yang_order(y1); @@ -268,9 +265,9 @@ xml_cmp(const void* arg1, else if ((b2 = xml_body(x2)) == NULL) equal = 1; else{ - if (xml_cv_cache(x1, b1, &cv1) < 0) /* error case */ + if (xml_cv_cache(x1, &cv1) < 0) /* error case */ goto done; - if (xml_cv_cache(x2, b2, &cv2) < 0) /* error case */ + if (xml_cv_cache(x2, &cv2) < 0) /* error case */ goto done; equal = cv_cmp(cv1, cv2); } @@ -283,15 +280,15 @@ xml_cmp(const void* arg1, while ((cvi = cvec_each(cvk, cvi)) != NULL) { keyname = cv_string_get(cvi); /* operational data may have NULL keys*/ if ((x1b = xml_find(x1, keyname)) == NULL || - (b1 = xml_body(x1b)) == NULL) + xml_body(x1b) == NULL) equal = -1; else if ((x2b = xml_find(x2, keyname)) == NULL || - (b2 = xml_body(x2b)) == NULL) + xml_body(x2b) == NULL) equal = 1; else{ - if (xml_cv_cache(x1b, b1, &cv1) < 0) /* error case */ + if (xml_cv_cache(x1b, &cv1) < 0) /* error case */ goto done; - if (xml_cv_cache(x2b, b2, &cv2) < 0) /* error case */ + if (xml_cv_cache(x2b, &cv2) < 0) /* error case */ goto done; if ((equal = cv_cmp(cv1, cv2)) != 0) goto done; @@ -308,6 +305,16 @@ xml_cmp(const void* arg1, return equal; } +/*! + * @note args are pointer ot pointers, to fit into qsort cmp function + */ +static int +xml_cmp_qsort(const void* arg1, + const void* arg2) +{ + return xml_cmp(*(struct xml**)arg1, *(struct xml**)arg2); +} + /*! Compare xml object * @param[in] x XML node to compare with * @param[in] y The yang spec of x @@ -331,13 +338,16 @@ xml_cmp1(cxobj *x, int keynr, char **keyvec, char **keyval, + cg_var **keycvec, int *userorder) { char *b; + cxobj *xb; int i; char *keyname; char *key; int match = 0; + cg_var *cv; /* state data = userorder */ if (userorder && yang_config(y)==0) @@ -353,8 +363,15 @@ xml_cmp1(cxobj *x, *userorder=1; if ((b=xml_body(x)) == NULL) match = 1; - else - match = strcmp(keyval[0], b); + else{ + if (keycvec[0]){ + if (xml_cv_cache(x, &cv) < 0) /* error case */ + goto done; + match = cv_cmp(keycvec[0], cv); + } + else + match = strcmp(keyval[0], b); + } break; case Y_LIST: /* Match with array of key values */ if (userorder && yang_find((yang_node*)y, Y_ORDERED_BY, "user") != NULL) @@ -363,21 +380,29 @@ xml_cmp1(cxobj *x, for (i=0; ie0 given "name" */ - if ((b = xml_find_body(x, keyname)) == NULL) + if ((xb = xml_find(x, keyname)) == NULL) break; /* error case */ - if ((match = strcmp(key, b)) != 0) - break; + if ((b = xml_body(xb)) == NULL) + break; /* error case */ + if (xml_cv_cache(xb, &cv) < 0) /* error case */ + goto done; + if (keycvec[i]){ + if ((match = cv_cmp(keycvec[i], cv)) != 0) + break; + } + else + if ((match = strcmp(key, b)) != 0) + break; } break; default: break; } - // done: - return match; /* should not reach here */ + done: + return match; } -/*! Sort children of an XML node +/*! Sort children of an XML node * Assume populated by yang spec. * @param[in] x0 XML node * @param[in] arg Dummy so it can be called by xml_apply() @@ -396,7 +421,7 @@ xml_sort(cxobj *x, if ((ys = xml_spec(x)) != 0 && yang_config(ys)==0) return 1; xml_enumerate_children(x); - qsort(xml_childvec_get(x), xml_child_nr(x), sizeof(cxobj *), xml_cmp); + qsort(xml_childvec_get(x), xml_child_nr(x), sizeof(cxobj *), xml_cmp_qsort); return 0; } @@ -411,7 +436,8 @@ xml_search_userorder(cxobj *x0, enum rfc_6020 keyword, int keynr, char **keyvec, - char **keyval) + char **keyval, + cg_var **keycvec) { int i; cxobj *xc; @@ -421,7 +447,7 @@ xml_search_userorder(cxobj *x0, y = xml_spec(xc); if (yangi!=yang_order(y)) break; - if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, NULL) == 0) + if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, keycvec, NULL) == 0) return xc; } for (i=mid-1; i>=0; i--){ /* Then decrement */ @@ -429,7 +455,7 @@ xml_search_userorder(cxobj *x0, y = xml_spec(xc); if (yangi!=yang_order(y)) break; - if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, NULL) == 0) + if (xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, keycvec, NULL) == 0) return xc; } return NULL; /* Not found */ @@ -451,6 +477,7 @@ xml_search1(cxobj *x0, int keynr, char **keyvec, char **keyval, + cg_var **keycvec, int low, int upper) { @@ -469,42 +496,53 @@ xml_search1(cxobj *x0, if ((y = xml_spec(xc)) == NULL) return NULL; cmp = yangi-yang_order(y); + /* Here is right yang order == same yang? */ if (cmp == 0){ - cmp = xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, &userorder); + cmp = xml_cmp1(xc, y, name, keyword, keynr, keyvec, keyval, keycvec, &userorder); if (userorder && cmp) /* Look inside this yangi order */ - return xml_search_userorder(x0, y, name, yangi, mid, keyword, keynr, keyvec, keyval); + return xml_search_userorder(x0, y, name, yangi, mid, keyword, keynr, keyvec, keyval, keycvec); } if (cmp == 0) return xc; else if (cmp < 0) return xml_search1(x0, name, yangi, keyword, - keynr, keyvec, keyval, low, mid-1); + keynr, keyvec, keyval, keycvec, low, mid-1); else return xml_search1(x0, name, yangi, keyword, - keynr, keyvec, keyval, mid+1, upper); + keynr, keyvec, keyval, keycvec, mid+1, upper); return NULL; } /*! Find XML children using binary search * @param[in] yangi yang child order - * @param[in] keynr Length of keyvec/keyval vector when applicable - * @param[in] keyvec Array of of yang key identifiers - * @param[in] keyval Array of of yang key values + * @param[in] keynr Length of keyvec/keyval vector when applicable + * @param[in] keyvec Array of of yang key identifiers + * @param[in] keyval Array of of yang key values */ -cxobj * +static cxobj * xml_search(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, - char **keyval) + char **keyval, + cg_var **keycvec) { - return xml_search1(x0, name, yangi, keyword, keynr, keyvec, keyval, - 0, xml_child_nr(x0)); + cxobj *xa; + int low = 0; + int high = xml_child_nr(x0); + + /* Assume if there are any attributes, they are first in the list, mask + them by raising low to skip them */ + for (low=0; lowkeyword, name - * list: x0, y->keyword, y->key, name - * - * The function needs a vector of key values (or single for LEAF_LIST). - * What format? - * 1) argc/argv:: "val1","val2" <<== - * 2) cv-list? - * 3) va-list? - * - * yc - LIST (interface) - - * ^ - * | - * x0-->x0c-->(name=interface)+->x(name=name)->xb(value="eth0") <==this is - * | - * v - * x1c->name (interface) - * x1c->x(name=name)->xb(value="eth0") - * - * CONTAINER:name - * LEAF: name - * LEAFLIST: name/body... #b0 - * LIST: name/key0/key1... #b2vec+b0 -> x0c - - * eth0 - * eth1 - * eth2 - * @param[in] x0 XML node. Find child of this node. - * @param[in] keyword Yang keyword. Relevant: container, list, leaf, leaf_list - * @param[in] keynr Length of keyvec/keyval vector when applicable - * @param[in] keyvec Array of of yang key identifiers - * @param[in] keyval Array of of yang key values - * @param[out] xp Return value on success, pointer to XML child node - * @note If keyword is: - * - list, keyvec and keyval should be an array with keynr length - * - leaf_list, keyval should be 1 and keyval should contain one element - * - otherwise, keyval should be 0 and keyval and keyvec should be both NULL. - */ -cxobj * -xml_match(cxobj *x0, - char *name, - enum rfc_6020 keyword, - int keynr, - char **keyvec, - char **keyval) -{ - char *key; - char *keyname; - char *b0; - cxobj *x = NULL; - int equal; - int i; - - x = NULL; - switch (keyword){ - case Y_CONTAINER: /* Match with name */ - case Y_LEAF: /* Match with name */ - if (keynr != 0){ - clicon_err(OE_XML, EINVAL, "Expected no key argument to CONTAINER or LEAF"); - goto ok; - } - x = xml_find(x0, name); - break; - case Y_LEAF_LIST: /* Match with name and value */ - if (keynr != 1) - goto ok; - x = xml_find_body_obj(x0, name, keyval[0]); - break; - case Y_LIST: /* Match with array of key values */ - i = 0; - while ((x = xml_child_each(x0, x, CX_ELMNT)) != NULL){ - equal = 0; - if (strcmp(xml_name(x), name)) - continue; - /* Must be inner loop */ - for (i=0; i 0) + if (xml_cmp(xprev, x) > 0) goto done; } xprev = x; @@ -711,10 +654,12 @@ match_base_child(cxobj *x0, cvec *cvk = NULL; /* vector of index keys */ cg_var *cvi; char *b; + cxobj *xb; char *keyname; char keynr = 0; char **keyval = NULL; char **keyvec = NULL; + cg_var **keycvec = NULL; int i; int yorder; cxobj *x0c = NULL; @@ -735,7 +680,6 @@ match_base_child(cxobj *x0, y0p == yp) break; /* x0c will have a value */ } - *x0cp = x0c; goto ok; /* What to do if not found? */ } switch (yc->ys_keyword){ @@ -750,6 +694,12 @@ match_base_child(cxobj *x0, } if ((keyval[0] = xml_body(x1c)) == NULL) goto ok; + if ((keycvec = calloc(keynr+1, sizeof(cg_var*))) == NULL){ + clicon_err(OE_UNIX, errno, "calloc"); + goto done; + } + if (xml_cv_cache(x1c, &keycvec[0]) < 0) /* error case */ + goto done; break; case Y_LIST: /* Match with key values */ cvk = yc->ys_cvec; /* Use Y_LIST cache, see ys_populate_list() */ @@ -768,34 +718,44 @@ match_base_child(cxobj *x0, clicon_err(OE_UNIX, errno, "calloc"); goto done; } + if ((keycvec = calloc(keynr+1, sizeof(char*))) == NULL){ + clicon_err(OE_UNIX, errno, "calloc"); + goto done; + } cvi = NULL; i = 0; while ((cvi = cvec_each(cvk, cvi)) != NULL) { keyname = cv_string_get(cvi); keyvec[i] = keyname; - if ((b = xml_find_body(x1c, keyname)) == NULL) - goto ok; /* not found */ - keyval[i++] = b; + if ((xb = xml_find(x1c, keyname)) == NULL) + goto ok; + if ((b = xml_body(xb)) == NULL) + goto ok; + // if ((b = xml_find_body(x1c, keyname)) == NULL) + // goto ok; /* not found */ + keyval[i] = b; + if (xml_cv_cache(xb, &keycvec[i]) < 0) /* error case */ + goto done; + i++; } break; default: break; } - /* Get match. Sorting mode(optimized) or not?*/ - if (xml_child_nr(x0)==0 || xml_spec(xml_child_i(x0,0))!=NULL){ - yorder = yang_order(yc); - x0c = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval); - } - else{ - x0c = xml_match(x0, xml_name(x1c), yc->ys_keyword, keynr, keyvec, keyval); - } - *x0cp = x0c; + /* Get match. Sorting mode(optimized) or not? + * This conditional is a mystery , but test_yang_namespace.sh breaks if set to (0) + */ + yorder = yang_order(yc); + x0c = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval, keycvec); ok: + *x0cp = x0c; retval = 0; done: if (keyval) free(keyval); if (keyvec) free(keyvec); + if (keycvec) + free(keycvec); return retval; } diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 9be09da2..a2854d3d 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -839,9 +839,9 @@ xp_union(xp_ctx *xc1, * @param[out] xrp Resulting context */ static int -xp_eval(xp_ctx *xc, +xp_eval(xp_ctx *xc, xpath_tree *xs, - xp_ctx **xrp) + xp_ctx **xrp) { int retval = -1; diff --git a/test/long.sh b/test/long.sh index 3db6b391..55191fe7 100755 --- a/test/long.sh +++ b/test/long.sh @@ -51,7 +51,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile false /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false EOF diff --git a/test/plot_perf.sh b/test/plot_perf.sh index c5eaaa98..dc565817 100755 --- a/test/plot_perf.sh +++ b/test/plot_perf.sh @@ -42,7 +42,6 @@ cat < $cfg /usr/local/var/routing/routing.pidfile false /usr/local/var/routing - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_augment.sh b/test/test_augment.sh index 9ae6ea60..b7302270 100755 --- a/test/test_augment.sh +++ b/test/test_augment.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/test/test_choice.sh b/test/test_choice.sh index f1d5192f..6e08feb9 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_cli.sh b/test/test_cli.sh index fe894be1..9030e6ed 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -32,7 +32,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_cli_history.sh b/test/test_cli_history.sh index 22591c66..c6700496 100755 --- a/test/test_cli_history.sh +++ b/test/test_cli_history.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_copy_config.sh b/test/test_copy_config.sh index f9e08e31..ee1d60d1 100755 --- a/test/test_copy_config.sh +++ b/test/test_copy_config.sh @@ -47,7 +47,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 $dir - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_feature.sh b/test/test_feature.sh index d3145263..5bf5997a 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -41,7 +41,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/test/test_identity.sh b/test/test_identity.sh index 0a60d67c..d2ae40cf 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -26,7 +26,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_leafref.sh b/test/test_leafref.sh index a596a4f7..1c8f7eae 100755 --- a/test/test_leafref.sh +++ b/test/test_leafref.sh @@ -23,7 +23,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_list.sh b/test/test_list.sh index b43b4d95..7709c074 100755 --- a/test/test_list.sh +++ b/test/test_list.sh @@ -22,7 +22,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_nacm.sh b/test/test_nacm.sh index d919d775..b7b914ae 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false internal diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index 042b6488..5048a1e3 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -32,7 +32,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false external $nacmfile diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index dbb27a24..8204b6a4 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -44,7 +44,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false internal @@ -125,7 +124,7 @@ RULES=$(cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false internal diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index 2e38f83c..a6af2124 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -49,7 +49,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false internal diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 266c31a2..9738345d 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh index 387b25c9..370b8b36 100755 --- a/test/test_openconfig.sh +++ b/test/test_openconfig.sh @@ -72,7 +72,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/test/test_order.sh b/test/test_order.sh index 05f564ae..82171613 100755 --- a/test/test_order.sh +++ b/test/test_order.sh @@ -37,7 +37,6 @@ cat < $cfg /usr/local/lib/example/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dbdir - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_perf.sh b/test/test_perf.sh index 9e703236..596d7b70 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -49,7 +49,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile false /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so false EOF diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 913216ae..f916952a 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -28,7 +28,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index 770c87f4..543a9799 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -21,7 +21,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock $dir/restconf.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_rpc.sh b/test/test_rpc.sh index 989c6f9f..3c2a44ee 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_startup.sh b/test/test_startup.sh index 4a7835d3..9457e4ea 100755 --- a/test/test_startup.sh +++ b/test/test_startup.sh @@ -29,7 +29,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - /usr/local/lib/xmldb/text.so 0 init false diff --git a/test/test_stream.sh b/test/test_stream.sh index 64f14d76..670199eb 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -45,7 +45,6 @@ cat < $cfg example_backend.so$ $dir/restconf.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME diff --git a/test/test_type.sh b/test/test_type.sh index 3b5935db..132e6a59 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -25,8 +25,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so - false + true EOF @@ -235,7 +234,7 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "cli set transitive union int" +new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 33" 0 "^$" new "cli validate" diff --git a/test/test_type_nocache.sh b/test/test_type_nocache.sh new file mode 100755 index 00000000..95a0e9af --- /dev/null +++ b/test/test_type_nocache.sh @@ -0,0 +1,588 @@ +#!/bin/bash +# Advanced union types and generated code +# and enum w values +# @see test_type.sh ONLY DIFFERENCE IS db-cache is OFF here + +# Magic line must be first in script (see README.md) +s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi + +APPNAME=example + +cfg=$dir/conf_yang.xml +fyang=$dir/type.yang +fyang2=$dir/example2.yang +fyang3=$dir/example3.yang + +cat < $cfg + + $cfg + $dir + /usr/local/share/clixon + $IETFRFC + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/cli + $APPNAME + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/var/$APPNAME/$APPNAME.pidfile + 1 + /usr/local/var/$APPNAME + false + +EOF + +# transitive type, exists in fyang3, referenced from fyang2, but not declared in fyang +cat < $fyang3 +module example3{ + prefix ex3; + namespace "urn:example:example3"; + typedef w{ + type union{ + type int32{ + range "4..44"; + } + } + } + typedef u{ + type union { + type w; + type enumeration { + enum "bounded"; + enum "unbounded"; + } + } + } + typedef t{ + type string{ + pattern '[a-z][0-9]*'; + } + } +} +EOF +cat < $fyang2 +module example2{ + import example3 { prefix ex3; } + namespace "urn:example:example2"; + prefix ex2; + grouping gr2 { + leaf talle{ + type ex3:t; + } + leaf ulle{ + type ex3:u; + } + } +} +EOF +cat < $fyang +module example{ + yang-version 1.1; + namespace "urn:example:clixon"; + prefix ex; + import example2 { prefix ex2; } + typedef ab { + type string { + pattern + '(([a-b])\.){3}[a-b]'; + } + } + typedef cd { + type string { + pattern + '(([c-d])\.){3}[c-d]'; + } + } + typedef ef { + type string { + pattern + '(([e-f])\.){3}[e-f]'; + length "1..253"; + } + } + typedef ad { + type union { + type ab; + type cd; + } + } + typedef af { + type union { + type ad; + type ef; + } + } + list list { + key ip; + leaf ip { + type af; + } + } + leaf status { + type enumeration { + enum up { + value 1; + } + enum down; + } + } + leaf num1 { + type int32 { + range "1"; + } + } + leaf num2 { /* range and blanks */ + type int32 { + range " 4 .. 4000 "; + } + } + leaf num3 { + type uint8 { + range "min..max"; + } + } + leaf num4 { + type uint8 { + range "1..2 | 42..50"; + } + } + leaf dec { + /* For test of multiple ranges with decimal64. More than 2, single range*/ + type decimal64 { + fraction-digits 3; + range "-3.5..-2.5 | 0.0 | 10.0..20.0"; + } + } + leaf len1 { + type string { + length "2"; + } + } + leaf len2 { + type string { + length " 4 .. 4000 "; + } + } + leaf len3 { + type string { + length "min..max"; + } + } + leaf len4 { + type string { + length "2 .. 3 | 20..29"; + } + } + typedef mybits { + description "Test adding several bits"; + type bits { + bit create; + bit read; + bit write; + } + } + leaf mbits{ + type mybits; + } + container c{ + description "transitive type- exists in ex3"; + uses ex2:gr2; + } + leaf digit4{ + type string { + pattern '\d{4}'; + } + } + leaf word4{ + type string { + pattern '\w{4}'; + } + } + leaf minus{ + description "Problem with minus"; + type string{ + pattern '[a-zA-Z_][a-zA-Z0-9_\-.]*'; + } + } +} +EOF + +new "test params: -f $cfg -y $fyang" + +if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend -s init -f $cfg -y $fyang" + start_backend -s init -f $cfg -y $fyang + + new "waiting" + sleep $RCWAIT +fi + +new "cli set transitive string. type is alpha followed by number and is defined in three levels of modules" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c talle x99" 0 "^$" + +new "cli set transitive string error. Wrong type" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c talle 9xx" 255 "^$" + +new "netconf set transitive string error" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '9xx]]>]]>' "^]]>]]>" + +new "netconf validate should fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementtalleerrorregexp match fail: "9xx" does not match \[a-z\]\[0-9\]\*]]>]]>$' + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 33" 0 "^$" + +new "cli validate" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 "^$" + +new "cli set transitive union string" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle unbounded" 0 "^$" + +new "cli validate" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 "^$" + +new "cli set transitive union error. should fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle kalle" 255 "" + +new "cli set transitive union error int" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 55" 255 "" + +new "netconf set transitive union error int" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '55]]>]]>' "^]]>]]>" + +new "netconf validate should fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#----------- + +new "cli set ab" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.a.b" 0 "^$" + +new "cli set cd" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list c.d.c.d" 0 "^$" + +new "cli set ef" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list e.f.e.f" 0 "^$" + +new "cli set ab fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a&b&a&b" 255 "^CLI syntax error" + +new "cli set ad fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.c.d" 255 "^CLI syntax error" + +new "cli validate" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 "^$" + +new "cli commit" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o commit" 0 "^$" + +new "netconf validate ok" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +new "netconf set ab wrong" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'a.b& c.d]]>]]>' "^]]>]]>$" + +new "netconf validate" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^" + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +new "netconf commit" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +new "cli enum value" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set status down" 0 "^$" + +new "cli bits value" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits create" 0 "^$" + +#XXX No, cli cant assign two bit values +#new "cli bits two values" +#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits \"create read\"" 0 "^$" + +new "netconf bits two values" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'create read]]>]]>' "^]]>]]>$" + +new "cli bits validate" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 "^$" + +#-------- num1 single range (1) + +new "cli range test num1 1 OK" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 1" 0 "^$" + +#new "cli range test num1 -100 ok" # XXX -/minus cant be given as argv +#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 \-100" 0 "^$" + +new "cli range test num1 2 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 2" 255 "^$" + +new "netconf range set num1 -1" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-1]]>]]>' "^]]>]]>$" + +new "netconf validate num1 -1 wrong" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum1errorNumber out of range: -1]]>]]>$' + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#-------- num2 range and blanks + +new "cli range test num2 3 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 3" 255 "^$" + +new "cli range test num2 1000 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 1000" 0 "^$" + +new "cli range test num2 5000 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 5000" 255 "^$" + +new "netconf range set num2 3 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '3]]>]]>' "^]]>]]>$" + +new "netconf validate num2 3 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 3]]>]]>$' + +new "netconf range set num2 1000 ok" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '1000]]>]]>' "^]]>]]>$" + +new "netconf validate num2 1000 ok" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + +new "netconf range set num2 5000 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '5000]]>]]>' "^]]>]]>$" + +new "netconf validate num2 5000 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 5000]]>]]>$' + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#-------- num3 min max range + +new "cli range test num3 42 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 42" 0 "^$" + +new "cli range test num3 260 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 260" 255 "^$" + +new "cli range test num3 -1 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 -1" 255 "^$" + +new "netconf range set num3 260 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '260]]>]]>' "^]]>]]>$" + +new "netconf validate num3 260 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum3error260 is out of range(type is uint8)]]>]]>$' + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#-------- num4 multiple ranges 1..2 | 42..50 + +new "cli range test num4 multiple 0 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 0" 255 "^$" + +new "cli range test num4 multiple 2 ok" +expectfn "$clixon_cli -1f $cfg -l e -y $fyang set num4 2" 0 "^$" + +new "cli range test num4 multiple 20 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 20" 255 "^$" + +new "cli range test num4 multiple 42 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 42" 0 "^$" + +new "cli range test num4 multiple 99 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 99" 255 "^$" + +new "netconf range set num4 multiple 2" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" + +new "netconf validate num4 OK" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + +new "netconf range set num4 multiple 20" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" + +new "netconf validate num4 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + +new "netconf range set num4 multiple 42" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" + +new "netconf validate num4 fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#-------- dec64 multiple ranges -3.5..-2.5 | 0.0 | 10.0..20.0 +# XXX how to enter negative numbers in bash string and cli -1? +new "cli range dec64 multiple 0 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 0" 0 "^$" + +new "cli range dec64 multiple 0.1 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 0.1" 255 "^$" + +new "cli range dec64 multiple 15.0 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 15.0" 0 "^$" + +new "cli range dec64 multiple 30.0 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 30.0" 255 "^$" + +new "dec64 discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +# Same with netconf +new "netconf range dec64 -3.59" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.59]]>]]>' "^]]>]]>$" + +new "netconf range dec64 -3.59 validate fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + +new "netconf range dec64 -3.5" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.500]]>]]>' "^]]>]]>$" + +new "netconf range dec64 -3.5 validate ok" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + +new "netconf range dec64 -2" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-2]]>]]>' "^]]>]]>$" + +new "netconf range dec64 -2 validate fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + +new "netconf range dec64 -0.001" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-0.001]]>]]>' "^]]>]]>$" + +new "netconf range dec64 -0.001 validate fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + +new "netconf range dec64 0.0" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '0.0]]>]]>' "^]]>]]>$" + +new "netconf range dec64 0.0 validate ok" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + +new "netconf range dec64 +0.001" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '+0.001]]>]]>' "^]]>]]>$" + +new "netconf range dec64 +0.001 validate fail" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + +#----------------string ranges--------------------- +#-------- len1 single range (2) +new "cli length test len1 1 fail" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 x" 255 "^$" + +new "cli length test len1 2 OK" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 xy" 0 "^$" + +new "cli length test len1 3 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 hej" 255 "^$" + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +new "netconf length set len1 1" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$" + +new "netconf validate len1 1 wrong" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementlen1errorstring length out of range: 1]]>]]>$' + +#-------- len2 range and blanks + +new "cli length test len2 3 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 ab" 255 "^$" + +new "cli length test len2 42 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 "^$" + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#-------- len3 min max range + +new "cli range ptest len3 42 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len3 hsakjdhkjsahdkjsahdksahdksajdhsakjhd" 0 "^$" + +#-------- len4 multiple ranges 2..3 | 20-29 +new "cli length test len4 1 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 a" 255 "^$" + +new "cli length test len4 2 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 ab" 0 "^$" + +new "cli length test len4 10 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghij" 255 "^$" + +new "cli length test len4 20 ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghija" 0 "^$" + +new "cli length test len4 30 error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghijabcdefghij" 255 "^$" + +# XSD schema -> POSIX ECE translation +new "cli yang pattern \d ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 0123" 0 "^$" + +new "cli yang pattern \d error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 01b2" 255 "^$" + +new "cli yang pattern \w ok" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 abc9" 0 "^$" + +new "cli yang pattern \w error" +expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 ab%3" 255 "^$" + +new "netconf pattern \w" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'aXG9]]>]]>' "^]]>]]>$" + +new "netconf pattern \w valid" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" + +new "netconf pattern \w error" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'ab%d3]]>]]>' "^]]>]]>$" + +new "netconf pattern \w valid" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' '^applicationbad-elementword4errorregexp match fail: "ab%d3" does not match \\w{4}]]>]]>$' + +new "netconf discard-changes" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + + +#------ minus + +new "type with minus" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'my-name]]>]]>' "^]]>]]>$" + +new "validate minus" +expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + +#new "cli type with minus" +#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set name my-name" 0 "^$" + +if [ $BE -eq 0 ]; then + exit # BE +fi + +new "Kill backend" +# Check if premature kill +pid=`pgrep -u root -f clixon_backend` +if [ -z "$pid" ]; then + err "backend already dead" +fi +# kill backend +stop_backend -f $cfg + +rm -rf $dir diff --git a/test/test_union.sh b/test/test_union.sh index a2d2bf46..01ef82e7 100755 --- a/test/test_union.sh +++ b/test/test_union.sh @@ -25,7 +25,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_upgrade.sh b/test/test_upgrade.sh index b143dc73..d33dbaf1 100755 --- a/test/test_upgrade.sh +++ b/test/test_upgrade.sh @@ -100,7 +100,6 @@ cat < $cfg /usr/local/lib/example/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - /usr/local/lib/xmldb/text.so true /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh index 50f52849..9827848f 100755 --- a/test/test_upgrade_auto.sh +++ b/test/test_upgrade_auto.sh @@ -179,7 +179,6 @@ cat < $cfg /usr/local/lib/example/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - /usr/local/lib/xmldb/text.so true true $changelog diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh index 3bb2ed7f..2ec3b230 100755 --- a/test/test_upgrade_interfaces.sh +++ b/test/test_upgrade_interfaces.sh @@ -239,7 +239,6 @@ cat < $cfg /usr/local/lib/example/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - /usr/local/lib/xmldb/text.so true false /usr/local/lib/$APPNAME/clispec diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh index 27f3e072..c6cc4dda 100755 --- a/test/test_upgrade_repair.sh +++ b/test/test_upgrade_repair.sh @@ -63,7 +63,6 @@ cat < $cfg /usr/local/lib/example/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - /usr/local/lib/xmldb/text.so true /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli diff --git a/test/test_when_must.sh b/test/test_when_must.sh index 1c65bde3..d4cbc0ea 100755 --- a/test/test_when_must.sh +++ b/test/test_when_must.sh @@ -22,7 +22,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_yang.sh b/test/test_yang.sh index a4b67cf9..b61ca9a1 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -24,7 +24,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/test/test_yang_load.sh b/test/test_yang_load.sh index ad772be6..19c826d5 100755 --- a/test/test_yang_load.sh +++ b/test/test_yang_load.sh @@ -67,7 +67,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME @@ -122,7 +121,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME @@ -172,7 +170,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF @@ -217,7 +214,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF @@ -262,7 +258,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF @@ -309,7 +304,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF @@ -355,7 +349,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF @@ -402,7 +395,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so EOF diff --git a/test/test_yangmodels.sh b/test/test_yang_models.sh similarity index 98% rename from test/test_yangmodels.sh rename to test/test_yang_models.sh index 9acfc191..a6198231 100755 --- a/test/test_yangmodels.sh +++ b/test/test_yang_models.sh @@ -46,7 +46,6 @@ cat < $cfg 1 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index 13877e2d..d5c925eb 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -27,7 +27,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME - /usr/local/lib/xmldb/text.so true EOF diff --git a/util/clixon_util_datastore.c b/util/clixon_util_datastore.c index 3f62efdd..4ba6558a 100644 --- a/util/clixon_util_datastore.c +++ b/util/clixon_util_datastore.c @@ -184,7 +184,7 @@ main(int argc, char **argv) xpath = argv[1]; else xpath = "/"; - if (xmldb_get(h, db, xpath, 0, &xt, NULL) < 0) + if (xmldb_get(h, db, xpath, &xt, NULL) < 0) goto done; clicon_xml2file(stdout, xt, 0, 0); @@ -200,7 +200,7 @@ main(int argc, char **argv) else xpath = "/"; for (i=0;i