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_BUILD_NAME"
26+ env_assert " MR_CC"
27+ env_assert " MR_BUILD_SOURCE"
28+ env_assert " MR_BUILD_PREFIX"
29+ env_assert " MR_SYS_ROOT"
30+ env_assert " MR_HOST_NPROC"
31+ echo " MR_DEBUG:$MR_DEBUG "
32+ echo " ===check env end==="
33+
34+ # prepare build config
35+ CFG_FLAGS=" --prefix=$MR_BUILD_PREFIX --disable-dependency-tracking --disable-silent-rules --disable-apidoc --enable-static --disable-shared"
36+ CFLAGS=" $MR_OTHER_CFLAGS "
37+
38+ if [[ " $MR_DEBUG " == " debug" ]]; then
39+ CFG_FLAGS=" ${CFG_FLAGS} use_examples=yes"
40+ fi
41+
42+ # for cross compile
43+ if [[ $( uname -m) != " $MR_ARCH " || " $MR_FORCE_CROSS " ]]; then
44+ echo " [*] cross compile, on $( uname -m) compile $MR_PLAT $MR_ARCH ."
45+ # https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html
46+ CFLAGS=" $CFLAGS -isysroot $MR_SYS_ROOT "
47+ CFG_FLAGS=" $CFG_FLAGS --host=$MR_ARCH -apple-darwin --with-sysroot=$MR_SYS_ROOT "
48+ fi
49+
50+ echo " ----------------------"
51+ echo " [*] configurate $LIB_NAME "
52+ echo " ----------------------"
53+
54+ cd $MR_BUILD_SOURCE
55+
56+ if [[ -f ' configure' ]]; then
57+ echo " reuse configure"
58+ else
59+ echo " auto generate configure"
60+ autoreconf -if > /dev/null
61+ fi
62+
63+
64+ echo
65+ echo " CC: $MR_TRIPLE_CC "
66+ echo " CFG_FLAGS: $CFG_FLAGS "
67+ echo " CFLAGS: $CFLAGS "
68+ echo
69+
70+ ./configure $CFG_FLAGS \
71+ CC=" $MR_TRIPLE_CC " \
72+ CFLAGS=" $CFLAGS " \
73+ LDFLAGS=" $CFLAGS " \
74+ > /dev/null
75+
76+ # ----------------------
77+ echo " ----------------------"
78+ echo " [*] compile $LIB_NAME "
79+ echo " ----------------------"
80+
81+ make install -j$MR_HOST_NPROC > /dev/null
0 commit comments