- previously hidden as Detail::[IO]FstreamAllocator, now exposed directly as [io]fstreamPointer, which allows reuse for std::ifstream, std::ofstream wrapping, without the additional ISstream, OSstream layers. These stream pointers have some characteristics similar to a unique_ptr. - restrict direct gzstream usage to two files (fstreamPointers.C, gzstream.C) which improves localization and makes it simpler to enable/disable with the `HAVE_LIBZ` define. The HAVE_LIBZ define is currently simply hard-coded in the Make/options. If compiled WITHOUT libz support: - reading gz files : FatalError - writing gz files : emit warning and downgrade to uncompressed - warn if compression is specified in the case controlDict and downgrade to uncompressed ENH: minor updates to gzstream interface for C++11 - support construct/open with std::string for the file names. CONFIG: provisioning for have_libz detection as wmake/script
127 lines
2.8 KiB
Bash
127 lines
2.8 KiB
Bash
#----------------------------------*-sh-*--------------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration |
|
|
# \\ / A nd | www.openfoam.com
|
|
# \\/ M anipulation |
|
|
#------------------------------------------------------------------------------
|
|
# Copyright (C) 2020 OpenCFD Ltd.
|
|
#------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
|
#
|
|
# Script
|
|
# have_libz
|
|
#
|
|
# Description
|
|
# Detection/setup of LIBZ (zlib)
|
|
#
|
|
# Requires
|
|
# None
|
|
#
|
|
# Functions provided
|
|
# have_libz, no_libz, echo_libz, search_libz
|
|
#
|
|
# Variables set on success
|
|
# HAVE_LIBZ - as per GNU autoconf
|
|
# LIBZ_INC_DIR
|
|
# LIBZ_LIB_DIR
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Reset
|
|
no_libz()
|
|
{
|
|
unset HAVE_LIBZ LIBZ_INC_DIR LIBZ_LIB_DIR
|
|
}
|
|
|
|
|
|
# Report
|
|
echo_libz()
|
|
{
|
|
echo "libz=${HAVE_LIBZ:-false}"
|
|
echo "include=\"$LIBZ_INC_DIR\""
|
|
echo "library=\"$LIBZ_LIB_DIR\""
|
|
}
|
|
|
|
|
|
# Search
|
|
# $1 : prefix (*_ARCH_PATH, system, ...)
|
|
#
|
|
# On success, return 0 and export variables
|
|
# -> HAVE_LIBZ, LIBZ_INC_DIR, LIBZ_LIB_DIR
|
|
search_libz()
|
|
{
|
|
local warn # warn="==> skip libz"
|
|
local incName="zlib.h"
|
|
local libName="libz"
|
|
|
|
local prefix="${1:-system}"
|
|
local header library
|
|
|
|
# ----------------------------------
|
|
if isNone "$prefix"
|
|
then
|
|
[ -n "$warn" ] && echo "$warn (disabled)"
|
|
return 1
|
|
elif hasAbsdir "$prefix"
|
|
then
|
|
header=$(findFirstFile "$prefix/include/$incName")
|
|
library=$(findExtLib "$libName")
|
|
elif isSystem "$prefix"
|
|
then
|
|
header=$(findSystemInclude -name="$incName")
|
|
prefix=$(sysPrefix "$header")
|
|
else
|
|
unset prefix
|
|
fi
|
|
# ----------------------------------
|
|
|
|
# Header
|
|
[ -n "$header" ] || {
|
|
[ -n "$warn" ] && echo "$warn (no header)"
|
|
return 2
|
|
}
|
|
|
|
# Library
|
|
[ -n "$library" ] \
|
|
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|
|
|| {
|
|
[ -n "$warn" ] && echo "$warn (no library)"
|
|
return 2
|
|
}
|
|
|
|
# ----------------------------------
|
|
|
|
# OK
|
|
export HAVE_LIBZ=true
|
|
export LIBZ_INC_DIR="${header%/*}" # Basename
|
|
export LIBZ_LIB_DIR="${library%/*}" # Basename
|
|
}
|
|
|
|
|
|
# Output as per search_* function
|
|
have_libz()
|
|
{
|
|
search_libz system
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Reset
|
|
no_libz
|
|
|
|
# Test/query
|
|
case "$1" in
|
|
-test)
|
|
have_libz
|
|
echo_libz
|
|
;;
|
|
esac
|
|
|
|
#------------------------------------------------------------------------------
|