forked from zephyrproject-rtos/sdk-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_wget.sh
More file actions
executable file
·119 lines (98 loc) · 2.63 KB
/
Copy pathbuild_wget.sh
File metadata and controls
executable file
·119 lines (98 loc) · 2.63 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
set -e
WGET_VERSION="1.25.0"
usage()
{
echo "Usage: $(basename $0) host source output"
}
# Validate and parse arguments
if [ "$1" == "" ]; then
usage
echo
echo "host must be specified."
exit 1
elif [ "$2" == "" ]; then
usage
echo
echo "source must be specified."
exit 1
elif [ "$3" == "" ]; then
usage
echo
echo "output must be specified."
exit 1
fi
BUILD_HOST="$1"
BUILD_SOURCE="$2"
BUILD_OUTPUT="$3"
# Set build parameters
WGET_FLAGS=" \
--with-ssl=openssl \
--disable-pcre2 \
"
if [ "${BUILD_HOST}" == "windows-x86_64" ]; then
BUILD_PREFIX="${BUILD_OUTPUT}/wget"
WGET_FLAGS+="--host=x86_64-w64-mingw32"
elif [[ "${BUILD_HOST}" =~ ^macos-.* ]]; then
BUILD_PREFIX="${BUILD_OUTPUT}/opt/wget"
case ${BUILD_HOST} in
macos-aarch64)
HOMEBREW_PREFIX="/opt/homebrew"
;;
macos-x86_64)
HOMEBREW_PREFIX="/usr/local"
;;
esac
# Ensure that arch-specific Homebrew environment is configured
eval $(${HOMEBREW_PREFIX}/bin/brew shellenv)
# Specify statically linked libraries and their dependencies
export LIBIDN2_LIBS=" \
${HOMEBREW_PREFIX}/lib/libidn2.a \
${HOMEBREW_PREFIX}/lib/libunistring.a \
"
export OPENSSL_LIBS=" \
${HOMEBREW_PREFIX}/lib/libssl.a \
${HOMEBREW_PREFIX}/lib/libcrypto.a \
"
else
echo "ERROR: Invalid build host '${BUILD_HOST}'"
exit 1
fi
# Download and extract wget source code
mkdir -p ${BUILD_SOURCE}
pushd ${BUILD_SOURCE}
wget -O wget.tar.gz https://ftp.gnu.org/gnu/wget/wget-${WGET_VERSION}.tar.gz
tar --strip-components=1 -xvf wget.tar.gz
popd
# Build wget
${BUILD_SOURCE}/configure \
${WGET_FLAGS} \
--prefix="${BUILD_PREFIX}"
make -j
make install
# Install root CA certificates (Mozilla CA certificate store)
mkdir -p ${BUILD_PREFIX}/etc/ssl
wget \
-O ${BUILD_PREFIX}/etc/ssl/cert.pem \
https://curl.se/ca/cacert.pem
# Copy required dynamic-link libraries for Windows
if [ "${BUILD_HOST}" == "windows-x86_64" ]; then
WGET_WIN_LIBS=" \
/opt/mingw-w64-win32/x86_64-w64-mingw32/bin/libcrypto-3-x64.dll \
/opt/mingw-w64-win32/x86_64-w64-mingw32/bin/libiconv-2.dll \
/opt/mingw-w64-win32/x86_64-w64-mingw32/bin/libidn2-0.dll \
/opt/mingw-w64-win32/x86_64-w64-mingw32/bin/libintl-8.dll \
/opt/mingw-w64-win32/x86_64-w64-mingw32/bin/libssl-3-x64.dll \
/opt/mingw-w64-win32/x86_64-w64-mingw32/bin/libunistring-5.dll \
"
for l in ${WGET_WIN_LIBS}; do
cp -f ${l} ${BUILD_PREFIX}/bin
done
fi
# Symlink wget executable for macOS
if [[ "${BUILD_HOST}" =~ ^macos-.* ]]; then
mkdir -p ${BUILD_OUTPUT}/usr/bin
pushd ${BUILD_OUTPUT}/usr/bin
ln -sf ../../opt/wget/bin/wget wget
popd
fi