From bebf6cd2d874080c7ef693b6e73170b03c6dbc57 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 23 Dec 2020 06:57:52 -0800 Subject: build: Android support. * Makefile (conftest.android): New helper target for testing for Android toolchain, via presence of __ANDROID__ preprocessor symbol, similarly to how we detect Darwin. * configure: New test for Android. This is mutually exclusive agains Darwin. On Android, we add some necessary feature selection macros to the compiler command line. --- Makefile | 6 ++++++ configure | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Makefile b/Makefile index dd7a2a11..6749a145 100644 --- a/Makefile +++ b/Makefile @@ -566,6 +566,12 @@ conftest.darwin: echo yes ; \ fi +.PHONY: conftest.android +conftest.android: + $(V)if echo | $(CC) -dM -E - | grep -s __ANDROID__ > /dev/null 2>&1 ; then \ + echo yes ; \ + fi + .PHONY: conftest.clean conftest.clean: $(V)rm -f conftest$(EXE) conftest.[co] \ diff --git a/configure b/configure index ee52e460..5c3fd974 100755 --- a/configure +++ b/configure @@ -202,6 +202,7 @@ termios_define= have_pkgconfig= libffi_cflags= darwin_target= +android_target= # # Parse configuration variables @@ -1143,6 +1144,21 @@ else printf "no\n" fi +if ! [ $darwin_target ] ; then + printf "Checking for Android environment ... " + + if [ "$(make conftest.android)" = "yes" ] ; then + printf "yes\n" + android_target=y + lang_flags="$lang_flags -D__ANDROID_API__=65535 -D_BSD_SOURCE" + printf "Regenerating config.make ..." + gen_config_make + printf "done\n" + else + printf "no\n" + fi +fi + # # Detect stupid FreeBSD problem: no defined way to reveal # traditional BSD functions if Unix compliance is selected with -- cgit v1.2.3