Fix #22745 - Fix Android static builds and autodetect NDK on Ubuntu ##build

This commit is contained in:
pancake 2024-03-25 19:23:57 +01:00 committed by GitHub
parent 56a53b96ae
commit 275e16719a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 6 deletions

View File

@ -18,6 +18,7 @@ endif
CFLAGS:=-I$(LTOP)/include $(CFLAGS)
ifeq (${ANDROID},1)
CFLAGS+=-lm
LDFLAGS+=-lm
else
ifneq (${OSTYPE},linux)

View File

@ -74,6 +74,7 @@ R_API RAnalOp *r_anal_op_clone(RAnalOp *op) {
}
#if 0
R_API RList *r_anal_op_list_new(void) {
RList *list = r_list_new ();
if (list) {
@ -81,6 +82,7 @@ R_API RList *r_anal_op_list_new(void) {
}
return list;
}
#endif
R_API void r_anal_op_init(RAnalOp *op) {
if (op) {

View File

@ -1018,7 +1018,7 @@ R_API void r_anal_op_fini(RAnalOp *op);
R_API char *r_anal_mnemonics(RAnal *anal, int id, bool json);
R_API int r_anal_op_reg_delta(RAnal *anal, ut64 addr, const char *name);
R_API bool r_anal_op_is_eob(RAnalOp *op);
R_API RList *r_anal_op_list_new(void);
// R_API RList *r_anal_op_list_new(void);
R_API int r_anal_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len, RAnalOpMask mask);
R_API int r_anal_opasm(RAnal *anal, ut64 pc, const char *s, ut8 *outbuf, int outlen);
R_API char *r_anal_op_tostring(RAnal *anal, RAnalOp *op);

View File

@ -45,9 +45,16 @@ all::
exit 1
endif
ifeq ($(shell type llvm-ar > /dev/null && echo ok),ok)
AR=llvm-ar
RANLIB=llvm-ranlib
CC_AR=llvm-ar -r ${LIBAR}
else
RANLIB=${CROSS}ranlib
AR=${CROSS}ar
CC_AR=${CROSS}ar -r ${LIBAR}
endif
PARTIALLD=${CROSS}ld -r
# -all_load
ONELIB=0

View File

@ -1,12 +1,12 @@
ifeq (${_INCLUDE_MK_GCC_},)
_INCLUDE_MK_GCC_=1
CC?=ndk-gcc
CC?=ndk-gcc -fPIC
OBJCOPY?=objcopy
RANLIB?=ranlib
ONELIB=0
AR?=ar
CC_AR=${AR} q ${LIBAR}
CFLAGS+=-MD
CFLAGS+=-MD -fPIC
CFLAGS_INCLUDE=-I
LDFLAGS_LINK=-l
LDFLAGS_LINKPATH=-L

View File

@ -3,6 +3,7 @@
BUILD=1
FLAGS=""
PREFIX="/data/data/org.radare.radare2installer/radare2"
export PAGER=cat
MAKE=make
gmake --help >/dev/null 2>&1
[ $? = 0 ] && MAKE=gmake
@ -59,7 +60,7 @@ x64-static|static-x64)
NDK_ARCH=x86
STATIC_BUILD=1
;;
arm64-static|static-arm64)
aarch64-static|static-aarch64|arm64-static|static-arm64)
NDK_ARCH=aarch64
STATIC_BUILD=1
;;
@ -127,7 +128,7 @@ if [ "${BUILD}" = 1 ]; then
echo ./configure --with-compiler=android \
--with-ostype=android \
--prefix=${PREFIX} ${CFGFLAGS}
cp -f plugins.android.cfg plugins.cfg
cp -f dist/plugins-cfg/plugins.android.cfg plugins.cfg
./configure --with-compiler=android --with-ostype=android \
--prefix=${PREFIX} ${CFGFLAGS} || exit 1
${MAKE} -s -j 4 || exit 1
@ -159,7 +160,6 @@ rm -rf "${HERE}/${D}/${PREFIX}/bin/r2pm"
# use busybox style symlinkz
cd binr/blob
#${MAKE} || exit 1
#CFLAGS=-static LDFLAGS=-static ${MAKE} -j4 || exit 1
${MAKE} -j4 || exit 1
${MAKE} install PREFIX="${PREFIX}" DESTDIR="${HERE}/${D}" || exit 1

View File

@ -60,6 +60,11 @@ if [ ! -x /work ]; then
echo "Using data from ${HOME}/.r2androidrc.."
else
#[ -z "${SDK}" ] && SDK="${HOME}/Downloads/android-sdk-${OS}"
if [ -z "${NDK}" ]; then
if [ -d /usr/lib/android-ndk ]; then
NDK="/usr/lib/android-ndk" # ubuntu
fi
fi
if [ -z "${NDK}" ]; then
# Checking if Android NDK is installed with macOS's brew
D=/usr/local/Caskroom/android-ndk/