-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathzlib.sh
More file actions
executable file
·82 lines (60 loc) · 2.07 KB
/
zlib.sh
File metadata and controls
executable file
·82 lines (60 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
# Copyright (C) Viktor Szakats. See LICENSE.md
# SPDX-License-Identifier: MIT
# shellcheck disable=SC3040,SC2039
set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail
export _NAM _VER _OUT _BAS _DST
_NAM="$(basename "$0" | cut -f 1 -d '.')"; [ -n "${2:-}" ] && _NAM="$2"
_VER="$1"
(
cd "${_NAM}" || exit 0
rm -r -f "${_PKGDIR:?}" "${_BLDDIR:?}"
options=''
if [ "${_NAM}" = 'zlibng' ]; then
options+=' -DBUILD_SHARED_LIBS=OFF'
options+=' -DZLIB_COMPAT=ON'
options+=' -DZLIB_ENABLE_TESTS=OFF'
options+=' -DWITH_GTEST=OFF'
else
options+=' -DZLIB_BUILD_TESTING=OFF'
options+=' -DZLIB_BUILD_SHARED=OFF'
fi
# shellcheck disable=SC2086
cmake -B "${_BLDDIR}" ${_CMAKE_GLOBAL} ${options} \
-DCMAKE_C_FLAGS="${_CFLAGS_GLOBAL_CMAKE} ${_CFLAGS_GLOBAL} ${_CPPFLAGS_GLOBAL} ${_LDFLAGS_GLOBAL}"
cmake --build "${_BLDDIR}"
cmake --install "${_BLDDIR}" --prefix "${_PP}"
ls -l "${_PP}"/lib/*.a
if [ "${_NAM}" = 'zlib' ] && [ -f "${_PP}"/lib/libzs.a ]; then
# Stick to the name expected by everyone
mv -f "${_PP}"/lib/libzs.a "${_PP}"/lib/libz.a
fi
# Delete .pc files
rm -r -f "${_PP}"/lib/pkgconfig
# Make steps for determinism
if [ "${_NAM}" = 'zlibng' ]; then
readonly _ref='README.md'
else
readonly _ref='ChangeLog'
fi
# shellcheck disable=SC2086
"${_STRIP_LIB}" ${_STRIPFLAGS_LIB} "${_PP}"/lib/*.a
touch -c -r "${_ref}" "${_PP}"/include/*.h
touch -c -r "${_ref}" "${_PP}"/lib/*.a
# Create package
_OUT="${_NAM}-${_VER}${_REVSUFFIX}${_PKGSUFFIX}"
_BAS="${_NAM}-${_VER}${_PKGSUFFIX}"
_DST="$(pwd)/_pkg"; rm -r -f "${_DST}"
mkdir -p "${_DST}"/include
mkdir -p "${_DST}"/lib
cp -f -p "${_PP}"/include/*.h "${_DST}"/include
cp -f -p "${_PP}"/lib/*.a "${_DST}"/lib/
if [ "${_NAM}" = 'zlibng' ]; then
cp -f -p LICENSE.md "${_DST}"/
cp -f -p README.md "${_DST}"/
else
cp -f -p LICENSE "${_DST}"/LICENSE.txt
cp -f -p ChangeLog "${_DST}"/ChangeLog.txt
fi
../_pkg.sh "$(pwd)/${_ref}"
)