2015-02-17 03:19:30 +00:00
#! /usr/bin/env bash
# vim: set ts=3 sw=3 noet ft=sh : bash
2013-02-10 17:30:38 +00:00
2014-07-27 01:56:49 +00:00
. ./libretro-config.sh
2014-08-18 05:07:05 +00:00
#split TARGET_ABI string into an array we can iterate over
IFS = ' ' read -ra ABIS <<< " $TARGET_ABIS "
2013-07-12 15:31:12 +00:00
# BSDs don't have readlink -f
read_link( )
{
2015-02-17 03:19:30 +00:00
TARGET_FILE = " $1 "
cd $( dirname " $TARGET_FILE " )
TARGET_FILE = $( basename " $TARGET_FILE " )
2013-07-12 15:31:12 +00:00
2015-02-17 03:19:30 +00:00
while [ -L " $TARGET_FILE " ]
do
TARGET_FILE = $( readlink " $TARGET_FILE " )
cd $( dirname " $TARGET_FILE " )
TARGET_FILE = $( basename " $TARGET_FILE " )
done
2013-07-12 15:31:12 +00:00
2015-02-17 03:19:30 +00:00
PHYS_DIR = $( pwd -P)
RESULT = " $PHYS_DIR / $TARGET_FILE "
echo $RESULT
2013-07-12 15:31:12 +00:00
}
SCRIPT = $( read_link " $0 " )
echo " Script: $SCRIPT "
2013-04-29 20:12:35 +00:00
BASE_DIR = $( dirname $SCRIPT )
RARCH_DIR = $BASE_DIR /dist
2013-04-29 20:36:13 +00:00
RARCH_DIST_DIR = $RARCH_DIR /android
2013-10-30 01:11:09 +00:00
FORMAT = _android
2013-05-18 00:11:06 +00:00
FORMAT_EXT = so
2013-07-12 15:31:12 +00:00
2013-02-10 17:30:38 +00:00
die( )
{
2015-02-17 03:19:30 +00:00
echo $1
#exit 1
2013-02-10 17:30:38 +00:00
}
2014-08-22 11:13:37 +00:00
# $1 is core name
2014-08-22 11:40:22 +00:00
# $2 is subdir (if there's no subdir, put "." here)
2015-11-09 13:53:42 +00:00
# $3 is appendage to core name for output JNI file
2014-08-22 11:40:22 +00:00
build_libretro_generic_makefile( )
2014-06-21 16:34:11 +00:00
{
2015-02-17 03:19:30 +00:00
cd $BASE_DIR
if [ -d " libretro- ${ 1 } " ] ; then
echo " === Building ${ 1 } === "
cd libretro-${ 1 }
cd ${ 2 }
for a in " ${ ABIS [@] } " ; do
if [ -z " ${ NOCLEAN } " ] ; then
ndk-build clean APP_ABI = ${ a } || die " Failed to clean ${ a } ${ 1 } "
fi
ndk-build -j$JOBS APP_ABI = ${ a } || die " Failed to build ${ a } ${ 1 } "
2015-11-09 13:53:42 +00:00
cp ../libs/${ a } /libretro${ 3 } .${ FORMAT_EXT } $RARCH_DIST_DIR /${ a } /${ 1 } _libretro${ FORMAT } .${ FORMAT_EXT }
2015-02-17 03:19:30 +00:00
done
else
echo " ${ 1 } not fetched, skipping ... "
fi
2014-06-21 16:34:11 +00:00
}
2016-05-18 17:15:37 +00:00
#same as above for armv7 with neon since android ndk does not see it as as its own architecture
build_libretro_generic_makefile_armv7neon( )
{
cd $BASE_DIR
if [ -d " libretro- ${ 1 } " ] ; then
echo "=== Attempting armv7-neon Build ==="
cd libretro-${ 1 }
cd ${ 2 }
if [ -z " ${ NOCLEAN } " ] ; then
ndk-build clean APP_ABI = "armeabi-v7a" NDK_OUT = "../obj/local/armeabi-v7a-neon" NDK_LIBS_OUT = "../libs/armeabi-v7a-neon" V7NEONOPTIMIZATION = "1" || die " Failed to clean armeabi_v7a_neon ${ 1 } "
fi
ndk-build -j$JOBS APP_ABI = "armeabi-v7a" NDK_OUT = "../obj/local/armeabi-v7a-neon" NDK_LIBS_OUT = "../libs/armeabi-v7a-neon" V7NEONOPTIMIZATION = "1" || die " Failed to build armeabi_v7a_neon ${ 1 } "
mkdir -p $RARCH_DIST_DIR /armeabi-v7a-neon
cp ../libs/armeabi-v7a-neon/armeabi-v7a/libretro${ 3 } .${ FORMAT_EXT } $RARCH_DIST_DIR /armeabi-v7a-neon/${ 1 } _libretro${ FORMAT } .${ FORMAT_EXT }
else
echo " ${ 1 } not fetched, skipping ... "
fi
}
2013-04-29 20:12:35 +00:00
create_dist_dir( )
{
2015-02-17 03:19:30 +00:00
if [ -d $RARCH_DIR ] ; then
echo " Directory $RARCH_DIR already exists, skipping creation... "
else
mkdir $RARCH_DIR
fi
if [ -d $RARCH_DIST_DIR ] ; then
echo " Directory $RARCH_DIST_DIR already exists, skipping creation... "
else
mkdir $RARCH_DIST_DIR
fi
2022-12-20 11:13:49 +00:00
2015-02-17 03:19:30 +00:00
for a in " ${ ABIS [@] } " ; do
if [ -d $RARCH_DIST_DIR /${ a } ] ; then
echo " Directory $RARCH_DIST_DIR / ${ a } already exists, skipping creation... "
else
mkdir $RARCH_DIST_DIR /${ a }
fi
done
2013-04-29 20:12:35 +00:00
}
2013-10-19 18:22:44 +00:00
2014-07-13 02:22:50 +00:00
2013-04-29 20:12:35 +00:00
create_dist_dir
2013-05-03 15:22:09 +00:00
if [ $1 ] ; then
2015-11-09 02:24:41 +00:00
WANT_CORES = " $1 "
2013-05-03 15:22:09 +00:00
else
2015-11-09 02:24:41 +00:00
WANT_CORES = " \
2048 \
bluemsx \
fmsx \
2020-02-17 05:26:47 +00:00
opera \
2021-01-19 20:34:44 +00:00
lowresnx\
2015-11-09 02:24:41 +00:00
mednafen_lynx \
mednafen_ngp \
mednafen_pce_fast \
mednafen_supergrafx \
mednafen_pcfx \
mednafen_vb \
mednafen_wswan \
mednafen_psx \
catsfc \
snes9x \
2017-08-13 02:22:19 +00:00
snes9x2002 \
snes9x2005 \
2022-12-20 11:13:49 +00:00
chimerasnes \
2017-08-13 02:22:19 +00:00
snes9x2010 \
2015-11-09 02:24:41 +00:00
genesis_plus_gx \
virtualjaguar \
stella \
gpsp \
dosbox \
picodrive \
3dengine \
prosystem \
meteor \
nxengine \
o2em \
2015-11-09 02:28:21 +00:00
pcsx_rearmed \
2017-02-17 14:48:46 +00:00
parallel_n64 \
2015-11-09 02:35:46 +00:00
vecx \
nestopia \
2015-11-09 02:38:20 +00:00
tgbdual \
2015-11-09 02:40:55 +00:00
quicknes \
2017-08-13 02:22:19 +00:00
handy \
2015-11-09 02:55:35 +00:00
gambatte \
2022-12-26 21:26:59 +00:00
numero \
2015-11-09 02:55:35 +00:00
prboom \
2015-11-09 03:10:18 +00:00
tyrquake \
vba_next \
2015-11-09 12:38:55 +00:00
vbam \
2015-11-09 12:44:16 +00:00
fceumm \
2015-11-09 13:42:28 +00:00
dinothawr \
2015-11-09 13:53:42 +00:00
desmume \
fb_alpha \
2016-05-18 22:27:35 +00:00
fb_alpha_new \
2015-11-09 13:42:28 +00:00
bsnes_mercury_performance \
2015-11-14 03:27:41 +00:00
bsnes_performance \
2016-02-23 20:17:03 +00:00
mame2000 \
2016-01-23 18:13:00 +00:00
mame2003 \
2017-03-24 06:35:03 +00:00
mrboom \
xrick \
2017-03-26 14:29:17 +00:00
pocketcdg \
crocods \
2018-05-09 15:07:12 +00:00
puae \
scummvm"
2013-05-03 15:22:09 +00:00
fi
2015-11-09 02:24:41 +00:00
for core in $WANT_CORES ; do
path = "jni"
2015-11-09 13:53:42 +00:00
append = ""
2020-01-22 03:52:39 +00:00
if [ $core = "snes9x" ] || [ $core = "genesis_plus_gx" ] || [ $core = "meteor" ] || [ $core = "nestopia" ] || [ $core = "yabause" ] || [ $core = "vbam" ] || [ $core = "vba_next" ] || [ $core = "ppsspp" ] || [ $core = "px68k" ] ; then
2015-11-09 02:24:41 +00:00
path = "libretro/jni"
fi
2015-11-09 02:51:28 +00:00
if [ $core = "gambatte" ] ; then
path = "libgambatte/libretro/jni"
2022-12-26 21:26:59 +00:00
fi
if [ $core = "numero" ] ; then
path = "libnumero/libretro/jni"
2015-11-09 02:51:28 +00:00
fi
2015-11-09 13:53:42 +00:00
if [ $core = "desmume" ] ; then
path = "desmume/src/libretro/jni"
fi
if [ $core = "fb_alpha" ] ; then
path = "svn-current/trunk/projectfiles/libretro-android/jni"
fi
2015-11-09 13:42:28 +00:00
if [ $core = "bsnes_mercury_performance" ] || [ $core = "bsnes_performance" ] ; then
path = "target-libretro/jni"
2015-11-09 13:53:42 +00:00
append = " _ $core "
2015-11-09 13:42:28 +00:00
fi
2022-12-20 11:13:49 +00:00
2018-05-09 15:07:12 +00:00
if [ $core = "scummvm" ] ; then
2023-03-05 16:32:39 +00:00
path = "backends/platform/libretro/build/jni"
2018-05-09 15:07:12 +00:00
fi
2021-01-19 20:34:44 +00:00
if [ $core = "lowresnx" ] ; then
path = "platform/LibRetro/jni"
fi
2015-11-09 13:53:42 +00:00
build_libretro_generic_makefile $core $path $append
2016-05-18 17:15:37 +00:00
build_libretro_generic_makefile_armv7neon $core $path $append
2015-11-09 02:24:41 +00:00
done