summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-07-04 13:10:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-07-04 13:10:38 +0000
commit3067aaa83148eaf7afce0435d63ef5793b724599 (patch)
tree6b07933e669900fb9b9bf5fff0464a9486cba225
parentReleasing progress-linux version 1.2.0-1~dschinn1. (diff)
downloadlibheif-3067aaa83148eaf7afce0435d63ef5793b724599.zip
libheif-3067aaa83148eaf7afce0435d63ef5793b724599.tar.xz
Merging upstream version 1.3.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.travis.yml34
-rw-r--r--Makefile.in14
-rw-r--r--README.md16
-rw-r--r--aclocal.m446
-rwxr-xr-xconfig.guess679
-rwxr-xr-xconfig.sub284
-rwxr-xr-xconfigure39
-rw-r--r--configure.ac18
-rwxr-xr-xdepcomp6
-rw-r--r--examples/Makefile.am9
-rw-r--r--examples/Makefile.in103
-rw-r--r--examples/heif_enc.cc143
-rw-r--r--examples/test_c_api.c29
-rw-r--r--extra/Makefile.in6
-rw-r--r--gnome/Makefile.in6
-rw-r--r--go/Makefile.in6
-rw-r--r--libheif.pc.in4
-rw-r--r--libheif/Makefile.am2
-rw-r--r--libheif/Makefile.in9
-rw-r--r--libheif/bitstream.cc234
-rw-r--r--libheif/bitstream.h185
-rw-r--r--libheif/box.cc125
-rw-r--r--libheif/box.h8
-rw-r--r--libheif/box_fuzzer.cc8
-rw-r--r--libheif/heif.cc183
-rw-r--r--libheif/heif.h126
-rw-r--r--libheif/heif_context.cc326
-rw-r--r--libheif/heif_context.h36
-rw-r--r--libheif/heif_cxx.h175
-rw-r--r--libheif/heif_emscripten.h142
-rw-r--r--libheif/heif_file.cc41
-rw-r--r--libheif/heif_file.h6
-rw-r--r--libheif/heif_plugin.h5
-rw-r--r--libheif/heif_plugin_registry.cc41
-rw-r--r--libheif/heif_plugin_registry.h2
-rw-r--r--libheif/heif_version.h4
-rw-r--r--ltmain.sh4
-rw-r--r--m4/libtool.m41
-rw-r--r--post.js10
-rw-r--r--scripts/Makefile.in6
-rwxr-xr-xscripts/install-ci-linux.sh10
-rwxr-xr-xscripts/prepare-ci.sh4
-rwxr-xr-xscripts/run-ci.sh9
43 files changed, 2133 insertions, 1011 deletions
diff --git a/.travis.yml b/.travis.yml
index 6aa3eda..fe02bb7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,19 +2,20 @@
# https://travis-ci.org/strukturag/libheif/
language: cpp
compiler:
- - gcc
- clang
+ - gcc
os:
- - linux
- osx
+ - linux
cache: ccache
sudo: required
addons:
apt:
update: true
env:
- - CHECK_LICENSES=1
- - CPPLINT=1
+ - EMSCRIPTEN_VERSION=1.37.26
+ - WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW32=1
+ - WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW64=1
- WITH_LIBDE265= WITH_X265= WITH_GRAPHICS=
- WITH_LIBDE265= WITH_X265= WITH_GRAPHICS=1
- WITH_LIBDE265= WITH_X265=1 WITH_GRAPHICS=
@@ -23,10 +24,10 @@ env:
- WITH_LIBDE265=2 WITH_X265= WITH_GRAPHICS=1
- WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1
- WITH_LIBDE265=2 WITH_X265=1 WITH_GRAPHICS=1
- - EMSCRIPTEN_VERSION=1.37.26
- WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1 TARBALL=1
- WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1 CMAKE=1
- - WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW64=1
+ - CHECK_LICENSES=1
+ - CPPLINT=1
matrix:
exclude:
@@ -36,13 +37,15 @@ matrix:
- compiler: clang
env: CPPLINT=1
- compiler: clang
+ env: WITH_LIBDE265= WITH_X265= WITH_GRAPHICS=1
+ - compiler: clang
env: WITH_LIBDE265= WITH_X265=1 WITH_GRAPHICS=
- compiler: clang
env: WITH_LIBDE265= WITH_X265=1 WITH_GRAPHICS=1
- compiler: clang
- env: WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1
+ env: WITH_LIBDE265=1 WITH_X265= WITH_GRAPHICS=1
- compiler: clang
- env: WITH_LIBDE265=2 WITH_X265=1 WITH_GRAPHICS=1
+ env: WITH_LIBDE265=2 WITH_X265= WITH_GRAPHICS=1
- compiler: clang
env: EMSCRIPTEN_VERSION=1.37.26
- compiler: clang
@@ -50,6 +53,8 @@ matrix:
- compiler: clang
env: WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1 CMAKE=1
- compiler: clang
+ env: WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW32=1
+ - compiler: clang
env: WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW64=1
# Don't build various targets on OSX.
- os: osx
@@ -67,13 +72,22 @@ matrix:
- os: osx
env: WITH_LIBDE265=2 WITH_X265= WITH_GRAPHICS=1
- os: osx
- env: WITH_LIBDE265=2 WITH_X265=1 WITH_GRAPHICS=1
- - os: osx
env: EMSCRIPTEN_VERSION=1.37.26
- os: osx
env: WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1 TARBALL=1
- os: osx
+ env: WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW32=1
+ - os: osx
env: WITH_LIBDE265= WITH_X265= WITH_GRAPHICS= MINGW64=1
+ - os: osx
+ compiler: clang
+ env: WITH_LIBDE265= WITH_X265= WITH_GRAPHICS=
+ - os: osx
+ compiler: clang
+ env: WITH_LIBDE265=1 WITH_X265=1 WITH_GRAPHICS=1
+ - os: osx
+ compiler: clang
+ env: WITH_LIBDE265=2 WITH_X265=1 WITH_GRAPHICS=1
before_install:
- ./scripts/install-ci-$TRAVIS_OS_NAME.sh
diff --git a/Makefile.in b/Makefile.in
index 5c61618..1867c15 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -344,6 +344,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -666,7 +668,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
@@ -692,7 +694,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
- shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
@@ -710,7 +712,7 @@ dist dist-all:
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
- GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
@@ -720,7 +722,7 @@ distcheck: dist
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
- GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
diff --git a/README.md b/README.md
index debbfc6..f793938 100644
--- a/README.md
+++ b/README.md
@@ -18,24 +18,28 @@ libheif has support for decoding
* tiled images
* alpha channels
* thumbnails
-* reading EXIF data
+* reading EXIF and XMP metadata
* reading the depth channel
-* multiple images in a HEIF file
+* multiple images in an HEIF file
* image transformations (crop, mirror, rotate)
* overlay images
* plugin interface to add decoders for additional formats (AVC, JPEG)
+* decoding of files while downloading (e.g. extract image size before file has been completely downloaded)
The encoder supports:
* lossy compression with adjustable quality
* lossless compression
* alpha channels
+* thumbnails
+* save multiple images to an HEIF file
+* save EXIF and XMP metadata
## API
The library has a C API for easy integration and wide language support.
Note that the API is still work in progress and may still change.
-Loading the primary image in a HEIF file is as easy as this:
+Loading the primary image in an HEIF file is as easy as this:
```C
heif_context* ctx = heif_context_alloc();
@@ -76,6 +80,12 @@ heif_context_write_to_file(context, "output.heic");
See the header file `heif.h` for the complete C API.
+There is also a C++ API which is a header-only wrapper to the C API.
+Hence, you can use the C++ API and still be binary compatible.
+Code using the C++ API is much less verbose than using the C API directly.
+
+There is also an experimental Go API, but this is not stable yet.
+
## Compiling
diff --git a/aclocal.m4 b/aclocal.m4
index 356f1c7..f533594 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.15 -*- Autoconf -*-
+# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -296,7 +296,7 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -311,7 +311,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.15], [],
+m4_if([$1], [1.15.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -327,14 +327,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.15])dnl
+[AM_AUTOMAKE_VERSION([1.15.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# Figure out how to run the assembler. -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -354,7 +354,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -406,7 +406,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
# AM_CONDITIONAL -*- Autoconf -*-
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -437,7 +437,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -628,7 +628,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -704,7 +704,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -901,7 +901,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -922,7 +922,7 @@ if test x"${install_sh+set}" != xset; then
fi
AC_SUBST([install_sh])])
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -943,7 +943,7 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -993,7 +993,7 @@ rm -f confinc confmf
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1032,7 +1032,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*-
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1061,7 +1061,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1108,7 +1108,7 @@ AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1127,7 +1127,7 @@ AC_DEFUN([AM_RUN_LOG],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1208,7 +1208,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1268,7 +1268,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1296,7 +1296,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -1315,7 +1315,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
diff --git a/config.guess b/config.guess
index 1659250..f50dcdb 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2015 Free Software Foundation, Inc.
+# Copyright 1992-2018 Free Software Foundation, Inc.
-timestamp='2015-08-20'
+timestamp='2018-02-24'
# 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
@@ -15,7 +15,7 @@ timestamp='2015-08-20'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -27,7 +27,7 @@ timestamp='2015-08-20'
# 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 <config-patches@gnu.org>.
@@ -39,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
@@ -50,7 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2018 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."
@@ -107,9 +107,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
+ ,,) 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
+ if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
@@ -132,14 +132,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-case "${UNAME_SYSTEM}" in
+case "$UNAME_SYSTEM" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
- eval $set_cc_for_build
- cat <<-EOF > $dummy.c
+ eval "$set_cc_for_build"
+ cat <<-EOF > "$dummy.c"
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
@@ -149,13 +149,20 @@ Linux|GNU|GNU/*)
LIBC=gnu
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ 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
+ LIBC=musl
+ 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*,
@@ -169,27 +176,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
- /sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || \
+ "/sbin/$sysctl" 2>/dev/null || \
+ "/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
+ case "$UNAME_MACHINE_ARCH" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
- arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
- endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
- machine=${arch}${endian}-unknown
+ 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 ;;
+ *) 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
- arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
+ # to ELF recently (or will in the future) and ABI.
+ case "$UNAME_MACHINE_ARCH" in
+ earm*)
+ os=netbsdelf
+ ;;
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval "$set_cc_for_build"
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
@@ -205,10 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;;
esac
# Determine ABI tags.
- case "${UNAME_MACHINE_ARCH}" in
+ case "$UNAME_MACHINE_ARCH" in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
- abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
;;
esac
# The OS release
@@ -216,42 +226,55 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# 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/[-_].*//' | cut -d. -f1,2`
+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}${abi}"
+ 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
+ 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)
@@ -268,63 +291,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
@@ -336,7 +350,7 @@ 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:*:*)
echo arm-unknown-riscos
@@ -363,38 +377,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"
+ eval "$set_cc_for_build"
+ SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if [ "$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
@@ -403,25 +417,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
@@ -432,44 +446,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
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
@@ -478,23 +492,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
@@ -520,17 +534,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)
@@ -547,7 +561,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
@@ -559,14 +573,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
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
main()
@@ -577,7 +591,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
@@ -591,7 +605,7 @@ 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
@@ -600,18 +614,18 @@ EOF
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
@@ -626,28 +640,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
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
#include <stdlib.h>
@@ -680,13 +694,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
+ eval "$set_cc_for_build"
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
@@ -697,23 +711,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
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#include <unistd.h>
int
main ()
@@ -738,11 +752,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:*:*)
@@ -751,7 +765,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:*:*)
@@ -759,9 +773,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*:*:*)
@@ -786,127 +800,109 @@ 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 ;;
*: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 ;;
*:MSYS*:*)
- echo ${UNAME_MACHINE}-pc-msys
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
+ 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
- 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-${LIBC}`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/[-(].*//'`-${LIBC}
+ 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
+ echo "$UNAME_MACHINE"-pc-minix
exit ;;
aarch64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -919,61 +915,64 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
- if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arm*:Linux:*:*)
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
else
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ 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}
+ 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:*:*)
- 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
+ eval "$set_cc_for_build"
+ sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
@@ -987,64 +986,74 @@ EOF
#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'`"
+ test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
;;
+ mips64el:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
openrisc*:Linux:*:*)
- echo or1k-unknown-linux-${LIBC}
+ echo or1k-unknown-linux-"$LIBC"
exit ;;
or32:Linux:*:* | or1k*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ 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}
+ echo powerpc64le-unknown-linux-"$LIBC"
exit ;;
ppcle:Linux:*:*)
- echo powerpcle-unknown-linux-${LIBC}
+ echo powerpcle-unknown-linux-"$LIBC"
+ exit ;;
+ riscv32:Linux:*:* | riscv64:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+ 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}-pc-linux-${LIBC}
+ if objdump -f /bin/sh | grep -q elf32-x86-64; then
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32
+ else
+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
+ fi
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.
@@ -1058,34 +1067,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]*)
@@ -1095,12 +1104,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' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1110,9 +1119,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:*:*:*)
@@ -1120,7 +1129,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 ;;
@@ -1132,9 +1141,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:*)
@@ -1154,9 +1163,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; } ;;
@@ -1165,28 +1174,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
@@ -1197,7 +1206,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
@@ -1217,23 +1226,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.
@@ -1252,46 +1261,56 @@ 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
- eval $set_cc_for_build
+ eval "$set_cc_for_build"
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
- if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if 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
+ (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
@@ -1302,27 +1321,33 @@ EOF
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
fi
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ 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"
exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
+ 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
@@ -1331,18 +1356,18 @@ 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
+ 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
@@ -1363,14 +1388,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 ;;
@@ -1379,34 +1404,48 @@ 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 ;;
esac
+echo "$0: unable to guess system type" >&2
+
+case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+ mips:Linux | mips64:Linux)
+ # If we got here on MIPS GNU/Linux, output extra information.
+ cat >&2 <<EOF
+
+NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
+the system type. Please install a C compiler and try again.
+EOF
+ ;;
+esac
+
cat >&2 <<EOF
-$0: unable to guess system type
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
- http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+ https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
and
- http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+ https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
config.guess timestamp = $timestamp
@@ -1425,16 +1464,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 'write-file-functions 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
diff --git a/config.sub b/config.sub
index 1acc966..1d8e98b 100755
--- a/config.sub
+++ b/config.sub
@@ -1,8 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2015 Free Software Foundation, Inc.
+# Copyright 1992-2018 Free Software Foundation, Inc.
-timestamp='2015-08-20'
+timestamp='2018-02-22'
# 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
@@ -15,7 +15,7 @@ timestamp='2015-08-20'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2015-08-20'
# 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
@@ -53,12 +53,11 @@ timestamp='2015-08-20'
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
@@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2018 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."
@@ -95,7 +94,7 @@ while test $# -gt 0 ; do
*local*)
# First pass through any local machine types.
- echo $1
+ echo "$1"
exit ;;
* )
@@ -113,24 +112,24 @@ 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/'`
+maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
- kopensolaris*-gnu* | \
+ kopensolaris*-gnu* | cloudabi*-eabi* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ 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/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
+ basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
+ if [ "$basic_machine" != "$1" ]
+ then os=`echo "$1" | sed 's/.*-/-/'`
else os=; fi
;;
esac
@@ -179,44 +178,44 @@ case $os in
;;
-sco6)
os=-sco5v6
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ 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/'`
+ 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/'`
+ 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/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ 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/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
@@ -228,10 +227,7 @@ case $os in
os=-lynxos
;;
-ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
;;
-psos*)
os=-psos
@@ -264,7 +260,7 @@ case $basic_machine in
| fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
- | i370 | i860 | i960 | ia64 \
+ | i370 | i860 | i960 | ia16 | ia64 \
| ip2k | iq2000 \
| k1om \
| le32 | le64 \
@@ -300,8 +296,9 @@ case $basic_machine in
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 | or1k | or1knd | or32 \
- | pdp10 | pdp11 | pj | pjl \
+ | pdp10 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pru \
| pyramid \
| riscv32 | riscv64 \
| rl78 | rx \
@@ -315,7 +312,7 @@ case $basic_machine in
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| visium \
- | we32k \
+ | wasm32 \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
@@ -336,7 +333,7 @@ case $basic_machine in
basic_machine=$basic_machine-unknown
os=-none
;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
;;
ms1)
basic_machine=mt-unknown
@@ -365,7 +362,7 @@ case $basic_machine in
;;
# Object if more than one company name word.
*-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
@@ -388,7 +385,7 @@ case $basic_machine in
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
- | i*86-* | i860-* | i960-* | ia64-* \
+ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
| ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
@@ -429,6 +426,7 @@ case $basic_machine in
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pru-* \
| pyramid-* \
| riscv32-* | riscv64-* \
| rl78-* | romp-* | rs6000-* | rx-* \
@@ -445,6 +443,7 @@ case $basic_machine in
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| visium-* \
+ | wasm32-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@@ -458,7 +457,7 @@ case $basic_machine in
# 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
+ basic_machine=i386-pc
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
@@ -492,7 +491,7 @@ case $basic_machine in
basic_machine=x86_64-pc
;;
amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
@@ -521,7 +520,7 @@ case $basic_machine in
basic_machine=i386-pc
os=-aros
;;
- asmjs)
+ asmjs)
basic_machine=asmjs-unknown
;;
aux)
@@ -537,7 +536,7 @@ case $basic_machine in
os=-linux
;;
blackfin-*)
- basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
@@ -545,13 +544,13 @@ case $basic_machine in
os=-cnk
;;
c54x-*)
- basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
c55x-*)
- basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
c6x-*)
- basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
c90)
basic_machine=c90-cray
@@ -640,10 +639,18 @@ case $basic_machine in
basic_machine=rs6000-bull
os=-bosx
;;
- dpx2* | dpx2*-bull)
+ dpx2*)
basic_machine=m68k-bull
os=-sysv3
;;
+ e500v[12])
+ basic_machine=powerpc-unknown
+ os=$os"spe"
+ ;;
+ e500v[12]-*)
+ basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ os=$os"spe"
+ ;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
@@ -733,9 +740,6 @@ case $basic_machine in
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
@@ -748,26 +752,26 @@ case $basic_machine in
basic_machine=i370-ibm
;;
i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
- i386-vsta | vsta)
+ vsta)
basic_machine=i386-unknown
os=-vsta
;;
@@ -786,19 +790,16 @@ case $basic_machine in
os=-sysv
;;
leon-*|leon[3-9]-*)
- basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+ basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
- basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=-linux
;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
@@ -830,10 +831,10 @@ case $basic_machine in
os=-mint
;;
mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
;;
mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
@@ -852,7 +853,7 @@ case $basic_machine in
os=-msdos
;;
ms1-*)
- basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i686-pc
@@ -894,7 +895,7 @@ case $basic_machine in
basic_machine=v70-nec
os=-sysv
;;
- next | m*-next )
+ next | m*-next)
basic_machine=m68k-next
case $os in
-nextstep* )
@@ -939,6 +940,12 @@ case $basic_machine in
nsr-tandem)
basic_machine=nsr-tandem
;;
+ nsv-tandem)
+ basic_machine=nsv-tandem
+ ;;
+ nsx-tandem)
+ basic_machine=nsx-tandem
+ ;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
@@ -971,7 +978,7 @@ case $basic_machine in
os=-linux
;;
parisc-*)
- basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
@@ -987,7 +994,7 @@ case $basic_machine in
basic_machine=i386-pc
;;
pc98-*)
- basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
@@ -1002,16 +1009,16 @@ case $basic_machine in
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
@@ -1021,23 +1028,23 @@ case $basic_machine in
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-* | ppcbe-*)
- basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
+ ppcle | powerpclittle)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ ppc64le | powerpc64little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
@@ -1091,17 +1098,10 @@ case $basic_machine in
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)
+ simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
@@ -1120,7 +1120,7 @@ case $basic_machine in
os=-sysv4
;;
strongarm-* | thumb-*)
- basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
;;
sun2)
basic_machine=m68000-sun
@@ -1242,6 +1242,9 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
+ x64)
+ basic_machine=x86_64-pc
+ ;;
xbox)
basic_machine=i686-pc
os=-mingw32
@@ -1250,20 +1253,12 @@ case $basic_machine in
basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
- basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+ 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
@@ -1292,10 +1287,6 @@ case $basic_machine in
vax)
basic_machine=vax-dec
;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
pdp11)
basic_machine=pdp11-dec
;;
@@ -1305,9 +1296,6 @@ case $basic_machine in
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
- sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
- basic_machine=sparc-sun
- ;;
cydra)
basic_machine=cydra-cydrome
;;
@@ -1327,7 +1315,7 @@ case $basic_machine in
# Make sure to match an already-canonicalized machine name.
;;
*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
exit 1
;;
esac
@@ -1335,10 +1323,10 @@ esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
;;
*-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
;;
*)
;;
@@ -1349,8 +1337,8 @@ esac
if [ x"$os" != x"" ]
then
case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
+ # First match some system type aliases that might get confused
+ # with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
@@ -1361,18 +1349,19 @@ case $os in
-solaris)
os=-solaris2
;;
- -svr4*)
- os=-sysv4
- ;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
- # First accept the basic system types.
+ # es1800 is here to avoid being matched by es* (a different OS)
+ -es1800*)
+ os=-ose
+ ;;
+ # Now accept the basic system types.
# The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
+ # 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]*\
@@ -1382,24 +1371,26 @@ case $os in
| -aos* | -aros* | -cloudabi* | -sortix* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
- | -bitrig* | -openbsd* | -solidbsd* \
+ | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* | -cegcc* \
+ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -morphos* | -superux* | -rtmk* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
+ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
+ | -midnightbsd*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1416,12 +1407,12 @@ case $os in
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ -sim | -xray | -os68k* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
+ os=`echo "$os" | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
@@ -1430,10 +1421,10 @@ case $os in
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
@@ -1444,12 +1435,6 @@ case $os in
-wince*)
os=-wince
;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
-utek*)
os=-bsd
;;
@@ -1474,7 +1459,7 @@ case $os in
-nova*)
os=-rtmk-nova
;;
- -ns2 )
+ -ns2)
os=-nextstep2
;;
-nsk*)
@@ -1496,7 +1481,7 @@ case $os in
-oss*)
os=-sysv3
;;
- -svr4)
+ -svr4*)
os=-sysv4
;;
-svr3)
@@ -1511,32 +1496,38 @@ case $os in
-ose*)
os=-ose
;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
- -aros*)
- os=-aros
- ;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
+ -pikeos*)
+ # Until real need of OS specific support for
+ # particular features comes up, bare metal
+ # configurations are quite functional.
+ case $basic_machine in
+ arm*)
+ os=-eabi
+ ;;
+ *)
+ os=-elf
+ ;;
+ esac
+ ;;
-nacl*)
;;
+ -ios)
+ ;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
exit 1
;;
esac
@@ -1626,12 +1617,12 @@ case $basic_machine in
sparc-* | *-sun)
os=-sunos4.1.1
;;
+ pru-*)
+ os=-elf
+ ;;
*-be)
os=-beos
;;
- *-haiku)
- os=-haiku
- ;;
*-ibm)
os=-aix
;;
@@ -1671,7 +1662,7 @@ case $basic_machine in
m88k-omron*)
os=-luna
;;
- *-next )
+ *-next)
os=-nextstep
;;
*-sequent)
@@ -1686,9 +1677,6 @@ case $basic_machine in
i370-*)
os=-mvs
;;
- *-next)
- os=-nextstep3
- ;;
*-gould)
os=-sysv
;;
@@ -1798,15 +1786,15 @@ case $basic_machine in
vendor=stratus
;;
esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
;;
esac
-echo $basic_machine$os
+echo "$basic_machine$os"
exit
# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'write-file-functions 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
diff --git a/configure b/configure
index eb267bd..e91e0c6 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libheif 1.2.0.
+# Generated by GNU Autoconf 2.69 for libheif 1.3.2.
#
# Report bugs to <opensource@struktur.de>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libheif'
PACKAGE_TARNAME='libheif'
-PACKAGE_VERSION='1.2.0'
-PACKAGE_STRING='libheif 1.2.0'
+PACKAGE_VERSION='1.3.2'
+PACKAGE_STRING='libheif 1.3.2'
PACKAGE_BUGREPORT='opensource@struktur.de'
PACKAGE_URL=''
@@ -647,10 +647,12 @@ HAVE_LIBJPEG_FALSE
HAVE_LIBJPEG_TRUE
libjpeg_LIBS
libjpeg_CFLAGS
+have_x265
HAVE_X265_FALSE
HAVE_X265_TRUE
x265_LIBS
x265_CFLAGS
+have_libde265
HAVE_LIBDE265_FALSE
HAVE_LIBDE265_TRUE
libde265_LIBS
@@ -1392,7 +1394,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libheif 1.2.0 to adapt to many kinds of systems.
+\`configure' configures libheif 1.3.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1464,7 +1466,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libheif 1.2.0:";;
+ short | recursive ) echo "Configuration of libheif 1.3.2:";;
esac
cat <<\_ACEOF
@@ -1597,7 +1599,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libheif configure 1.2.0
+libheif configure 1.3.2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2195,7 +2197,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libheif $as_me 1.2.0, which was
+It was created by libheif $as_me 1.3.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2547,12 +2549,18 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers config.h"
-NUMERIC_VERSION=0x01020000 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD)
+NUMERIC_VERSION=0x01030200 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD)
-LIBHEIF_CURRENT=3
-LIBHEIF_REVISION=0
-LIBHEIF_AGE=2
+# From https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html:
+# If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
+# If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
+# If any interfaces have been added since the last public release, then increment age.
+# If any interfaces have been removed or changed since the last public release, then set age to 0.
+
+LIBHEIF_CURRENT=4
+LIBHEIF_REVISION=2
+LIBHEIF_AGE=3
@@ -16541,7 +16549,7 @@ fi
# Define the identity of the package.
PACKAGE='libheif'
- VERSION='1.2.0'
+ VERSION='1.3.2'
cat >>confdefs.h <<_ACEOF
@@ -17651,6 +17659,7 @@ fi
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x265" >&5
$as_echo_n "checking for x265... " >&6; }
@@ -17737,6 +17746,7 @@ else
fi
+
for ac_header in jpeglib.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "jpeglib.h" "ac_cv_header_jpeglib_h" "$ac_includes_default"
@@ -18593,7 +18603,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libheif $as_me 1.2.0, which was
+This file was extended by libheif $as_me 1.3.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -18659,7 +18669,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libheif config.status 1.2.0
+libheif config.status 1.3.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -19791,7 +19801,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.
diff --git a/configure.ac b/configure.ac
index 2d61612..d175ef0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,14 +1,20 @@
AC_PREREQ([2.68])
-AC_INIT([libheif], [1.2.0], [opensource@struktur.de])
+AC_INIT([libheif], [1.3.2], [opensource@struktur.de])
AC_CONFIG_SRCDIR([libheif/box.cc])
AC_CONFIG_HEADERS([config.h])
-NUMERIC_VERSION=0x01020000 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD)
+NUMERIC_VERSION=0x01030200 # Numeric representation of the version (A.B.C[.D] = 0xAABBCCDD)
AC_SUBST(NUMERIC_VERSION)
-LIBHEIF_CURRENT=3
-LIBHEIF_REVISION=0
-LIBHEIF_AGE=2
+# From https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html:
+# If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
+# If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
+# If any interfaces have been added since the last public release, then increment age.
+# If any interfaces have been removed or changed since the last public release, then set age to 0.
+
+LIBHEIF_CURRENT=4
+LIBHEIF_REVISION=2
+LIBHEIF_AGE=3
AC_SUBST(LIBHEIF_CURRENT)
AC_SUBST(LIBHEIF_REVISION)
AC_SUBST(LIBHEIF_AGE)
@@ -58,6 +64,7 @@ PKG_CHECK_MODULES([libde265], [libde265], [
have_libde265="yes"
], [have_libde265="no"])
AM_CONDITIONAL([HAVE_LIBDE265], [test "x$have_libde265" = "xyes"])
+AC_SUBST([have_libde265])
PKG_CHECK_MODULES([x265], [x265], [
AC_DEFINE([HAVE_X265], [1], [Whether x265 was found.])
@@ -66,6 +73,7 @@ PKG_CHECK_MODULES([x265], [x265], [
have_x265="yes"
], [have_x265="no"])
AM_CONDITIONAL([HAVE_X265], [test "x$have_x265" = "xyes"])
+AC_SUBST([have_x265])
AC_CHECK_HEADERS([jpeglib.h])
AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [
diff --git a/depcomp b/depcomp
index fc98710..b39f98f 100755
--- a/depcomp
+++ b/depcomp
@@ -1,9 +1,9 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -786,6 +786,6 @@ exit 0
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 99023c8..4cadf15 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -6,7 +6,8 @@ bin_PROGRAMS = \
heif-info
noinst_PROGRAMS = \
- heif-test
+ heif-test \
+ test-c-api
heif_convert_DEPENDENCIES = ../libheif/libheif.la
heif_convert_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir)/.
@@ -64,6 +65,12 @@ heif_test_LDFLAGS =
heif_test_LDADD = ../libheif/libheif.la
heif_test_SOURCES = heif_test.cc
+test_c_api_DEPENDENCIES = ../libheif/libheif.la
+test_c_api_CFLAGS = -I$(top_srcdir) -I$(top_builddir)
+test_c_api_LDFLAGS =
+test_c_api_LDADD = ../libheif/libheif.la
+test_c_api_SOURCES = test_c_api.c
+
EXTRA_DIST = \
demo.html \
example.heic
diff --git a/examples/Makefile.in b/examples/Makefile.in
index ccc083c..8d60c13 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -91,7 +91,7 @@ host_triplet = @host@
target_triplet = @target@
bin_PROGRAMS = heif-convert$(EXEEXT) heif-enc$(EXEEXT) \
heif-info$(EXEEXT) $(am__EXEEXT_1)
-noinst_PROGRAMS = heif-test$(EXEEXT)
+noinst_PROGRAMS = heif-test$(EXEEXT) test-c-api$(EXEEXT)
@HAVE_LIBPNG_TRUE@am__append_1 = heif-thumbnailer
@HAVE_LIBJPEG_TRUE@am__append_2 = $(libjpeg_CFLAGS)
@HAVE_LIBJPEG_TRUE@am__append_3 = $(libjpeg_LIBS)
@@ -165,6 +165,11 @@ heif_thumbnailer_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
$(heif_thumbnailer_CXXFLAGS) $(CXXFLAGS) \
$(heif_thumbnailer_LDFLAGS) $(LDFLAGS) -o $@
+am_test_c_api_OBJECTS = test_c_api-test_c_api.$(OBJEXT)
+test_c_api_OBJECTS = $(am_test_c_api_OBJECTS)
+test_c_api_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_c_api_CFLAGS) \
+ $(CFLAGS) $(test_c_api_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -181,24 +186,6 @@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
-CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CXXFLAGS) $(CXXFLAGS)
-AM_V_CXX = $(am__v_CXX_@AM_V@)
-am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
-am__v_CXX_0 = @echo " CXX " $@;
-am__v_CXX_1 =
-CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
- $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
-am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
-am__v_CXXLD_0 = @echo " CXXLD " $@;
-am__v_CXXLD_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -217,12 +204,30 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo " CXX " $@;
+am__v_CXX_1 =
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+am__v_CXXLD_1 =
SOURCES = $(heif_convert_SOURCES) $(heif_enc_SOURCES) \
$(heif_info_SOURCES) $(heif_test_SOURCES) \
- $(heif_thumbnailer_SOURCES)
+ $(heif_thumbnailer_SOURCES) $(test_c_api_SOURCES)
DIST_SOURCES = $(am__heif_convert_SOURCES_DIST) $(heif_enc_SOURCES) \
$(heif_info_SOURCES) $(heif_test_SOURCES) \
- $(am__heif_thumbnailer_SOURCES_DIST)
+ $(am__heif_thumbnailer_SOURCES_DIST) $(test_c_api_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -356,6 +361,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -428,6 +435,11 @@ heif_test_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir)
heif_test_LDFLAGS =
heif_test_LDADD = ../libheif/libheif.la
heif_test_SOURCES = heif_test.cc
+test_c_api_DEPENDENCIES = ../libheif/libheif.la
+test_c_api_CFLAGS = -I$(top_srcdir) -I$(top_builddir)
+test_c_api_LDFLAGS =
+test_c_api_LDADD = ../libheif/libheif.la
+test_c_api_SOURCES = test_c_api.c
EXTRA_DIST = \
demo.html \
example.heic
@@ -435,7 +447,7 @@ EXTRA_DIST = \
all: all-am
.SUFFIXES:
-.SUFFIXES: .cc .lo .o .obj
+.SUFFIXES: .c .cc .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -544,6 +556,10 @@ heif-thumbnailer$(EXEEXT): $(heif_thumbnailer_OBJECTS) $(heif_thumbnailer_DEPEND
@rm -f heif-thumbnailer$(EXEEXT)
$(AM_V_CXXLD)$(heif_thumbnailer_LINK) $(heif_thumbnailer_OBJECTS) $(heif_thumbnailer_LDADD) $(LIBS)
+test-c-api$(EXEEXT): $(test_c_api_OBJECTS) $(test_c_api_DEPENDENCIES) $(EXTRA_test_c_api_DEPENDENCIES)
+ @rm -f test-c-api$(EXEEXT)
+ $(AM_V_CCLD)$(test_c_api_LINK) $(test_c_api_OBJECTS) $(test_c_api_LDADD) $(LIBS)
+
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -560,6 +576,45 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/heif_thumbnailer-encoder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/heif_thumbnailer-encoder_png.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/heif_thumbnailer-heif_thumbnailer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_c_api-test_c_api.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+test_c_api-test_c_api.o: test_c_api.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_c_api_CFLAGS) $(CFLAGS) -MT test_c_api-test_c_api.o -MD -MP -MF $(DEPDIR)/test_c_api-test_c_api.Tpo -c -o test_c_api-test_c_api.o `test -f 'test_c_api.c' || echo '$(srcdir)/'`test_c_api.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_c_api-test_c_api.Tpo $(DEPDIR)/test_c_api-test_c_api.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_c_api.c' object='test_c_api-test_c_api.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_c_api_CFLAGS) $(CFLAGS) -c -o test_c_api-test_c_api.o `test -f 'test_c_api.c' || echo '$(srcdir)/'`test_c_api.c
+
+test_c_api-test_c_api.obj: test_c_api.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_c_api_CFLAGS) $(CFLAGS) -MT test_c_api-test_c_api.obj -MD -MP -MF $(DEPDIR)/test_c_api-test_c_api.Tpo -c -o test_c_api-test_c_api.obj `if test -f 'test_c_api.c'; then $(CYGPATH_W) 'test_c_api.c'; else $(CYGPATH_W) '$(srcdir)/test_c_api.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_c_api-test_c_api.Tpo $(DEPDIR)/test_c_api-test_c_api.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_c_api.c' object='test_c_api-test_c_api.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_c_api_CFLAGS) $(CFLAGS) -c -o test_c_api-test_c_api.obj `if test -f 'test_c_api.c'; then $(CYGPATH_W) 'test_c_api.c'; else $(CYGPATH_W) '$(srcdir)/test_c_api.c'; fi`
.cc.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc
index 2b7b95b..30840be 100644
--- a/examples/heif_enc.cc
+++ b/examples/heif_enc.cc
@@ -47,27 +47,37 @@ extern "C" {
#include <assert.h>
+int master_alpha = 1;
+int thumb_alpha = 1;
static struct option long_options[] = {
{"help", no_argument, 0, 'h' },
{"quality", required_argument, 0, 'q' },
{"output", required_argument, 0, 'o' },
{"lossless", no_argument, 0, 'L' },
+ {"thumb", required_argument, 0, 't' },
{"verbose", no_argument, 0, 'v' },
{"params", no_argument, 0, 'P' },
+ {"no-alpha", no_argument, &master_alpha, 0 },
+ {"no-thumb-alpha", no_argument, &thumb_alpha, 0 },
{0, 0, 0, 0 }
};
void show_help(const char* argv0)
{
std::cerr << " heif-enc libheif version: " << heif_get_version() << "\n"
- << "------------------------------------\n"
- << "usage: heif-enc [options] image.jpeg\n"
+ << "----------------------------------------\n"
+ << "usage: heif-enc [options] image.jpeg ...\n"
+ << "\n"
+ << "When specifying multiple source images, they will all be saved into the same HEIF file.\n"
<< "\n"
<< "options:\n"
<< " -h, --help show help\n"
<< " -q, --quality set output quality (0-100) for lossy compression\n"
<< " -L, --lossless generate lossless output (-q has no effect)\n"
+ << " -t, --thumb # generate thumbnail with maximum size # (default: off)\n"
+ << " --no-alpha do not save alpha channel\n"
+ << " --no-thumb-alpha do not save alpha channel in thumbnail image\n"
<< " -o, --output output filename (optional)\n"
<< " -v, --verbose enable logging output (more -v will increase logging level)\n"
<< " -P, --params show all encoder parameters\n"
@@ -579,12 +589,14 @@ int main(int argc, char** argv)
std::string output_filename;
int logging_level = 0;
bool option_show_parameters = false;
+ int thumbnail_bbox_size = 0;
std::vector<std::string> raw_params;
+
while (true) {
int option_index = 0;
- int c = getopt_long(argc, argv, "hq:Lo:vPp:", long_options, &option_index);
+ int c = getopt_long(argc, argv, "hq:Lo:vPp:t:", long_options, &option_index);
if (c == -1)
break;
@@ -610,10 +622,13 @@ int main(int argc, char** argv)
case 'p':
raw_params.push_back(optarg);
break;
+ case 't':
+ thumbnail_bbox_size = atoi(optarg);
+ break;
}
}
- if (optind != argc-1) {
+ if (optind > argc-1) {
show_help(argv[0]);
return 0;
}
@@ -679,70 +694,102 @@ int main(int argc, char** argv)
+ struct heif_error error;
+
+ for ( ; optind<argc ; optind++) {
+ std::string input_filename = argv[optind];
- std::string input_filename = argv[optind];
+ if (output_filename.empty()) {
+ std::string filename_without_suffix;
+ std::string::size_type dot_position = input_filename.find_last_of('.');
+ if (dot_position != std::string::npos) {
+ filename_without_suffix = input_filename.substr(0 , dot_position);
+ }
+ else {
+ filename_without_suffix = input_filename;
+ }
- if (output_filename.empty()) {
- std::string filename_without_suffix;
- std::string::size_type dot_position = input_filename.find_last_of('.');
- if (dot_position != std::string::npos) {
- filename_without_suffix = input_filename.substr(0 , dot_position);
+ output_filename = filename_without_suffix + ".heic";
}
- else {
- filename_without_suffix = input_filename;
+
+
+ // ==============================================================================
+
+ // get file type from file name
+
+ std::string suffix;
+ auto suffix_pos = input_filename.find_last_of('.');
+ if (suffix_pos != std::string::npos) {
+ suffix = input_filename.substr(suffix_pos+1);
+ std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
}
- output_filename = filename_without_suffix + ".heic";
- }
+ enum { PNG, JPEG } filetype = JPEG;
+ if (suffix == "png") {
+ filetype = PNG;
+ }
+ std::shared_ptr<heif_image> image;
+ if (filetype==PNG) {
+ image = loadPNG(input_filename.c_str());
+ }
+ else {
+ image = loadJPEG(input_filename.c_str());
+ }
- // ==============================================================================
- // get file type from file name
- std::string suffix;
- auto suffix_pos = input_filename.find_last_of('.');
- if (suffix_pos != std::string::npos) {
- suffix = input_filename.substr(suffix_pos+1);
- std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
- }
+ heif_encoder_set_lossy_quality(encoder, quality);
+ heif_encoder_set_lossless(encoder, lossless);
+ heif_encoder_set_logging_level(encoder, logging_level);
- enum { PNG, JPEG } filetype = JPEG;
- if (suffix == "png") {
- filetype = PNG;
- }
+ set_params(encoder, raw_params);
- std::shared_ptr<heif_image> image;
- if (filetype==PNG) {
- image = loadPNG(input_filename.c_str());
- }
- else {
- image = loadJPEG(input_filename.c_str());
- }
+ struct heif_encoding_options* options = heif_encoding_options_alloc();
+ options->save_alpha_channel = (uint8_t)master_alpha;
+ struct heif_image_handle* handle;
+ error = heif_context_encode_image(context.get(),
+ image.get(),
+ encoder,
+ options,
+ &handle);
+ if (error.code != 0) {
+ std::cerr << "Could not read HEIF file: " << error.message << "\n";
+ return 1;
+ }
- heif_encoder_set_lossy_quality(encoder, quality);
- heif_encoder_set_lossless(encoder, lossless);
- heif_encoder_set_logging_level(encoder, logging_level);
+ if (thumbnail_bbox_size > 0)
+ {
+ // encode thumbnail
+
+ struct heif_image_handle* thumbnail_handle;
+
+ options->save_alpha_channel = master_alpha && thumb_alpha;
+
+ error = heif_context_encode_thumbnail(context.get(),
+ image.get(),
+ handle,
+ encoder,
+ options,
+ thumbnail_bbox_size,
+ &thumbnail_handle);
+ if (error.code) {
+ std::cerr << "Could not generate thumbnail: " << error.message << "\n";
+ return 5;
+ }
- set_params(encoder, raw_params);
+ if (thumbnail_handle) {
+ heif_image_handle_release(thumbnail_handle);
+ }
+ }
- struct heif_image_handle* handle;
- struct heif_error error = heif_context_encode_image(context.get(),
- image.get(),
- encoder,
- nullptr,
- &handle);
- if (error.code != 0) {
- std::cerr << "Could not read HEIF file: " << error.message << "\n";
- return 1;
+ heif_image_handle_release(handle);
}
heif_encoder_release(encoder);
- heif_image_handle_release(handle);
-
error = heif_context_write_to_file(context.get(), output_filename.c_str());
if (error.code) {
std::cerr << error.message << "\n";
diff --git a/examples/test_c_api.c b/examples/test_c_api.c
new file mode 100644
index 0000000..47b04e8
--- /dev/null
+++ b/examples/test_c_api.c
@@ -0,0 +1,29 @@
+/*
+ * Very simple test whether the header file compiler with a plain C compiler
+ * Copyright (c) 2018 struktur AG, Dirk Farin <farin@struktur.de>
+ *
+ * This file is part of libheif. It performs test calculations for CI checks.
+ *
+ * heif 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.
+ *
+ * heif 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 heif. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "libheif/heif.h"
+#include "libheif/heif_version.h"
+#include "libheif/heif_plugin.h"
+
+int main()
+{
+ return 0;
+}
diff --git a/extra/Makefile.in b/extra/Makefile.in
index a563066..58158e3 100644
--- a/extra/Makefile.in
+++ b/extra/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -231,6 +231,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
diff --git a/gnome/Makefile.in b/gnome/Makefile.in
index 38addf1..2466247 100644
--- a/gnome/Makefile.in
+++ b/gnome/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -262,6 +262,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
diff --git a/go/Makefile.in b/go/Makefile.in
index d0b5de6..466a985 100644
--- a/go/Makefile.in
+++ b/go/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -231,6 +231,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
diff --git a/libheif.pc.in b/libheif.pc.in
index bf30c11..0f14ca8 100644
--- a/libheif.pc.in
+++ b/libheif.pc.in
@@ -2,12 +2,14 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
+builtin_h265_decoder=@have_libde265@
+builtin_h265_encoder=@have_x265@
Name: libheif
Description: HEIF image codec.
URL: https://github.com/strukturag/libheif
Version: @VERSION@
Requires:
-Libs: -lheif -L@libdir@
+Libs: -L@libdir@ -lheif
Libs.private: @LIBS@ -lstdc++
Cflags: -I@includedir@
diff --git a/libheif/Makefile.am b/libheif/Makefile.am
index 185897e..c034ad4 100644
--- a/libheif/Makefile.am
+++ b/libheif/Makefile.am
@@ -25,7 +25,7 @@ libheif_la_CXXFLAGS = \
$(CFLAG_VISIBILITY) \
$(libde265_CFLAGS) \
$(x265_CFLAGS) \
- -DLIBHEIF_EXPORTS
+ -DLIBHEIF_EXPORTS -I$(top_srcdir)
libheif_la_LIBADD = $(ADDITIONAL_LIBS)
libheif_la_LDFLAGS = -version-info $(LIBHEIF_CURRENT):$(LIBHEIF_REVISION):$(LIBHEIF_AGE)
diff --git a/libheif/Makefile.in b/libheif/Makefile.in
index 779e13b..7c0adf2 100644
--- a/libheif/Makefile.in
+++ b/libheif/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -476,6 +476,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -527,7 +529,8 @@ libheif_la_CPPFLAGS =
libheif_la_CFLAGS = $(CFLAG_VISIBILITY) -DLIBHEIF_EXPORTS \
$(am__append_6)
libheif_la_CXXFLAGS = $(CFLAG_VISIBILITY) $(libde265_CFLAGS) \
- $(x265_CFLAGS) -DLIBHEIF_EXPORTS $(am__append_7)
+ $(x265_CFLAGS) -DLIBHEIF_EXPORTS -I$(top_srcdir) \
+ $(am__append_7)
libheif_la_LIBADD = $(ADDITIONAL_LIBS)
libheif_la_LDFLAGS = -version-info \
$(LIBHEIF_CURRENT):$(LIBHEIF_REVISION):$(LIBHEIF_AGE) \
diff --git a/libheif/bitstream.cc b/libheif/bitstream.cc
index 5f87476..049c82e 100644
--- a/libheif/bitstream.cc
+++ b/libheif/bitstream.cc
@@ -20,6 +20,7 @@
#include "bitstream.h"
+#include <utility>
#include <string.h>
#include <assert.h>
@@ -28,19 +29,157 @@
using namespace heif;
+StreamReader_istream::StreamReader_istream(std::unique_ptr<std::istream>&& istr)
+ : m_istr(std::move(istr))
+{
+ m_istr->seekg(0, std::ios_base::end);
+ m_length = m_istr->tellg();
+ m_istr->seekg(0, std::ios_base::beg);
+}
+
+int64_t StreamReader_istream::get_position() const
+{
+ return m_istr->tellg();
+}
+
+StreamReader::grow_status StreamReader_istream::wait_for_file_size(int64_t target_size)
+{
+ return (target_size > m_length) ? size_beyond_eof : size_reached;
+}
+
+bool StreamReader_istream::read(void* data, size_t size)
+{
+ int64_t end_pos = get_position() + size;
+ if (end_pos > m_length) {
+ return false;
+ }
+
+ m_istr->read((char*)data, size);
+ return true;
+}
+
+bool StreamReader_istream::seek(int64_t position)
+{
+ if (position>m_length)
+ return false;
+
+ m_istr->seekg(position, std::ios_base::beg);
+ return true;
+}
+
+
+
+StreamReader_memory::StreamReader_memory(const uint8_t* data, int64_t size, bool copy)
+ : m_length(size),
+ m_position(0)
+{
+ if (copy) {
+ m_owned_data = new uint8_t[m_length];
+ memcpy(m_owned_data, data, m_length);
+
+ m_data = m_owned_data;
+ }
+ else {
+ m_data = data;
+ }
+}
+
+StreamReader_memory::~StreamReader_memory()
+{
+ if (m_owned_data) {
+ delete[] m_owned_data;
+ }
+}
+
+int64_t StreamReader_memory::get_position() const
+{
+ return m_position;
+}
+
+StreamReader::grow_status StreamReader_memory::wait_for_file_size(int64_t target_size)
+{
+ return (target_size > m_length) ? size_beyond_eof : size_reached;
+}
+
+bool StreamReader_memory::read(void* data, size_t size)
+{
+ int64_t end_pos = m_position + size;
+ if (end_pos > m_length) {
+ return false;
+ }
+
+ memcpy(data, &m_data[m_position], size);
+ m_position += size;
+
+ return true;
+}
+
+bool StreamReader_memory::seek(int64_t position)
+{
+ if (position>m_length || position<0)
+ return false;
+
+ m_position = position;
+ return true;
+}
+
+
+
+StreamReader_CApi::StreamReader_CApi(const heif_reader* func_table, void* userdata)
+ : m_func_table(func_table), m_userdata(userdata)
+{
+}
+
+StreamReader::grow_status StreamReader_CApi::wait_for_file_size(int64_t target_size)
+{
+ heif_reader_grow_status status = m_func_table->wait_for_file_size(target_size, m_userdata);
+ switch (status) {
+ case heif_reader_grow_status_size_reached: return size_reached;
+ case heif_reader_grow_status_timeout: return timeout;
+ case heif_reader_grow_status_size_beyond_eof: return size_beyond_eof;
+ default:
+ assert(0);
+ return size_beyond_eof;
+ }
+}
+
+
+
+
+BitstreamRange::BitstreamRange(std::shared_ptr<StreamReader> istr,
+ uint64_t length,
+ BitstreamRange* parent)
+{
+ m_remaining = length;
+
+ m_istr = istr;
+ m_parent_range = parent;
+
+ if (parent) {
+ m_nesting_level = parent->m_nesting_level + 1;
+ }
+}
+
+
+StreamReader::grow_status BitstreamRange::wait_until_range_is_available()
+{
+ return m_istr->wait_for_file_size( m_istr->get_position() + m_remaining );
+}
+
+
uint8_t BitstreamRange::read8()
{
- if (!read(1)) {
+ if (!prepare_read(1)) {
return 0;
}
uint8_t buf;
- std::istream* istr = get_istream();
- istr->read((char*)&buf,1);
+ auto istr = get_istream();
+ bool success = istr->read((char*)&buf,1);
- if (istr->fail()) {
- set_eof_reached();
+ if (!success) {
+ set_eof_while_reading();
return 0;
}
@@ -50,17 +189,17 @@ uint8_t BitstreamRange::read8()
uint16_t BitstreamRange::read16()
{
- if (!read(2)) {
+ if (!prepare_read(2)) {
return 0;
}
uint8_t buf[2];
- std::istream* istr = get_istream();
- istr->read((char*)buf,2);
+ auto istr = get_istream();
+ bool success = istr->read((char*)buf,2);
- if (istr->fail()) {
- set_eof_reached();
+ if (!success) {
+ set_eof_while_reading();
return 0;
}
@@ -70,17 +209,17 @@ uint16_t BitstreamRange::read16()
uint32_t BitstreamRange::read32()
{
- if (!read(4)) {
+ if (!prepare_read(4)) {
return 0;
}
uint8_t buf[4];
- std::istream* istr = get_istream();
- istr->read((char*)buf,4);
+ auto istr = get_istream();
+ bool success = istr->read((char*)buf,4);
- if (istr->fail()) {
- set_eof_reached();
+ if (!success) {
+ set_eof_while_reading();
return 0;
}
@@ -95,20 +234,23 @@ std::string BitstreamRange::read_string()
{
std::string str;
+ // Reading a string when no more data is available, returns an empty string.
+ // Such a case happens, for example, when reading a 'url' box without content.
if (eof()) {
- return "";
+ return std::string();
}
for (;;) {
- if (!read(1)) {
+ if (!prepare_read(1)) {
return std::string();
}
- std::istream* istr = get_istream();
- int c = istr->get();
+ auto istr = get_istream();
+ char c;
+ bool success = istr->read(&c,1);
- if (istr->fail()) {
- set_eof_reached();
+ if (!success) {
+ set_eof_while_reading();
return std::string();
}
@@ -124,6 +266,56 @@ std::string BitstreamRange::read_string()
}
+bool BitstreamRange::prepare_read(int64_t nBytes)
+{
+ if (nBytes<0) {
+ // --- we cannot read negative amounts of bytes
+
+ assert(false);
+ return false;
+ }
+ else if (m_remaining < nBytes) {
+ // --- not enough data left in box -> move to end of box and set error flag
+
+ skip_to_end_of_box();
+
+ m_error = true;
+ return false;
+ }
+ else {
+ // --- this is the normal case (m_remaining >= nBytes)
+
+ if (m_parent_range) {
+ m_parent_range->prepare_read(nBytes);
+ }
+
+ m_remaining -= nBytes;
+
+ return true;
+ }
+}
+
+
+StreamReader::grow_status BitstreamRange::wait_for_available_bytes(int64_t nBytes)
+{
+ int64_t target_size = m_istr->get_position() + nBytes;
+
+ return m_istr->wait_for_file_size(target_size);
+}
+
+
+void BitstreamRange::skip_without_advancing_file_pos(int64_t n)
+{
+ assert(n<=m_remaining);
+
+ m_remaining -= n;
+
+ if (m_parent_range) {
+ m_parent_range->skip_without_advancing_file_pos(n);
+ }
+}
+
+
BitReader::BitReader(const uint8_t* buffer, int len)
diff --git a/libheif/bitstream.h b/libheif/bitstream.h
index bba65d6..e1622a2 100644
--- a/libheif/bitstream.h
+++ b/libheif/bitstream.h
@@ -43,83 +43,151 @@
namespace heif {
- class BitstreamRange
+ class StreamReader
{
public:
- BitstreamRange(std::istream* istr, uint64_t length, BitstreamRange* parent = nullptr) {
- construct(istr, length, parent);
+ virtual ~StreamReader() { }
+
+ virtual int64_t get_position() const = 0;
+
+ enum grow_status {
+ size_reached, // requested size has been reached
+ timeout, // size has not been reached yet, but it may still grow further
+ size_beyond_eof // size has not been reached and never will. The file has grown to its full size
+ };
+
+ // a StreamReader can maintain a timeout for waiting for new data
+ virtual grow_status wait_for_file_size(int64_t target_size) = 0;
+
+ // returns 'false' when we read out of the available file size
+ virtual bool read(void* data, size_t size) = 0;
+
+ virtual bool seek(int64_t position) = 0;
+
+ bool seek_cur(int64_t position_offset) {
+ return seek(get_position() + position_offset);
}
+ };
+
+
+ class StreamReader_istream : public StreamReader
+ {
+ public:
+ StreamReader_istream(std::unique_ptr<std::istream>&& istr);
+
+ int64_t get_position() const override;
+
+ grow_status wait_for_file_size(int64_t target_size) override;
+
+ bool read(void* data, size_t size) override;
+
+ bool seek(int64_t position) override;
+
+ private:
+ std::unique_ptr<std::istream> m_istr;
+ int64_t m_length;
+ };
+
+
+ class StreamReader_memory : public StreamReader
+ {
+ public:
+ StreamReader_memory(const uint8_t* data, int64_t size, bool copy);
+ ~StreamReader_memory();
+
+ int64_t get_position() const override;
+
+ grow_status wait_for_file_size(int64_t target_size) override;
+
+ bool read(void* data, size_t size) override;
+
+ bool seek(int64_t position) override;
+
+ private:
+ const uint8_t* m_data;
+ int64_t m_length;
+ int64_t m_position;
+
+ // if we made a copy of the data, we store a pointer to the owned memory area here
+ uint8_t* m_owned_data = nullptr;
+ };
+
+
+ class StreamReader_CApi : public StreamReader
+ {
+ public:
+ StreamReader_CApi(const heif_reader* func_table, void* userdata);
+
+ int64_t get_position() const override { return m_func_table->get_position(m_userdata); }
+
+ StreamReader::grow_status wait_for_file_size(int64_t target_size) override;
+
+ bool read(void* data, size_t size) override { return !m_func_table->read(data,size,m_userdata); }
+ bool seek(int64_t position) override { return !m_func_table->seek(position,m_userdata); }
+
+ private:
+ const heif_reader* m_func_table;
+ void* m_userdata;
+ };
+
+
+ // This class simplifies safely reading part of a file (e.g. a box).
+ // It makes sure that we do not read past the boundaries of a box.
+ class BitstreamRange
+ {
+ public:
+ BitstreamRange(std::shared_ptr<StreamReader> istr,
+ uint64_t length,
+ BitstreamRange* parent = nullptr);
+
+ // This function tries to make sure that the full data of this range is
+ // available. You should call this before starting reading the range.
+ // If you don't, you have to make sure that you do not read past the available data.
+ StreamReader::grow_status wait_until_range_is_available();
uint8_t read8();
uint16_t read16();
uint32_t read32();
std::string read_string();
- bool read(int n) {
- if (n<0) {
- return false;
- }
- return read(static_cast<uint64_t>(n));
- }
-
- bool read(uint64_t n) {
- if (m_remaining >= n) {
- if (m_parent_range) {
- m_parent_range->read(n);
- }
-
- m_remaining -= n;
- m_end_reached = (m_remaining==0);
-
- return true;
- }
- else if (m_remaining==0) {
- m_error = true;
- return false;
- }
- else {
- if (m_parent_range) {
- m_parent_range->read(m_remaining);
- }
+ bool prepare_read(int64_t nBytes);
- m_istr->seekg(m_remaining, std::ios::cur);
- m_remaining = 0;
- m_end_reached = true;
- m_error = true;
- return false;
- }
- }
+ StreamReader::grow_status wait_for_available_bytes(int64_t nBytes);
void skip_to_end_of_file() {
- m_istr->seekg(0, std::ios_base::end);
+ // we do not actually move the file position here (because the stream may still be incomplete),
+ // but we set all m_remaining to zero
m_remaining = 0;
- m_end_reached = true;
+
+ if (m_parent_range) {
+ m_parent_range->skip_to_end_of_file();
+ }
}
void skip_to_end_of_box() {
- if (m_remaining) {
+ if (m_remaining>0) {
if (m_parent_range) {
- m_parent_range->read(m_remaining);
+ // also advance position in parent range
+ m_parent_range->skip_without_advancing_file_pos(m_remaining);
}
- m_istr->seekg(m_remaining, std::ios_base::cur);
+ m_istr->seek_cur(m_remaining);
m_remaining = 0;
}
-
- m_end_reached = true;
}
- void set_eof_reached() {
+ void set_eof_while_reading() {
m_remaining = 0;
- m_end_reached = true;
if (m_parent_range) {
- m_parent_range->set_eof_reached();
+ m_parent_range->set_eof_while_reading();
}
+
+ m_error = true;
}
bool eof() const {
- return m_end_reached;
+ return m_remaining == 0;
}
bool error() const {
@@ -136,31 +204,20 @@ namespace heif {
}
}
- std::istream* get_istream() { return m_istr; }
+ std::shared_ptr<StreamReader> get_istream() { return m_istr; }
int get_nesting_level() const { return m_nesting_level; }
- protected:
- void construct(std::istream* istr, uint64_t length, BitstreamRange* parent) {
- m_remaining = length;
- m_end_reached = (length==0);
-
- m_istr = istr;
- m_parent_range = parent;
-
- if (parent) {
- m_nesting_level = parent->m_nesting_level + 1;
- }
- }
-
private:
- std::istream* m_istr = nullptr;
+ std::shared_ptr<StreamReader> m_istr;
BitstreamRange* m_parent_range = nullptr;
int m_nesting_level = 0;
- uint64_t m_remaining;
- bool m_end_reached = false;
+ int64_t m_remaining;
bool m_error = false;
+
+ // Note: 'nBytes' may not be larger than the number of remaining bytes
+ void skip_without_advancing_file_pos(int64_t nBytes);
};
diff --git a/libheif/box.cc b/libheif/box.cc
index 2a86606..88be416 100644
--- a/libheif/box.cc
+++ b/libheif/box.cc
@@ -157,12 +157,27 @@ std::string heif::BoxHeader::get_type_string() const
heif::Error heif::BoxHeader::parse(BitstreamRange& range)
{
+ StreamReader::grow_status status;
+ status = range.wait_for_available_bytes(8);
+ if (status != StreamReader::size_reached) {
+ // TODO: return recoverable error at timeout
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data);
+ }
+
m_size = range.read32();
m_type = range.read32();
m_header_size = 8;
if (m_size==1) {
+ status = range.wait_for_available_bytes(8);
+ if (status != StreamReader::size_reached) {
+ // TODO: return recoverable error at timeout
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data);
+ }
+
uint64_t high = range.read32();
uint64_t low = range.read32();
@@ -171,7 +186,14 @@ heif::Error heif::BoxHeader::parse(BitstreamRange& range)
}
if (m_type==fourcc("uuid")) {
- if (range.read(16)) {
+ status = range.wait_for_available_bytes(16);
+ if (status != StreamReader::size_reached) {
+ // TODO: return recoverable error at timeout
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data);
+ }
+
+ if (range.prepare_read(16)) {
m_uuid_type.resize(16);
range.get_istream()->read((char*)m_uuid_type.data(), 16);
}
@@ -287,13 +309,13 @@ Error Box::parse(BitstreamRange& range)
}
else {
uint64_t content_size = get_box_size() - get_header_size();
- if (range.read(content_size)) {
+ if (range.prepare_read(content_size)) {
if (content_size > MAX_BOX_SIZE) {
return Error(heif_error_Invalid_input,
heif_suberror_Invalid_box_size);
}
- range.get_istream()->seekg(get_box_size() - get_header_size(), std::ios_base::cur);
+ range.get_istream()->seek_cur(get_box_size() - get_header_size());
}
}
@@ -440,6 +462,13 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<heif::Box>* result)
}
+ auto status = range.wait_for_available_bytes( hdr.get_box_size() - hdr.get_header_size() );
+ if (status != StreamReader::size_reached) {
+ // TODO: return recoverable error at timeout
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data);
+ }
+
BitstreamRange boxrange(range.get_istream(),
hdr.get_box_size() - hdr.get_header_size(),
&range);
@@ -950,27 +979,17 @@ std::string Box_iloc::dump(Indent& indent) const
}
-Error Box_iloc::read_data(const Item& item, std::istream& istr,
+Error Box_iloc::read_data(const Item& item,
+ std::shared_ptr<StreamReader> istr,
const std::shared_ptr<Box_idat>& idat,
std::vector<uint8_t>* dest) const
{
- istr.clear();
+ //istr.clear();
for (const auto& extent : item.extents) {
if (item.construction_method == 0) {
- istr.seekg(extent.offset + item.base_offset, std::ios::beg);
- if (istr.eof()) {
- // Out-of-bounds
- dest->clear();
- std::stringstream sstr;
- sstr << "Extent in iloc box references data outside of file bounds "
- << "(points to file position " << extent.offset + item.base_offset << ")\n";
-
- return Error(heif_error_Invalid_input,
- heif_suberror_End_of_data,
- sstr.str());
- }
+ // --- security check that we do not allocate too much memory
size_t old_size = dest->size();
if (MAX_MEMORY_BLOCK_SIZE - old_size < extent.length) {
@@ -984,12 +1003,41 @@ Error Box_iloc::read_data(const Item& item, std::istream& istr,
sstr.str());
}
- dest->resize(static_cast<size_t>(old_size + extent.length));
- istr.read((char*)dest->data() + old_size, static_cast<size_t>(extent.length));
- if (istr.eof()) {
- return Error(heif_error_Invalid_input,
- heif_suberror_End_of_data);
+
+ // --- make sure that all data is available
+
+ StreamReader::grow_status status = istr->wait_for_file_size(extent.offset + item.base_offset + extent.length);
+ if (status == StreamReader::size_beyond_eof) {
+ // Out-of-bounds
+ // TODO: I think we should not clear this. Maybe we want to try reading again later and
+ // hence should not lose the data already read.
+ dest->clear();
+
+ std::stringstream sstr;
+ sstr << "Extent in iloc box references data outside of file bounds "
+ << "(points to file position " << extent.offset + item.base_offset << ")\n";
+
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data,
+ sstr.str());
+ }
+ else if (status == StreamReader::timeout) {
+ // TODO: maybe we should introduce some 'Recoverable error' instead of 'Invalid input'
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data);
}
+
+ // --- move file pointer to start of data
+
+ bool success = istr->seek(extent.offset + item.base_offset);
+ assert(success);
+
+
+ // --- read data
+
+ dest->resize(static_cast<size_t>(old_size + extent.length));
+ success = istr->read((char*)dest->data() + old_size, static_cast<size_t>(extent.length));
+ assert(success);
}
else if (item.construction_method==1) {
if (!idat) {
@@ -2154,7 +2202,7 @@ Error Box_hvcC::parse(BitstreamRange& range)
continue;
}
- if (range.read(size)) {
+ if (range.prepare_read(size)) {
nal_unit.resize(size);
range.get_istream()->read((char*)nal_unit.data(), size);
}
@@ -2318,7 +2366,7 @@ Error Box_hvcC::write(StreamWriter& writer) const
}
writer.write8(c.general_level_idc);
- writer.write16(c.min_spatial_segmentation_idc & 0x0FFF);
+ writer.write16((c.min_spatial_segmentation_idc & 0x0FFF) | 0xF000);
writer.write8(c.parallelism_type | 0xFC);
writer.write8(c.chroma_format | 0xFC);
writer.write8((uint8_t)((c.bit_depth_luma - 8) | 0xF8));
@@ -2365,7 +2413,7 @@ Error Box_idat::parse(BitstreamRange& range)
{
//parse_full_box_header(range);
- m_data_start_pos = range.get_istream()->tellg();
+ m_data_start_pos = range.get_istream()->get_position();
return range.get_error();
}
@@ -2382,13 +2430,12 @@ std::string Box_idat::dump(Indent& indent) const
}
-Error Box_idat::read_data(std::istream& istr, uint64_t start, uint64_t length,
+Error Box_idat::read_data(std::shared_ptr<StreamReader> istr,
+ uint64_t start, uint64_t length,
std::vector<uint8_t>& out_data) const
{
- // move to start of data
- istr.seekg(m_data_start_pos + (std::streampos)start, std::ios_base::beg);
+ // --- security check that we do not allocate too much data
- // reserve space for the data in the output array
auto curr_size = out_data.size();
if (MAX_MEMORY_BLOCK_SIZE - curr_size < length) {
@@ -2402,10 +2449,28 @@ Error Box_idat::read_data(std::istream& istr, uint64_t start, uint64_t length,
sstr.str());
}
+
+ // move to start of data
+
+ StreamReader::grow_status status = istr->wait_for_file_size((int64_t)m_data_start_pos + start + length);
+ if (status == StreamReader::size_beyond_eof ||
+ status == StreamReader::timeout) {
+ // TODO: maybe we should introduce some 'Recoverable error' instead of 'Invalid input'
+ return Error(heif_error_Invalid_input,
+ heif_suberror_End_of_data);
+ }
+
+ bool success;
+ success = istr->seek(m_data_start_pos + (std::streampos)start);
+ assert(success);
+
+ // reserve space for the data in the output array
+
out_data.resize(static_cast<size_t>(curr_size + length));
uint8_t* data = &out_data[curr_size];
- istr.read((char*)data, static_cast<size_t>(length));
+ success = istr->read((char*)data, static_cast<size_t>(length));
+ assert(success);
return Error::Ok;
}
diff --git a/libheif/box.h b/libheif/box.h
index f2f87d9..75d1fb1 100644
--- a/libheif/box.h
+++ b/libheif/box.h
@@ -299,7 +299,8 @@ namespace heif {
const std::vector<Item>& get_items() const { return m_items; }
- Error read_data(const Item& item, std::istream& istr,
+ Error read_data(const Item& item,
+ std::shared_ptr<StreamReader> istr,
const std::shared_ptr<class Box_idat>&,
std::vector<uint8_t>* dest) const;
@@ -366,6 +367,8 @@ namespace heif {
std::string get_content_type() const { return m_content_type; }
+ void set_content_type(std::string content_type) { m_content_type = content_type; }
+
void derive_box_version() override;
Error write(StreamWriter& writer) const override;
@@ -682,7 +685,8 @@ namespace heif {
std::string dump(Indent&) const override;
- Error read_data(std::istream& istr, uint64_t start, uint64_t length,
+ Error read_data(std::shared_ptr<StreamReader> istr,
+ uint64_t start, uint64_t length,
std::vector<uint8_t>& out_data) const;
protected:
diff --git a/libheif/box_fuzzer.cc b/libheif/box_fuzzer.cc
index 5e64a73..eb3d7aa 100644
--- a/libheif/box_fuzzer.cc
+++ b/libheif/box_fuzzer.cc
@@ -21,11 +21,12 @@
#include <sstream>
#include "box.h"
+#include "bitstream.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- std::string s(size ? reinterpret_cast<const char*>(data) : nullptr, size);
- std::istringstream stream(s);
- heif::BitstreamRange range(&stream, size);
+ auto reader = std::make_shared<heif::StreamReader_memory>(data, size, false);
+
+ heif::BitstreamRange range(reader, size);
for (;;) {
std::shared_ptr<heif::Box> box;
heif::Error error = heif::Box::read(range, &box);
@@ -33,5 +34,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
break;
}
}
+
return 0;
}
diff --git a/libheif/heif.cc b/libheif/heif.cc
index 2022e9a..954a007 100644
--- a/libheif/heif.cc
+++ b/libheif/heif.cc
@@ -104,7 +104,25 @@ heif_error heif_context_read_from_file(heif_context* ctx, const char* filename,
heif_error heif_context_read_from_memory(heif_context* ctx, const void* mem, size_t size,
const struct heif_reading_options*)
{
- Error err = ctx->context->read_from_memory(mem, size);
+ Error err = ctx->context->read_from_memory(mem, size, true);
+ return err.error_struct(ctx->context.get());
+}
+
+heif_error heif_context_read_from_memory_without_copy(heif_context* ctx, const void* mem, size_t size,
+ const struct heif_reading_options*)
+{
+ Error err = ctx->context->read_from_memory(mem, size, false);
+ return err.error_struct(ctx->context.get());
+}
+
+heif_error heif_context_read_from_reader(struct heif_context* ctx,
+ const struct heif_reader* reader_func_table,
+ void* userdata,
+ const struct heif_reading_options*)
+{
+ auto reader = std::make_shared<StreamReader_CApi>(reader_func_table, userdata);
+
+ Error err = ctx->context->read(reader);
return err.error_struct(ctx->context.get());
}
@@ -855,6 +873,20 @@ struct heif_error heif_context_get_encoder(struct heif_context* context,
}
+int heif_have_decoder_for_format(enum heif_compression_format format)
+{
+ auto plugin = heif::get_decoder(format);
+ return plugin != nullptr;
+}
+
+
+int heif_have_encoder_for_format(enum heif_compression_format format)
+{
+ auto plugin = heif::get_encoder(format);
+ return plugin != nullptr;
+}
+
+
struct heif_error heif_context_get_encoder_for_format(struct heif_context* context,
enum heif_compression_format format,
struct heif_encoder** encoder)
@@ -1186,6 +1218,29 @@ struct heif_error heif_encoder_get_parameter(struct heif_encoder* encoder,
}
+static void set_default_options(heif_encoding_options& options)
+{
+ options.version = 1;
+
+ options.save_alpha_channel = true;
+}
+
+
+heif_encoding_options* heif_encoding_options_alloc()
+{
+ auto options = new heif_encoding_options;
+
+ set_default_options(*options);
+
+ return options;
+}
+
+
+void heif_encoding_options_free(heif_encoding_options* options)
+{
+ delete options;
+}
+
struct heif_error heif_context_encode_image(struct heif_context* ctx,
const struct heif_image* input_image,
struct heif_encoder* encoder,
@@ -1197,30 +1252,126 @@ struct heif_error heif_context_encode_image(struct heif_context* ctx,
heif_suberror_Null_pointer_argument).error_struct(ctx->context.get());
}
- std::shared_ptr<HeifContext::Image> image;
- Error error(heif_error_Encoder_plugin_error, heif_suberror_Unsupported_codec);
+ heif_encoding_options default_options;
+ if (options==nullptr) {
+ set_default_options(default_options);
+ options = &default_options;
+ }
- switch (encoder->plugin->compression_format) {
- case heif_compression_HEVC:
- image = ctx->context->add_new_hvc1_image();
- error = image->encode_image_as_hevc(input_image->image, encoder,
- heif_image_input_class_normal);
- break;
+ std::shared_ptr<HeifContext::Image> image;
+ Error error;
- default:
- // Will return "heif_suberror_Unsupported_codec" from above.
- break;
- }
+ error = ctx->context->encode_image(input_image->image,
+ encoder,
+ options,
+ heif_image_input_class_normal,
+ image);
if (error != Error::Ok) {
return error.error_struct(ctx->context.get());
}
- ctx->context->set_primary_image(image);
+
+ // mark the new image as primary image
+
+ if (ctx->context->is_primary_image_set() == false) {
+ ctx->context->set_primary_image(image);
+ }
if (out_image_handle) {
*out_image_handle = new heif_image_handle;
(*out_image_handle)->image = image;
}
- struct heif_error err = { heif_error_Ok, heif_suberror_Unspecified, kSuccess };
- return err;
+ return error_Ok;
+}
+
+
+struct heif_error heif_context_assign_thumbnail(struct heif_context* ctx,
+ const struct heif_image_handle* thumbnail_image,
+ const struct heif_image_handle* master_image)
+{
+ Error error = ctx->context->assign_thumbnail(thumbnail_image->image, master_image->image);
+ return error.error_struct(ctx->context.get());
+}
+
+
+struct heif_error heif_context_encode_thumbnail(struct heif_context* ctx,
+ const struct heif_image* image,
+ const struct heif_image_handle* image_handle,
+ struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
+ int bbox_size,
+ struct heif_image_handle** out_image_handle)
+{
+ std::shared_ptr<HeifContext::Image> thumbnail_image;
+
+ heif_encoding_options default_options;
+ if (options==nullptr) {
+ set_default_options(default_options);
+ options = &default_options;
+ }
+
+ Error error = ctx->context->encode_thumbnail(image->image,
+ encoder,
+ options,
+ bbox_size,
+ thumbnail_image);
+ if (error != Error::Ok) {
+ return error.error_struct(ctx->context.get());
+ }
+
+
+ error = ctx->context->assign_thumbnail(image_handle->image, thumbnail_image);
+ if (error != Error::Ok) {
+ return error.error_struct(ctx->context.get());
+ }
+
+
+ if (out_image_handle) {
+ if (thumbnail_image) {
+ *out_image_handle = new heif_image_handle;
+ (*out_image_handle)->image = thumbnail_image;
+ }
+ else {
+ *out_image_handle = nullptr;
+ }
+ }
+
+ return error_Ok;
+}
+
+
+struct heif_error heif_context_set_primary_image(struct heif_context* ctx,
+ struct heif_image_handle* image_handle)
+{
+ ctx->context->set_primary_image(image_handle->image);
+
+ return error_Ok;
+}
+
+
+struct heif_error heif_context_add_exif_metadata(struct heif_context* ctx,
+ const struct heif_image_handle* image_handle,
+ const void* data, int size)
+{
+ Error error = ctx->context->add_exif_metadata(image_handle->image, data, size);
+ if (error != Error::Ok) {
+ return error.error_struct(ctx->context.get());
+ }
+ else {
+ return error_Ok;
+ }
+}
+
+
+struct heif_error heif_context_add_XMP_metadata(struct heif_context* ctx,
+ const struct heif_image_handle* image_handle,
+ const void* data, int size)
+{
+ Error error = ctx->context->add_XMP_metadata(image_handle->image, data, size);
+ if (error != Error::Ok) {
+ return error.error_struct(ctx->context.get());
+ }
+ else {
+ return error_Ok;
+ }
}
diff --git a/libheif/heif.h b/libheif/heif.h
index 7080256..396adb5 100644
--- a/libheif/heif.h
+++ b/libheif/heif.h
@@ -28,16 +28,16 @@ extern "C" {
#include <stddef.h>
#include <stdint.h>
-#include "heif_version.h"
+#include <libheif/heif_version.h>
// API versions table
//
-// release depth.rep dec.options heif_writer
-// ------------------------------------------------
-// 1.0 1 1 N/A
-// 1.1 1 1 1
-
+// release depth.rep dec.options enc.options heif_reader heif_writer
+// ------------------------------------------------------------------------------
+// 1.0 1 1 N/A N/A N/A
+// 1.1 1 1 N/A N/A 1
+// 1.3 1 1 1 1 1
#if defined(_MSC_VER) && !defined(LIBHEIF_STATIC_BUILD)
@@ -273,6 +273,39 @@ void heif_context_free(struct heif_context*);
struct heif_reading_options;
+enum heif_reader_grow_status {
+ heif_reader_grow_status_size_reached, // requested size has been reached, we can read until this point
+ heif_reader_grow_status_timeout, // size has not been reached yet, but it may still grow further
+ heif_reader_grow_status_size_beyond_eof // size has not been reached and never will. The file has grown to its full size
+};
+
+struct heif_reader {
+ // API version supported by this reader
+ int reader_api_version;
+
+ // --- version 1 functions ---
+ int64_t (*get_position)(void* userdata);
+
+ // The functions read(), and seek() return 0 on success.
+ // Generally, libheif will make sure that we do not read past the file size.
+ int (*read)(void* data,
+ size_t size,
+ void* userdata);
+ int (*seek)(int64_t position,
+ void* userdata);
+
+ // When calling this function, libheif wants to make sure that it can read the file
+ // up to 'target_size'. This is useful when the file is currently downloaded and may
+ // grow with time. You may, for example, extract the image sizes even before the actual
+ // compressed image data has been completely downloaded.
+ //
+ // Even if your input files will not grow, you will have to implement at least
+ // detection whether the target_size is above the (fixed) file length
+ // (in this case, return 'size_beyond_eof').
+ enum heif_reader_grow_status (*wait_for_file_size)(int64_t target_size, void* userdata);
+};
+
+
// Read a HEIF file from a named disk file.
// The heif_reading_options should currently be set to NULL.
LIBHEIF_API
@@ -281,11 +314,25 @@ struct heif_error heif_context_read_from_file(struct heif_context*, const char*
// Read a HEIF file stored completely in memory.
// The heif_reading_options should currently be set to NULL.
+// DEPRECATED: use heif_context_read_from_memory_without_copy() instead.
LIBHEIF_API
struct heif_error heif_context_read_from_memory(struct heif_context*,
const void* mem, size_t size,
const struct heif_reading_options*);
+// Same as heif_context_read_from_memory() except that the provided memory is not copied.
+// That means, you will have to keep the memory area alive as long as you use the heif_context.
+LIBHEIF_API
+struct heif_error heif_context_read_from_memory_without_copy(struct heif_context*,
+ const void* mem, size_t size,
+ const struct heif_reading_options*);
+
+LIBHEIF_API
+struct heif_error heif_context_read_from_reader(struct heif_context*,
+ const struct heif_reader* reader,
+ void* userdata,
+ const struct heif_reading_options*);
+
// Number of top-level images in the HEIF file. This does not include the thumbnails or the
// tile images that are composed to an image grid. You can get access to the thumbnails via
// the main image handle.
@@ -701,6 +748,18 @@ struct heif_error heif_context_get_encoder(struct heif_context* context,
const struct heif_encoder_descriptor*,
struct heif_encoder** out_encoder);
+// Quick check whether there is a decoder available for the given format.
+// Note that the decoder still may not be able to decode all variants of that format.
+// You will have to query that further (todo) or just try to decode and check the returned error.
+LIBHEIF_API
+int heif_have_decoder_for_format(enum heif_compression_format format);
+
+// Quick check whether there is an enoder available for the given format.
+// Note that the encoder may be limited to a certain subset of features (e.g. only 8 bit, only lossy).
+// You will have to query the specific capabilities further.
+LIBHEIF_API
+int heif_have_encoder_for_format(enum heif_compression_format format);
+
// Get an encoder for the given compression format. If there are several encoder plugins
// for this format, the encoder with the highest plugin priority will be returned.
// TODO: why do we need the context here? I think we should remove this. You may pass a NULL context.
@@ -830,11 +889,26 @@ struct heif_error heif_encoder_get_parameter(struct heif_encoder*,
char* value_ptr, int value_size);
-struct heif_encoding_options;
+struct heif_encoding_options {
+ uint8_t version;
+
+ // version 1 options
+
+ uint8_t save_alpha_channel; // default: true
+};
+
+LIBHEIF_API
+struct heif_encoding_options* heif_encoding_options_alloc();
+
+LIBHEIF_API
+void heif_encoding_options_free(struct heif_encoding_options*);
+
// Compress the input image.
// Returns a handle to the coded image in 'out_image_handle' unless out_image_handle = NULL.
// 'options' should be NULL for now.
+// The first image added to the context is also automatically set the primary image, but
+// you can change the primary image later with heif_context_set_primary_image().
LIBHEIF_API
struct heif_error heif_context_encode_image(struct heif_context*,
const struct heif_image* image,
@@ -842,6 +916,44 @@ struct heif_error heif_context_encode_image(struct heif_context*,
const struct heif_encoding_options* options,
struct heif_image_handle** out_image_handle);
+LIBHEIF_API
+struct heif_error heif_context_set_primary_image(struct heif_context*,
+ struct heif_image_handle* image_handle);
+
+// Encode the 'image' as a scaled down thumbnail image.
+// The image is scaled down to fit into a square area of width 'bbox_size'.
+// If the input image is already so small that it fits into this bounding box, no thumbnail
+// image is encoded and NULL is returned in 'out_thumb_image_handle'.
+// No error is returned in this case.
+// The encoded thumbnail is automatically assigned to the 'master_image_handle'. Hence, you
+// do not have to call heif_context_assign_thumbnail().
+LIBHEIF_API
+struct heif_error heif_context_encode_thumbnail(struct heif_context*,
+ const struct heif_image* image,
+ const struct heif_image_handle* master_image_handle,
+ struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
+ int bbox_size,
+ struct heif_image_handle** out_thumb_image_handle);
+
+// Assign 'thumbnail_image' as the thumbnail image of 'master_image'.
+LIBHEIF_API
+struct heif_error heif_context_assign_thumbnail(struct heif_context*,
+ const struct heif_image_handle* thumbnail_image,
+ const struct heif_image_handle* master_image);
+
+// Add EXIF metadata to an image. The raw EXIF metadata shall begin with the TIFF header.
+LIBHEIF_API
+struct heif_error heif_context_add_exif_metadata(struct heif_context*,
+ const struct heif_image_handle* image_handle,
+ const void* data, int size);
+
+// Add XMP metadata to an image.
+LIBHEIF_API
+struct heif_error heif_context_add_XMP_metadata(struct heif_context*,
+ const struct heif_image_handle* image_handle,
+ const void* data, int size);
+
// --- heif_image allocation
diff --git a/libheif/heif_context.cc b/libheif/heif_context.cc
index f85987d..25b07d3 100644
--- a/libheif/heif_context.cc
+++ b/libheif/heif_context.cc
@@ -29,6 +29,7 @@
#include <limits>
#include <utility>
#include <math.h>
+#include <deque>
#if ENABLE_PARALLEL_TILE_DECODING
#include <future>
@@ -42,14 +43,6 @@
#include "heif_hevc.h"
#include "heif_plugin_registry.h"
-#if HAVE_LIBDE265
-#include "heif_decoder_libde265.h"
-#endif
-
-#if HAVE_X265
-#include "heif_encoder_x265.h"
-#endif
-
using namespace heif;
@@ -329,14 +322,6 @@ void ImageOverlay::get_offset(size_t image_index, int32_t* x, int32_t* y) const
HeifContext::HeifContext()
{
-#if HAVE_LIBDE265
- heif::register_decoder(get_decoder_plugin_libde265());
-#endif
-
-#if HAVE_X265
- heif::register_encoder(get_encoder_plugin_x265());
-#endif
-
reset_to_empty_heif();
}
@@ -344,6 +329,17 @@ HeifContext::~HeifContext()
{
}
+Error HeifContext::read(std::shared_ptr<StreamReader> reader)
+{
+ m_heif_file = std::make_shared<HeifFile>();
+ Error err = m_heif_file->read(reader);
+ if (err) {
+ return err;
+ }
+
+ return interpret_heif_file();
+}
+
Error HeifContext::read_from_file(const char* input_filename)
{
m_heif_file = std::make_shared<HeifFile>();
@@ -355,10 +351,10 @@ Error HeifContext::read_from_file(const char* input_filename)
return interpret_heif_file();
}
-Error HeifContext::read_from_memory(const void* data, size_t size)
+Error HeifContext::read_from_memory(const void* data, size_t size, bool copy)
{
m_heif_file = std::make_shared<HeifFile>();
- Error err = m_heif_file->read_from_memory(data,size);
+ Error err = m_heif_file->read_from_memory(data,size, copy);
if (err) {
return err;
}
@@ -404,12 +400,9 @@ const struct heif_decoder_plugin* HeifContext::get_decoder(enum heif_compression
// search global plugins
- for (const auto* plugin : s_decoder_plugins) {
- int priority = plugin->does_support_format(type);
- if (priority > highest_priority) {
- highest_priority = priority;
- best_plugin = plugin;
- }
+ best_plugin = heif::get_decoder(type);
+ if (best_plugin != nullptr) {
+ highest_priority = best_plugin->does_support_format(type);
}
@@ -1013,9 +1006,18 @@ Error HeifContext::decode_full_grid_image(heif_item_id ID,
int y0=0;
int reference_idx = 0;
+
#if ENABLE_PARALLEL_TILE_DECODING
- std::vector<std::future<Error> > errs;
- errs.resize(grid.get_rows() * grid.get_columns() );
+ // remember which tile to put where into the image
+ struct tile_data {
+ heif_item_id tileID;
+ int x_origin,y_origin;
+ };
+
+ std::deque<tile_data> tiles;
+ tiles.resize(grid.get_rows() * grid.get_columns() );
+
+ std::deque<std::future<Error> > errs;
#endif
for (int y=0;y<grid.get_rows();y++) {
@@ -1031,9 +1033,7 @@ Error HeifContext::decode_full_grid_image(heif_item_id ID,
int src_height = tileImg->get_height();
#if ENABLE_PARALLEL_TILE_DECODING
- errs[x+y*grid.get_columns()] = std::async(std::launch::async,
- &HeifContext::decode_and_paste_tile_image, this,
- tileID, img, x0,y0);
+ tiles[x+y*grid.get_columns()] = tile_data { tileID, x0,y0 };
#else
Error err = decode_and_paste_tile_image(tileID, img, x0,y0);
if (err) {
@@ -1051,13 +1051,42 @@ Error HeifContext::decode_full_grid_image(heif_item_id ID,
}
#if ENABLE_PARALLEL_TILE_DECODING
- // check for decoding errors in all decoded tiles
+ // Process all tiles in a set of background threads.
+ // Do not start more than the maximum number of threads.
+
+ while (tiles.empty()==false) {
+
+ // If maximum number of threads running, wait until first thread finishes
+
+ if (errs.size() >= (size_t)m_max_decoding_threads) {
+ Error e = errs.front().get();
+ if (e) {
+ return e;
+ }
+
+ errs.pop_front();
+ }
+
+
+ // Start a new decoding thread
+
+ tile_data data = tiles.front();
+ tiles.pop_front();
+
+ errs.push_back( std::async(std::launch::async,
+ &HeifContext::decode_and_paste_tile_image, this,
+ data.tileID, img, data.x_origin,data.y_origin) );
+ }
+
+ // check for decoding errors in remaining tiles
- for (int i=0;i<grid.get_rows() * grid.get_columns();i++) {
- Error e = errs[i].get();
+ while (errs.empty() == false) {
+ Error e = errs.front().get();
if (e) {
return e;
}
+
+ errs.pop_front();
}
#endif
@@ -1248,29 +1277,9 @@ Error HeifContext::decode_overlay_image(heif_item_id ID,
}
-std::shared_ptr<HeifContext::Image> HeifContext::add_new_hvc1_image()
-{
- heif_item_id image_id = m_heif_file->add_new_image("hvc1");
-
- auto image = std::make_shared<Image>(this, image_id);
-
- m_top_level_images.push_back(image);
-
- return image;
-}
-
-
-Error HeifContext::add_alpha_image(std::shared_ptr<HeifPixelImage> image, heif_item_id* out_item_id,
- struct heif_encoder* encoder)
+static std::shared_ptr<HeifPixelImage>
+create_alpha_image_from_image_alpha_channel(const std::shared_ptr<HeifPixelImage> image)
{
- std::shared_ptr<HeifContext::Image> heif_alpha_image;
-
- heif_alpha_image = add_new_hvc1_image();
-
- assert(out_item_id);
- *out_item_id = heif_alpha_image->get_id();
-
-
// --- generate alpha image
// TODO: can we directly code a monochrome image instead of the dummy color channels?
@@ -1284,16 +1293,10 @@ Error HeifContext::add_alpha_image(std::shared_ptr<HeifPixelImage> image, heif_i
alpha_image->fill_new_plane(heif_channel_Cb, 128, chroma_width, chroma_height);
alpha_image->fill_new_plane(heif_channel_Cr, 128, chroma_width, chroma_height);
-
- // --- encode the alpha image
-
- Error error = heif_alpha_image->encode_image_as_hevc(alpha_image, encoder,
- heif_image_input_class_alpha);
- return error;
+ return alpha_image;
}
-
void HeifContext::Image::set_preencoded_hevc_image(const std::vector<uint8_t>& data)
{
m_heif_context->m_heif_file->add_hvcC_property(m_id);
@@ -1393,8 +1396,40 @@ void HeifContext::Image::set_preencoded_hevc_image(const std::vector<uint8_t>& d
}
+Error HeifContext::encode_image(std::shared_ptr<HeifPixelImage> pixel_image,
+ struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
+ enum heif_image_input_class input_class,
+ std::shared_ptr<Image>& out_image)
+{
+ Error error;
+
+ switch (encoder->plugin->compression_format) {
+ case heif_compression_HEVC:
+ {
+ heif_item_id image_id = m_heif_file->add_new_image("hvc1");
+
+ out_image = std::make_shared<Image>(this, image_id);
+ m_top_level_images.push_back(out_image);
+
+ error = out_image->encode_image_as_hevc(pixel_image,
+ encoder,
+ options,
+ heif_image_input_class_normal);
+ }
+ break;
+
+ default:
+ return Error(heif_error_Encoder_plugin_error, heif_suberror_Unsupported_codec);
+ }
+
+ return error;
+}
+
+
Error HeifContext::Image::encode_image_as_hevc(std::shared_ptr<HeifPixelImage> image,
struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
enum heif_image_input_class input_class)
{
/*
@@ -1423,14 +1458,33 @@ Error HeifContext::Image::encode_image_as_hevc(std::shared_ptr<HeifPixelImage> i
}
+ m_width = image->get_width(heif_channel_Y);
+ m_height = image->get_height(heif_channel_Y);
+
// --- if there is an alpha channel, add it as an additional image
- if (image->has_channel(heif_channel_Alpha)) {
- heif_item_id alpha_image_id;
- Error err = m_heif_context->add_alpha_image(image, &alpha_image_id, encoder);
- if (err) {
- return err;
+ if (options->save_alpha_channel && image->has_channel(heif_channel_Alpha)) {
+
+ // --- generate alpha image
+ // TODO: can we directly code a monochrome image instead of the dummy color channels?
+
+ std::shared_ptr<HeifPixelImage> alpha_image;
+ alpha_image = create_alpha_image_from_image_alpha_channel(image);
+
+
+ // --- encode the alpha image
+
+ heif_item_id alpha_image_id = m_heif_context->m_heif_file->add_new_image("hvc1");
+
+ std::shared_ptr<HeifContext::Image> heif_alpha_image;
+ heif_alpha_image = std::make_shared<Image>(m_heif_context, alpha_image_id);
+
+
+ Error error = heif_alpha_image->encode_image_as_hevc(alpha_image, encoder, options,
+ heif_image_input_class_alpha);
+ if (error) {
+ return error;
}
m_heif_context->m_heif_file->add_iref_reference(alpha_image_id, fourcc("auxl"), { m_id });
@@ -1503,3 +1557,143 @@ void HeifContext::set_primary_image(std::shared_ptr<Image> image)
m_heif_file->set_primary_item_id(image->get_id());
}
+
+
+Error HeifContext::set_primary_item(heif_item_id id)
+{
+ auto iter = m_all_images.find(id);
+ if (iter == m_all_images.end()) {
+ return Error(heif_error_Usage_error,
+ heif_suberror_No_or_invalid_primary_item,
+ "Cannot set primary item as the ID does not exist.");
+ }
+
+ set_primary_image(iter->second);
+
+ return Error::Ok;
+}
+
+
+Error HeifContext::assign_thumbnail(std::shared_ptr<Image> master_image,
+ std::shared_ptr<Image> thumbnail_image)
+{
+ m_heif_file->add_iref_reference(thumbnail_image->get_id(),
+ fourcc("thmb"), { master_image->get_id() });
+
+ return Error::Ok;
+}
+
+
+Error HeifContext::encode_thumbnail(std::shared_ptr<HeifPixelImage> image,
+ struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
+ int bbox_size,
+ std::shared_ptr<Image>& out_thumbnail_handle)
+{
+ Error error;
+
+ int orig_width = image->get_width();
+ int orig_height = image->get_height();
+
+ int thumb_width, thumb_height;
+
+ if (orig_width <= bbox_size && orig_height <= bbox_size) {
+ // original image is smaller than thumbnail size -> do not encode any thumbnail
+
+ out_thumbnail_handle.reset();
+ return Error::Ok;
+ }
+ else if (orig_width > orig_height) {
+ thumb_height = orig_height * bbox_size / orig_width;
+ thumb_width = bbox_size;
+ }
+ else {
+ thumb_width = orig_width * bbox_size / orig_height;
+ thumb_height = bbox_size;
+ }
+
+
+ // round size to even width and height
+
+ thumb_width &= ~1;
+ thumb_height &= ~1;
+
+
+ std::shared_ptr<HeifPixelImage> thumbnail_image;
+ error = image->scale_nearest_neighbor(thumbnail_image, thumb_width, thumb_height);
+ if (error) {
+ return error;
+ }
+
+ error = encode_image(thumbnail_image,
+ encoder, options,
+ heif_image_input_class_thumbnail,
+ out_thumbnail_handle);
+ if (error) {
+ return error;
+ }
+
+ return error;
+}
+
+
+Error HeifContext::add_exif_metadata(std::shared_ptr<Image> master_image, const void* data, int size)
+{
+ // create an infe box describing what kind of data we are storing (this also creates a new ID)
+
+ auto metadata_infe_box = m_heif_file->add_new_infe_box("Exif");
+ metadata_infe_box->set_hidden_item(true);
+
+ heif_item_id metadata_id = metadata_infe_box->get_item_ID();
+
+
+ // we assign this data to the image
+
+ m_heif_file->add_iref_reference(metadata_id,
+ fourcc("cdsc"), { master_image->get_id() });
+
+
+ // copy the Exif data into the file, store the pointer to it in an iloc box entry
+
+ std::vector<uint8_t> data_array;
+ data_array.resize(size+4);
+ data_array[0] = 0;
+ data_array[1] = 0;
+ data_array[2] = 0;
+ data_array[3] = 0;
+ memcpy(data_array.data()+4, data, size);
+
+ m_heif_file->append_iloc_data(metadata_id, data_array);
+
+ return Error::Ok;
+}
+
+
+
+Error HeifContext::add_XMP_metadata(std::shared_ptr<Image> master_image, const void* data, int size)
+{
+ // create an infe box describing what kind of data we are storing (this also creates a new ID)
+
+ auto metadata_infe_box = m_heif_file->add_new_infe_box("mime");
+ metadata_infe_box->set_content_type("application/rdf+xml");
+ metadata_infe_box->set_hidden_item(true);
+
+ heif_item_id metadata_id = metadata_infe_box->get_item_ID();
+
+
+ // we assign this data to the image
+
+ m_heif_file->add_iref_reference(metadata_id,
+ fourcc("cdsc"), { master_image->get_id() });
+
+
+ // copy the XMP data into the file, store the pointer to it in an iloc box entry
+
+ std::vector<uint8_t> data_array;
+ data_array.resize(size);
+ memcpy(data_array.data(), data, size);
+
+ m_heif_file->append_iloc_data(metadata_id, data_array);
+
+ return Error::Ok;
+}
diff --git a/libheif/heif_context.h b/libheif/heif_context.h
index f50fa4d..1b5db78 100644
--- a/libheif/heif_context.h
+++ b/libheif/heif_context.h
@@ -31,6 +31,7 @@
#include "heif.h"
#include "heif_plugin.h"
+#include "bitstream.h"
namespace heif {
class HeifContext;
@@ -62,8 +63,11 @@ namespace heif {
HeifContext();
~HeifContext();
+ void set_max_decoding_threads(int max_threads) { m_max_decoding_threads = max_threads; }
+
+ Error read(std::shared_ptr<StreamReader> reader);
Error read_from_file(const char* input_filename);
- Error read_from_memory(const void* data, size_t size);
+ Error read_from_memory(const void* data, size_t size, bool copy);
class Image : public ErrorBuffer {
public:
@@ -145,6 +149,7 @@ namespace heif {
Error encode_image_as_hevc(std::shared_ptr<HeifPixelImage> image,
struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
enum heif_image_input_class input_class);
private:
@@ -193,14 +198,31 @@ namespace heif {
// contain no valid data yet.
void reset_to_empty_heif();
- std::shared_ptr<Image> add_new_hvc1_image();
-
- Error add_alpha_image(std::shared_ptr<HeifPixelImage> image,
- heif_item_id* out_item_id,
- struct heif_encoder* encoder);
+ Error encode_image(std::shared_ptr<HeifPixelImage> image,
+ struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
+ enum heif_image_input_class input_class,
+ std::shared_ptr<Image>& out_image);
void set_primary_image(std::shared_ptr<Image> image);
+ Error set_primary_item(heif_item_id id);
+
+ bool is_primary_image_set() const { return !!m_primary_image; }
+
+ Error assign_thumbnail(std::shared_ptr<Image> master_image,
+ std::shared_ptr<Image> thumbnail_image);
+
+ Error encode_thumbnail(std::shared_ptr<HeifPixelImage> image,
+ struct heif_encoder* encoder,
+ const struct heif_encoding_options* options,
+ int bbox_size,
+ std::shared_ptr<Image>& out_image_handle);
+
+ Error add_exif_metadata(std::shared_ptr<Image> master_image, const void* data, int size);
+
+ Error add_XMP_metadata(std::shared_ptr<Image> master_image, const void* data, int size);
+
void write(StreamWriter& writer);
private:
@@ -218,6 +240,8 @@ namespace heif {
std::shared_ptr<HeifFile> m_heif_file;
+ int m_max_decoding_threads = 4;
+
Error interpret_heif_file();
void remove_top_level_image(std::shared_ptr<Image> image);
diff --git a/libheif/heif_cxx.h b/libheif/heif_cxx.h
index 8bf4d3b..bfba483 100644
--- a/libheif/heif_cxx.h
+++ b/libheif/heif_cxx.h
@@ -80,9 +80,26 @@ namespace heif {
// throws Error
void read_from_file(std::string filename, const ReadingOptions& opts = ReadingOptions());
+ // DEPRECATED. Use read_from_memory_without_copy() instead.
// throws Error
void read_from_memory(const void* mem, size_t size, const ReadingOptions& opts = ReadingOptions());
+ // throws Error
+ void read_from_memory_without_copy(const void* mem, size_t size, const ReadingOptions& opts = ReadingOptions());
+
+ class Reader {
+ public:
+ virtual ~Reader() { }
+
+ virtual int64_t get_position() const = 0;
+ virtual int read(void* data, size_t size) = 0;
+ virtual int seek(int64_t position) = 0;
+ virtual heif_reader_grow_status wait_for_file_size(int64_t target_size) = 0;
+ };
+
+ // throws Error
+ void read_from_reader(Reader&, const ReadingOptions& opts = ReadingOptions());
+
int get_number_of_top_level_images() const noexcept;
bool is_top_level_image_ID(heif_item_id id) const noexcept;
@@ -99,12 +116,37 @@ namespace heif {
- class EncodingOptions { };
+ class EncodingOptions : public heif_encoding_options {
+ public:
+ EncodingOptions();
+ };
// throws Error
ImageHandle encode_image(const Image& img, Encoder& encoder,
const EncodingOptions& options = EncodingOptions());
+ // throws Error
+ void set_primary_image(ImageHandle& new_primary_image_handle);
+
+ // throws Error
+ ImageHandle encode_thumbnail(const Image& image,
+ const ImageHandle& master_image,
+ Encoder& encoder,
+ const EncodingOptions&,
+ int bbox_size);
+
+ // throws Error
+ void assign_thumbnail(const ImageHandle& thumbnail_image,
+ const ImageHandle& master_image);
+
+ // throws Error
+ void add_exif_metadata(const ImageHandle& master_image,
+ const void* data, int size);
+
+ // throws Error
+ void add_XMP_metadata(const ImageHandle& master_image,
+ const void* data, int size);
+
class Writer {
public:
virtual ~Writer() { }
@@ -138,6 +180,8 @@ namespace heif {
ImageHandle(heif_image_handle* handle);
+ bool empty() const noexcept { return !m_image_handle; }
+
bool is_primary_image() const noexcept;
int get_width() const noexcept;
@@ -348,6 +392,52 @@ namespace heif {
}
}
+ inline void Context::read_from_memory_without_copy(const void* mem, size_t size, const ReadingOptions& /*opts*/) {
+ Error err = Error(heif_context_read_from_memory_without_copy(m_context.get(), mem, size, NULL));
+ if (err) {
+ throw err;
+ }
+ }
+
+
+ inline int64_t heif_reader_trampoline_get_position(void* userdata) {
+ Context::Reader* reader = (Context::Reader*)userdata;
+ return reader->get_position();
+ }
+
+ inline int heif_reader_trampoline_read(void* data, size_t size, void* userdata) {
+ Context::Reader* reader = (Context::Reader*)userdata;
+ return reader->read(data,size);
+ }
+
+ inline int heif_reader_trampoline_seek(int64_t position, void* userdata) {
+ Context::Reader* reader = (Context::Reader*)userdata;
+ return reader->seek(position);
+ }
+
+ inline heif_reader_grow_status heif_reader_trampoline_wait_for_file_size(int64_t target_size, void* userdata) {
+ Context::Reader* reader = (Context::Reader*)userdata;
+ return reader->wait_for_file_size(target_size);
+ }
+
+
+ static struct heif_reader heif_reader_trampoline =
+ {
+ 1,
+ heif_reader_trampoline_get_position,
+ heif_reader_trampoline_read,
+ heif_reader_trampoline_seek,
+ heif_reader_trampoline_wait_for_file_size
+ };
+
+ inline void Context::read_from_reader(Reader& reader, const ReadingOptions& /*opts*/) {
+ Error err = Error(heif_context_read_from_reader(m_context.get(), &heif_reader_trampoline,
+ &reader, NULL));
+ if (err) {
+ throw err;
+ }
+ }
+
inline int Context::get_number_of_top_level_images() const noexcept {
return heif_context_get_number_of_top_level_images(m_context.get());
@@ -437,8 +527,10 @@ namespace heif {
inline ImageHandle::ImageHandle(heif_image_handle* handle) {
- m_image_handle = std::shared_ptr<heif_image_handle>(handle,
- [] (heif_image_handle* h) { heif_image_handle_release(h); });
+ if (handle != nullptr) {
+ m_image_handle = std::shared_ptr<heif_image_handle>(handle,
+ [] (heif_image_handle* h) { heif_image_handle_release(h); });
+ }
}
inline bool ImageHandle::is_primary_image() const noexcept {
@@ -843,14 +935,34 @@ namespace heif {
return value;
}
+ inline void Context::set_primary_image(ImageHandle& new_primary_image_handle) {
+ Error err = Error(heif_context_set_primary_image(m_context.get(),
+ new_primary_image_handle.get_raw_image_handle()));
+ if (err) {
+ throw err;
+ }
+ }
+
+
+ inline Context::EncodingOptions::EncodingOptions() {
+ // TODO: this is a bit hacky. It would be better to have an API function to set
+ // the options to default values. But I do not see any reason for that apart from
+ // this use-case.
+
+ struct heif_encoding_options* default_options = heif_encoding_options_alloc();
+ *static_cast<heif_encoding_options*>(this) = *default_options; // copy over all options
+ heif_encoding_options_free(default_options);
+ }
+
+
inline ImageHandle Context::encode_image(const Image& img, Encoder& encoder,
- const EncodingOptions&) {
+ const EncodingOptions& options) {
struct heif_image_handle* image_handle;
Error err = Error(heif_context_encode_image(m_context.get(),
img.m_image.get(),
encoder.m_encoder.get(),
- nullptr,
+ &options,
&image_handle));
if (err) {
throw err;
@@ -858,6 +970,59 @@ namespace heif {
return ImageHandle(image_handle);
}
+
+
+ inline ImageHandle Context::encode_thumbnail(const Image& image,
+ const ImageHandle& master_image_handle,
+ Encoder& encoder,
+ const EncodingOptions& options,
+ int bbox_size) {
+ struct heif_image_handle* thumb_image_handle;
+
+ Error err = Error(heif_context_encode_thumbnail(m_context.get(),
+ image.m_image.get(),
+ master_image_handle.get_raw_image_handle(),
+ encoder.m_encoder.get(),
+ &options,
+ bbox_size,
+ &thumb_image_handle));
+ if (err) {
+ throw err;
+ }
+
+ return ImageHandle(thumb_image_handle);
+ }
+
+
+ inline void Context::assign_thumbnail(const ImageHandle& thumbnail_image,
+ const ImageHandle& master_image) {
+ Error err = Error(heif_context_assign_thumbnail(m_context.get(),
+ thumbnail_image.get_raw_image_handle(),
+ master_image.get_raw_image_handle()));
+ if (err) {
+ throw err;
+ }
+ }
+
+ inline void Context::add_exif_metadata(const ImageHandle& master_image,
+ const void* data, int size) {
+ Error err = Error(heif_context_add_exif_metadata(m_context.get(),
+ master_image.get_raw_image_handle(),
+ data, size));
+ if (err) {
+ throw err;
+ }
+ }
+
+ inline void Context::add_XMP_metadata(const ImageHandle& master_image,
+ const void* data, int size) {
+ Error err = Error(heif_context_add_XMP_metadata(m_context.get(),
+ master_image.get_raw_image_handle(),
+ data, size));
+ if (err) {
+ throw err;
+ }
+ }
}
diff --git a/libheif/heif_emscripten.h b/libheif/heif_emscripten.h
index d207f29..2f8f662 100644
--- a/libheif/heif_emscripten.h
+++ b/libheif/heif_emscripten.h
@@ -9,87 +9,10 @@
#include <utility>
#include <vector>
-#include "box.h"
-#include "heif_file.h"
+#include "heif.h"
-namespace heif {
-
-static std::string dump_box_header(BoxHeader* header) {
- if (!header) {
- return "";
- }
-
- Indent indent;
- return header->dump(indent);
-}
-
-static std::string dump_box(Box* box) {
- if (!box) {
- return "";
- }
-
- Indent indent;
- return box->dump(indent);
-}
-
-static std::shared_ptr<Box> Box_read(BitstreamRange& range) {
- std::shared_ptr<Box> box;
- Error error = Box::read(range, &box);
- if (error) {
- return nullptr;
- }
-
- return box;
-}
-
-class EmscriptenBitstreamRange : public BitstreamRange {
- public:
- explicit EmscriptenBitstreamRange(const std::string& data)
- : BitstreamRange(nullptr, 0),
- data_(data),
- stream_(std::move(data_)) {
- construct(&stream_, data.size(), nullptr);
- }
- bool error() const {
- return BitstreamRange::error();
- }
-
- private:
- std::string data_;
- std::basic_istringstream<char> stream_;
-};
-
-static Error HeifFile_read_from_memory(HeifFile* file,
- const std::string& data) {
- if (!file) {
- return Error(heif_error_Usage_error,
- heif_suberror_Null_pointer_argument);
- }
-
- return file->read_from_memory(data.data(), data.size());
-}
-
-static emscripten::val HeifFile_get_compressed_image_data(HeifFile* file,
- uint16_t ID, const std::string& data) {
- emscripten::val result = emscripten::val::object();
- if (!file) {
- return result;
- }
-
- std::vector<uint8_t> image_data;
- Error err = file->get_compressed_image_data(ID, &image_data);
- if (err) {
- return emscripten::val(err);
- }
-
- result.set("type", file->get_item_type(ID));
- result.set("data", std::string(reinterpret_cast<char*>(image_data.data()),
- image_data.size()));
- return result;
-}
-
-static std::string heif_get_version() {
- return ::heif_get_version();
+static std::string _heif_get_version() {
+ return heif_get_version();
}
static struct heif_error _heif_context_read_from_memory(
@@ -140,8 +63,9 @@ static emscripten::val heif_js_context_get_list_of_top_level_image_IDs(
heif_item_id* ids = (heif_item_id*) malloc(count * sizeof(heif_item_id));
if (!ids) {
- Error err = Error(heif_error_Memory_allocation_error,
- heif_suberror_Security_limit_exceeded);
+ struct heif_error err;
+ err.code = heif_error_Memory_allocation_error;
+ err.subcode = heif_suberror_Security_limit_exceeded;
return emscripten::val(err);
}
@@ -238,7 +162,8 @@ static emscripten::val heif_js_decode_image(struct heif_image_handle* handle,
emscripten::function(#name, &name, emscripten::allow_raw_pointers())
EMSCRIPTEN_BINDINGS(libheif) {
- EXPORT_HEIF_FUNCTION(heif_get_version);
+ emscripten::function("heif_get_version", &_heif_get_version,
+ emscripten::allow_raw_pointers());
EXPORT_HEIF_FUNCTION(heif_get_version_number);
EXPORT_HEIF_FUNCTION(heif_context_alloc);
@@ -254,53 +179,6 @@ EMSCRIPTEN_BINDINGS(libheif) {
&heif_js_decode_image, emscripten::allow_raw_pointers());
EXPORT_HEIF_FUNCTION(heif_image_handle_release);
- emscripten::class_<Error>("Error")
- .constructor<>()
- .class_property("Ok", &Error::Ok)
- .property("error_code", &Error::error_code)
- .property("sub_error_code", &Error::sub_error_code)
- ;
-
- emscripten::class_<BitstreamRange>("BitstreamRangeBase")
- ;
-
- emscripten::class_<EmscriptenBitstreamRange,
- emscripten::base<BitstreamRange>>("BitstreamRange")
- .constructor<const std::string&>()
- .function("error", &EmscriptenBitstreamRange::error)
- ;
-
- emscripten::class_<Indent>("Indent")
- .constructor<>()
- .function("get_indent", &Indent::get_indent)
- ;
-
- emscripten::class_<BoxHeader>("BoxHeader")
- .function("get_box_size", &BoxHeader::get_box_size)
- .function("get_header_size", &BoxHeader::get_header_size)
- .function("get_short_type", &BoxHeader::get_short_type)
- .function("get_type_string", &BoxHeader::get_type_string)
- .function("dump", &dump_box_header, emscripten::allow_raw_pointers())
- ;
-
- emscripten::class_<Box, emscripten::base<BoxHeader>>("Box")
- .class_function("read", &Box_read, emscripten::allow_raw_pointers())
- .function("get_child_box", &Box::get_child_box)
- .function("dump", &dump_box, emscripten::allow_raw_pointers())
- .smart_ptr<std::shared_ptr<Box>>("Box")
- ;
-
- emscripten::class_<HeifFile>("HeifFile")
- .constructor<>()
- .function("read_from_memory", &HeifFile_read_from_memory,
- emscripten::allow_raw_pointers())
- .function("get_num_images", &HeifFile::get_num_images)
- .function("get_primary_image_ID", &HeifFile::get_primary_image_ID)
- .function("get_item_IDs", &HeifFile::get_item_IDs)
- .function("get_compressed_image_data", &HeifFile_get_compressed_image_data,
- emscripten::allow_raw_pointers())
- ;
-
emscripten::enum_<heif_error_code>("heif_error_code")
.value("heif_error_Ok", heif_error_Ok)
.value("heif_error_Input_does_not_exist", heif_error_Input_does_not_exist)
@@ -391,8 +269,6 @@ EMSCRIPTEN_BINDINGS(libheif) {
.value("heif_channel_interleaved", heif_channel_interleaved)
;
- emscripten::register_vector<std::string>("StringVector");
- emscripten::register_vector<uint32_t>("UInt32Vector");
emscripten::class_<heif_context>("heif_context");
emscripten::class_<heif_image_handle>("heif_image_handle");
emscripten::class_<heif_image>("heif_image");
@@ -402,6 +278,4 @@ EMSCRIPTEN_BINDINGS(libheif) {
;
}
-} // namespace heif
-
#endif // LIBHEIF_BOX_EMSCRIPTEN_H
diff --git a/libheif/heif_file.cc b/libheif/heif_file.cc
index 45499cd..0634b47 100644
--- a/libheif/heif_file.cc
+++ b/libheif/heif_file.cc
@@ -56,27 +56,28 @@ std::vector<heif_item_id> HeifFile::get_item_IDs() const
Error HeifFile::read_from_file(const char* input_filename)
{
- m_input_stream = std::unique_ptr<std::istream>(new std::ifstream(input_filename));
+ auto input_stream_istr = std::unique_ptr<std::istream>(new std::ifstream(input_filename));
+ auto input_stream = std::make_shared<StreamReader_istream>(std::move(input_stream_istr));
- uint64_t maxSize = std::numeric_limits<uint64_t>::max();
- heif::BitstreamRange range(m_input_stream.get(), maxSize);
-
-
- Error error = parse_heif_file(range);
- return error;
+ return read(input_stream);
}
-Error HeifFile::read_from_memory(const void* data, size_t size)
+Error HeifFile::read_from_memory(const void* data, size_t size, bool copy)
{
- // TODO: Work on passed memory directly instead of creating a copy here.
- // Note: we cannot use basic_streambuf for this, because it does not support seeking
- std::string s(static_cast<const char*>(data), size);
+ auto input_stream = std::make_shared<StreamReader_memory>((const uint8_t*)data, size, copy);
+
+ return read(input_stream);
+}
- m_input_stream = std::unique_ptr<std::istream>(new std::istringstream(std::move(s)));
- heif::BitstreamRange range(m_input_stream.get(), size);
+Error HeifFile::read(std::shared_ptr<StreamReader> reader)
+{
+ m_input_stream = reader;
+
+ uint64_t maxSize = std::numeric_limits<int64_t>::max();
+ heif::BitstreamRange range(m_input_stream, maxSize);
Error error = parse_heif_file(range);
return error;
@@ -410,12 +411,12 @@ Error HeifFile::get_compressed_image_data(heif_item_id ID, std::vector<uint8_t>*
heif_suberror_No_item_data);
}
- error = m_iloc_box->read_data(*item, *m_input_stream.get(), m_idat_box, data);
+ error = m_iloc_box->read_data(*item, m_input_stream, m_idat_box, data);
} else if (item_type == "grid" ||
item_type == "iovl" ||
item_type == "Exif" ||
(item_type == "mime" && content_type=="application/rdf+xml")) {
- error = m_iloc_box->read_data(*item, *m_input_stream.get(), m_idat_box, data);
+ error = m_iloc_box->read_data(*item, m_input_stream, m_idat_box, data);
}
if (error != Error::Ok) {
@@ -453,18 +454,24 @@ heif_item_id HeifFile::get_unused_item_id() const
heif_item_id HeifFile::add_new_image(const char* item_type)
{
+ auto box = add_new_infe_box(item_type);
+ return box->get_item_ID();
+}
+
+
+std::shared_ptr<Box_infe> HeifFile::add_new_infe_box(const char* item_type)
+{
heif_item_id id = get_unused_item_id();
auto infe = std::make_shared<Box_infe>();
infe->set_item_ID(id);
infe->set_hidden_item(false);
infe->set_item_type(item_type);
- //infe->set_item_name("Nice image");
m_infe_boxes[id] = infe;
m_iinf_box->append_child_box(infe);
- return id;
+ return infe;
}
diff --git a/libheif/heif_file.h b/libheif/heif_file.h
index 15c2fd6..01d2b55 100644
--- a/libheif/heif_file.h
+++ b/libheif/heif_file.h
@@ -49,8 +49,9 @@ namespace heif {
HeifFile();
~HeifFile();
+ Error read(std::shared_ptr<StreamReader> reader);
Error read_from_file(const char* input_filename);
- Error read_from_memory(const void* data, size_t size);
+ Error read_from_memory(const void* data, size_t size, bool copy);
void new_empty_file();
@@ -98,6 +99,7 @@ namespace heif {
heif_item_id get_unused_item_id() const;
heif_item_id add_new_image(const char* item_type);
+ std::shared_ptr<Box_infe> add_new_infe_box(const char* item_type);
void add_hvcC_property(heif_item_id id);
Error append_hvcC_nal_data(heif_item_id id, const std::vector<uint8_t>& data);
@@ -121,7 +123,7 @@ namespace heif {
mutable std::mutex m_read_mutex;
#endif
- std::unique_ptr<std::istream> m_input_stream;
+ std::shared_ptr<StreamReader> m_input_stream;
std::vector<std::shared_ptr<Box> > m_top_level_boxes;
diff --git a/libheif/heif_plugin.h b/libheif/heif_plugin.h
index 4e32485..30a95b0 100644
--- a/libheif/heif_plugin.h
+++ b/libheif/heif_plugin.h
@@ -111,7 +111,8 @@ enum heif_image_input_class
{
heif_image_input_class_normal = 1,
heif_image_input_class_alpha = 2,
- heif_image_input_class_depth = 3
+ heif_image_input_class_depth = 3,
+ heif_image_input_class_thumbnail = 4
};
@@ -216,7 +217,7 @@ struct heif_encoder_parameter
struct {
int default_value;
- bool have_minimum_maximum;
+ uint8_t have_minimum_maximum; // bool
int minimum;
int maximum;
diff --git a/libheif/heif_plugin_registry.cc b/libheif/heif_plugin_registry.cc
index d2fc55b..5f5b3ee 100644
--- a/libheif/heif_plugin_registry.cc
+++ b/libheif/heif_plugin_registry.cc
@@ -28,6 +28,15 @@
#include "heif_plugin_registry.h"
+#if HAVE_LIBDE265
+#include "heif_decoder_libde265.h"
+#endif
+
+#if HAVE_X265
+#include "heif_encoder_x265.h"
+#endif
+
+
using namespace heif;
@@ -49,6 +58,22 @@ std::set<std::unique_ptr<struct heif_encoder_descriptor>,
encoder_descriptor_priority_order> s_encoder_descriptors;
+
+static class Register_Default_Plugins
+{
+public:
+ Register_Default_Plugins() {
+#if HAVE_LIBDE265
+ heif::register_decoder(get_decoder_plugin_libde265());
+#endif
+
+#if HAVE_X265
+ heif::register_encoder(get_encoder_plugin_x265());
+#endif
+ }
+} dummy;
+
+
void heif::register_decoder(const heif_decoder_plugin* decoder_plugin)
{
if (decoder_plugin->init_plugin) {
@@ -59,6 +84,22 @@ void heif::register_decoder(const heif_decoder_plugin* decoder_plugin)
}
+const struct heif_decoder_plugin* heif::get_decoder(enum heif_compression_format type)
+{
+ int highest_priority = 0;
+ const struct heif_decoder_plugin* best_plugin = nullptr;
+
+ for (const auto* plugin : s_decoder_plugins) {
+ int priority = plugin->does_support_format(type);
+ if (priority > highest_priority) {
+ highest_priority = priority;
+ best_plugin = plugin;
+ }
+ }
+
+ return best_plugin;
+}
+
void heif::register_encoder(const heif_encoder_plugin* encoder_plugin)
{
if (encoder_plugin->init_plugin) {
diff --git a/libheif/heif_plugin_registry.h b/libheif/heif_plugin_registry.h
index 06b586d..894c73c 100644
--- a/libheif/heif_plugin_registry.h
+++ b/libheif/heif_plugin_registry.h
@@ -50,6 +50,8 @@ namespace heif {
void register_encoder(const heif_encoder_plugin* encoder_plugin);
+ const struct heif_decoder_plugin* get_decoder(enum heif_compression_format type);
+
const struct heif_encoder_plugin* get_encoder(enum heif_compression_format type);
std::vector<const struct heif_encoder_descriptor*>
diff --git a/libheif/heif_version.h b/libheif/heif_version.h
index a85cd7f..9ebf0ce 100644
--- a/libheif/heif_version.h
+++ b/libheif/heif_version.h
@@ -28,9 +28,9 @@
#define LIBHEIF_HEIF_VERSION_H
/* Numeric representation of the version */
-#define LIBHEIF_NUMERIC_VERSION 0x01020000
+#define LIBHEIF_NUMERIC_VERSION 0x01030200
/* Version string */
-#define LIBHEIF_VERSION "1.2.0"
+#define LIBHEIF_VERSION "1.3.2"
#endif // LIBHEIF_HEIF_VERSION_H
diff --git a/ltmain.sh b/ltmain.sh
index 147d758..a736cf9 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -31,7 +31,7 @@
PROGRAM=libtool
PACKAGE=libtool
-VERSION="2.4.6 Debian-2.4.6-0.1"
+VERSION="2.4.6 Debian-2.4.6-2"
package_revision=2.4.6
@@ -2068,7 +2068,7 @@ include the following information:
compiler: $LTCC
compiler flags: $LTCFLAGS
linker: $LD (gnu? $with_gnu_ld)
- version: $progname (GNU libtool) 2.4.6
+ version: $progname $scriptversion Debian-2.4.6-2
automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 10ab284..ee80844 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -728,7 +728,6 @@ _LT_CONFIG_SAVE_COMMANDS([
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.
diff --git a/post.js b/post.js
index 314538a..0508a5f 100644
--- a/post.js
+++ b/post.js
@@ -168,15 +168,7 @@ var libheif = {
s.charCodeAt(1) << 16 |
s.charCodeAt(2) << 8 |
s.charCodeAt(3);
- },
- /** @expose */
- BitstreamRange: Module.BitstreamRange,
- /** @expose */
- Box: Module.Box,
- /** @expose */
- Error: Module.Error,
- /** @expose */
- HeifFile: Module.HeifFile,
+ }
};
var key;
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 9a870cc..ccc952d 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -231,6 +231,8 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+have_libde265 = @have_libde265@
+have_x265 = @have_x265@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
diff --git a/scripts/install-ci-linux.sh b/scripts/install-ci-linux.sh
index dc7c77b..c21c99e 100755
--- a/scripts/install-ci-linux.sh
+++ b/scripts/install-ci-linux.sh
@@ -79,7 +79,15 @@ if [ ! -z "$WITH_GRAPHICS" ]; then
"
fi
-if [ ! -z "$MINGW64" ]; then
+if [ ! -z "$MINGW32" ]; then
+ INSTALL_PACKAGES="$INSTALL_PACKAGES \
+ binutils-mingw-w64-i686 \
+ g++-mingw-w64-i686 \
+ gcc-mingw-w64-i686 \
+ mingw-w64-i686-dev \
+ wine \
+ "
+elif [ ! -z "$MINGW64" ]; then
INSTALL_PACKAGES="$INSTALL_PACKAGES \
binutils-mingw-w64-x86-64 \
g++-mingw-w64-x86-64 \
diff --git a/scripts/prepare-ci.sh b/scripts/prepare-ci.sh
index 9a0b183..4f617fc 100755
--- a/scripts/prepare-ci.sh
+++ b/scripts/prepare-ci.sh
@@ -27,7 +27,9 @@ if [ "$WITH_LIBDE265" = "2" ]; then
fi
CONFIGURE_HOST=
-if [ ! -z "$MINGW64" ]; then
+if [ ! -z "$MINGW32" ]; then
+ CONFIGURE_HOST=i686-w64-mingw32
+elif [ ! -z "$MINGW64" ]; then
CONFIGURE_HOST=x86_64-w64-mingw32
fi
diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh
index f656c01..421de33 100755
--- a/scripts/run-ci.sh
+++ b/scripts/run-ci.sh
@@ -34,7 +34,14 @@ fi
BIN_SUFFIX=
BIN_WRAPPER=
-if [ ! -z "$MINGW64" ]; then
+if [ ! -z "$MINGW32" ]; then
+ # Make sure the correct compiler will be used.
+ unset CC
+ unset CXX
+ BIN_SUFFIX=.exe
+ BIN_WRAPPER=wine
+ export WINEPATH="/usr/lib/gcc/i686-w64-mingw32/4.8/;/usr/i686-w64-mingw32/lib"
+elif [ ! -z "$MINGW64" ]; then
# Make sure the correct compiler will be used.
unset CC
unset CXX