forked from DragonMinded/libdragon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·59 lines (49 loc) · 1.73 KB
/
build.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
#!/usr/bin/env bash
# Bash strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
if [[ -z ${N64_INST-} ]]; then
echo N64_INST environment variable is not defined
echo Please set N64_INST to point to your libdragon toolchain directory
exit 1
fi
if [[ $OSTYPE == 'darwin'* ]]; then
if command -v brew >/dev/null; then
brew install libpng
CFLAGS="-I$(brew --prefix)/include"
LDFLAGS="-L$(brew --prefix)/lib"
fi
fi
CFLAGS=${CFLAGS:-}; export CFLAGS
LDFLAGS=${LDFLAGS:-}; export LDFLAGS
makeWithParams(){
make -j"${JOBS}" "$@" || \
sudo env N64_INST="$N64_INST" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
make -j"${JOBS}" "$@"
}
# Limit the number of make jobs to the number of CPUs
JOBS="${JOBS:-$(getconf _NPROCESSORS_ONLN)}"
JOBS="${JOBS:-1}" # If getconf returned nothing, default to 1
# Specify where to get libmikmod from and where to put it
LIBMIKMOD_REPO=https://github.com/networkfusion/libmikmod.git
LIBMIKMOD_COMMIT=738b1e8b11b470360b1b919680d1d88429d9d174
LIBMIKMOD_DIR=/tmp/libmikmod
# Clean, build, and install libdragon + tools
makeWithParams clobber
makeWithParams install tools-install
# Remove the cloned libmikmod repo if it already exists
[ -d "$LIBMIKMOD_DIR" ] && rm -Rf $LIBMIKMOD_DIR
# Clone, compile, and install libmikmod
git clone $LIBMIKMOD_REPO $LIBMIKMOD_DIR
pushd $LIBMIKMOD_DIR/n64
git checkout $LIBMIKMOD_COMMIT
makeWithParams
makeWithParams install
popd
rm -Rf $LIBMIKMOD_DIR
# Build examples and tests - libdragon must be already installed at this point,
# so first clobber the build to make sure that everything works against the
# installed version rather than using local artifacts.
makeWithParams clobber
makeWithParams examples
makeWithParams test