1+ #! /usr/bin/env bash
2+ #
3+ # Copyright (C) 2021 Matt Reach<[email protected] >4+
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+ #
17+
18+ set -e
19+
20+ THIS_DIR=$( DIRNAME=$( dirname " $0 " ) ; cd " $DIRNAME " ; pwd)
21+ cd " $THIS_DIR "
22+
23+ echo " === [$0 ] check env begin==="
24+ env_assert " MR_ARCH"
25+ env_assert " MR_PLAT"
26+ env_assert " MR_BUILD_NAME"
27+ env_assert " MR_CC"
28+ env_assert " MR_BUILD_SOURCE"
29+ env_assert " MR_BUILD_PREFIX"
30+ env_assert " MR_SYS_ROOT"
31+ env_assert " MR_HOST_NPROC"
32+ echo " MR_DEBUG:$MR_DEBUG "
33+ echo " MR_FORCE_CROSS:$MR_FORCE_CROSS "
34+ echo " MR_OTHER_CFLAGS:$MR_OTHER_CFLAGS "
35+ echo " ===check env end==="
36+
37+ if [[ " $MR_DEBUG " == " debug" ]]; then
38+ export MR_OTHER_CFLAGS=" ${MR_OTHER_CFLAGS} -g"
39+ else
40+ export MR_OTHER_CFLAGS=" ${MR_OTHER_CFLAGS} -Os"
41+ fi
42+
43+ # prepare build config
44+ CFG_FLAGS=" --prefix=$MR_BUILD_PREFIX --disable-shared --disable-dependency-tracking --disable-silent-rules --disable-bdjava-jar --without-freetype --without-fontconfig --disable-doxygen-doc --disable-examples"
45+ CFLAGS=" $MR_OTHER_CFLAGS "
46+
47+ if [[ " $MR_DEBUG " == " debug" ]]; then
48+ CFG_FLAGS=" ${CFG_FLAGS} use_examples=yes --disable-optimizations"
49+ fi
50+
51+ # for cross compile
52+ if [[ $( uname -m) != " $MR_ARCH " || " $MR_FORCE_CROSS " ]]; then
53+ echo " [*] cross compile, on $( uname -m) compile $MR_PLAT $MR_ARCH ."
54+ # https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html
55+ CFLAGS=" $CFLAGS -isysroot $MR_SYS_ROOT "
56+ # $MR_ARCH-apple-darwin
57+ CFG_FLAGS=" $CFG_FLAGS --host=$MR_ARCH -apple-$MR_PLAT --with-sysroot=$MR_SYS_ROOT "
58+ fi
59+
60+ echo " ----------------------"
61+ echo " [*] configurate $LIB_NAME "
62+ echo " ----------------------"
63+
64+ # # use system xml2 lib
65+ # export LIBXML2_CFLAGS=$(xml2-config --prefix=${MR_SYS_ROOT}/usr --cflags)
66+ # export LIBXML2_LIBS=$(xml2-config --prefix=${MR_SYS_ROOT}/usr --libs)
67+
68+ cd $MR_BUILD_SOURCE
69+
70+ if [[ -f ' configure' ]]; then
71+ echo " reuse configure"
72+ else
73+ echo " auto generate configure"
74+ ./bootstrap > /dev/null
75+ fi
76+
77+ echo
78+ echo " CC: $MR_TRIPLE_CC "
79+ echo " CFG_FLAGS: $CFG_FLAGS "
80+ echo " CFLAGS: $CFLAGS "
81+ echo
82+
83+ export CC=" $MR_TRIPLE_CC "
84+ export CFLAGS=" $CFLAGS "
85+ export LDFLAGS=" $CFLAGS "
86+
87+ ./configure $CFG_FLAGS
88+
89+ # ----------------------
90+ echo " ----------------------"
91+ echo " [*] compile $LIB_NAME "
92+ echo " ----------------------"
93+
94+ make install -j$MR_HOST_NPROC
0 commit comments