-
Notifications
You must be signed in to change notification settings - Fork 42
/
prepare_osx_build_environment.sh
executable file
·144 lines (135 loc) · 4.79 KB
/
prepare_osx_build_environment.sh
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# Requires xcode and cmake, also OpenSSL has to be installed via homebrew.
set -e
######### Versions of libraries/frameworks to be compiled
QT_VER="6.7.3"
OPENSSL_VER="3.0.15"
OPENLDAP_VER="2.6.8"
REBUILD=false
BUILD_PATH=~/cmake_builds
: ${MACOSX_DEPLOYMENT_TARGET:="12.0"}
export MACOSX_DEPLOYMENT_TARGET
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-o|--openssl)
OPENSSL_PATH="$2"
shift
;;
-p|--path)
BUILD_PATH="$2"
: ${OPENSSL_PATH:="${BUILD_PATH}/OpenSSL"}
shift
;;
-q|--qt)
QT_VER="$2"
shift
;;
-l|--openldap)
OPENLDAP_VER="$2"
shift
;;
-r|--rebuild)
REBUILD=true
;;
-h|--help)
echo "Build Qt for Digidoc4 client"
echo ""
echo "Usage: $0 [-r|--rebuild] [-p build-path] [-h|--help] [-q|--qt qt-version] [-l|--openldap openldap-version]"
echo ""
echo "Options:"
echo " -o or --openssl openssl-path:"
echo " OpenSSL path; default ${OPENSSL_VER} will be built ${OPENSSL_PATH}"
echo " -p or --path build-path"
echo " folder where the dependencies should be built; default ${BUILD_PATH}"
echo " -q or --qt qt-version:"
echo " Specific version of Qt to build; default ${QT_VER} "
echo " -l or --openldap openldap-version:"
echo " Specific version of OpenLDAP to build; default ${OPENLDAP_VER} "
echo " -r or --rebuild:"
echo " Rebuild even if dependency is already built"
echo " "
echo " -h or --help:"
echo " Print usage of the script "
exit 0
;;
esac
shift # past argument or value
done
QT_PATH=${BUILD_PATH}/Qt-${QT_VER}-OpenSSL
OPENLDAP_PATH=${BUILD_PATH}/OpenLDAP
GREY='\033[0;37m'
ORANGE='\033[0;33m'
RED='\033[0;31m'
RESET='\033[0m'
mkdir -p ${BUILD_PATH}
pushd ${BUILD_PATH}
if [[ ! -d ${OPENSSL_PATH} ]] ; then
echo -e "\n${ORANGE}##### Building OpenSSL ${OPENSSL_VER} ${OPENSSL_PATH} #####${RESET}\n"
if [ ! -f openssl-${OPENSSL_VER}.tar.gz ]; then
curl -O -L https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz
fi
rm -rf openssl-${OPENSSL_VER}
tar xf openssl-${OPENSSL_VER}.tar.gz
pushd openssl-${OPENSSL_VER}
for ARCH in x86_64 arm64; do
./Configure darwin64-${ARCH} --prefix=${OPENSSL_PATH} shared no-autoload-config no-module no-tests enable-ec_nistp_64_gcc_128
make -s > /dev/null
make install_sw
mv ${OPENSSL_PATH}{,.${ARCH}}
make distclean
done
popd
cp -a ${OPENSSL_PATH}{.x86_64,}
pushd ${OPENSSL_PATH}.arm64
for i in lib/lib*3.dylib; do
lipo -create ${OPENSSL_PATH}.x86_64/${i} ${i} -output ${OPENSSL_PATH}/${i}
done
popd
else
echo -e "\n${GREY} OpenSSL not built${RESET}"
fi
if [[ "$REBUILD" = true || ! -d ${QT_PATH} ]] ; then
qt_ver_parts=( ${QT_VER//./ } )
QT_MINOR="${qt_ver_parts[0]}.${qt_ver_parts[1]}"
echo -e "\n${ORANGE}##### Building Qt ${QT_VER} ${QT_PATH} #####${RESET}\n"
for PACKAGE in qtbase-everywhere-src-${QT_VER} qtsvg-everywhere-src-${QT_VER} qttools-everywhere-src-${QT_VER}; do
if [ ! -f ${PACKAGE}.tar.xz ]; then
curl -O -L http://download.qt.io/official_releases/qt/${QT_MINOR}/${QT_VER}/submodules/${PACKAGE}.tar.xz
fi
rm -rf ${PACKAGE}
tar xf ${PACKAGE}.tar.xz
pushd ${PACKAGE}
if [[ "${PACKAGE}" == *"qtbase"* ]] ; then
./configure -prefix ${QT_PATH} -opensource -nomake tests -nomake examples -no-securetransport -openssl-linked -confirm-license -appstore-compliant -- -DOPENSSL_ROOT_DIR=${OPENSSL_PATH} -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
else
${QT_PATH}/bin/qt-configure-module .
fi
cmake --build . --parallel
cmake --install .
popd
rm -rf ${PACKAGE}
done
else
echo -e "\n${GREY} Qt not built${RESET}"
fi
if [[ "$REBUILD" = true || ! -d ${OPENLDAP_PATH} ]] ; then
echo -e "\n${ORANGE}##### Building OpenLDAP ${OPENLDAP_VER} ${OPENLDAP_PATH} #####${RESET}\n"
if [ ! -f openldap-${OPENLDAP_VER}.tgz ]; then
curl -O -L http://mirror.eu.oneandone.net/software/openldap/openldap-release/openldap-${OPENLDAP_VER}.tgz
fi
tar xf openldap-${OPENLDAP_VER}.tgz
pushd openldap-${OPENLDAP_VER}
sed -ie 's! doc!!' Makefile.in
ARCH="-arch x86_64 -arch arm64"
CFLAGS="${ARCH}" CXXFLAGS="${ARCH}" LDFLAGS="${ARCH} -L${OPENSSL_PATH}/lib" CPPFLAGS="-I${OPENSSL_PATH}/include" ./configure \
--prefix ${OPENLDAP_PATH} --enable-static --disable-shared --disable-syslog --disable-local --disable-slapd \
--without-threads --without-cyrus-sasl --with-tls=openssl
make
make install
popd
else
echo -e "\n${GREY} OpenLDAP not built${RESET}"
fi
popd