Skip to content

android ndk build files and fixes #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions android/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
librtlsdr for Android
=====================

Building:
---------

To build librtlsdr for Android do the following:

1. Download the latest NDK from:
http://developer.android.com/tools/sdk/ndk/index.html

2. Extract the NDK.

3. Open a shell and make sure there exist an NDK global variable
set to the directory where you extracted the NDK.

4. Change directory to librtlsdr's "android/jni"

5. Set LIBUSB_INCLUDES and LIBUSB_PREBUILDS for proper locations.

6. Run "$NDK/ndk-build".

The librtlsdr library and tools can then be found in:
"android/libs/$ARCH"
22 changes: 22 additions & 0 deletions android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Android build config for libusb, examples and tests
# Copyright © 2012-2013 RealVNC Ltd. <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

LOCAL_PATH:= $(call my-dir)

include $(LOCAL_PATH)/librtlsdr.mk
include $(LOCAL_PATH)/tools.mk
20 changes: 20 additions & 0 deletions android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Android application build config for libusb
# Copyright © 2012-2013 RealVNC Ltd. <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

APP_ABI := all
APP_PLATFORM := android-9
57 changes: 57 additions & 0 deletions android/jni/librtlsdr.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Android build config for libusb
# Copyright © 2012-2013 RealVNC Ltd. <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

LOCAL_PATH:= $(call my-dir)
LIBRTLSDR_ROOT_REL:= ../..
LIBRTLSDR_ROOT_ABS:= $(LOCAL_PATH)/../..


# libusb
include $(CLEAR_VARS)

LOCAL_MODULE := libusb

LOCAL_SRC_FILES := $(LIBUSB_PREBUILDS)/$(TARGET_ARCH_ABI)/libusb1.0.so

LOCAL_EXPORT_C_INCLUDES := \
$(LIBUSB_INCLUDES)/libusb \

include $(PREBUILT_SHARED_LIBRARY)


# librtlsdr
include $(CLEAR_VARS)

LOCAL_MODULE := librtlsdr

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/librtlsdr.c \
$(LIBRTLSDR_ROOT_REL)/src/tuner_e4k.c \
$(LIBRTLSDR_ROOT_REL)/src/tuner_fc0012.c \
$(LIBRTLSDR_ROOT_REL)/src/tuner_fc0013.c \
$(LIBRTLSDR_ROOT_REL)/src/tuner_fc2580.c \
$(LIBRTLSDR_ROOT_REL)/src/tuner_r82xx.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb

include $(BUILD_SHARED_LIBRARY)
155 changes: 155 additions & 0 deletions android/jni/tools.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Android build config for libusb examples
# Copyright © 2012-2013 RealVNC Ltd. <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

LOCAL_PATH:= $(call my-dir)
LIBUSB_ROOT_REL:= ../..
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..


include $(CLEAR_VARS)

LOCAL_MODULE := rtl_test

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_test.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE := rtl_sdr

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_sdr.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE := rtl_tcp

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_tcp.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE := rtl_power

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_power.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE := rtl_fm

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_fm.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE := rtl_eeprom

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_eeprom.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE := rtl_adsb

LOCAL_SRC_FILES := \
$(LIBRTLSDR_ROOT_REL)/src/rtl_adsb.c \
$(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \

LOCAL_C_INCLUDES += \
$(LIBRTLSDR_ROOT_ABS)/include \
$(LIBRTLSDR_ROOT_ABS)/src/convenience \

LOCAL_LDLIBS := -llog

LOCAL_SHARED_LIBRARIES += libusb
LOCAL_SHARED_LIBRARIES += librtlsdr

include $(BUILD_EXECUTABLE)
2 changes: 1 addition & 1 deletion src/rtl_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int cic_9_tables[][10] = {
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
};

#ifdef _MSC_VER
#if defined(_MSC_VER ) || defined(__ANDROID__)
double log2(double n)
{
return log(n) / log(2.0);
Expand Down
2 changes: 1 addition & 1 deletion src/rtl_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int cic_9_tables[][10] = {
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
};

#ifdef _MSC_VER
#if defined(_MSC_VER ) || defined(__ANDROID__)
double log2(double n)
{
return log(n) / log(2.0);
Expand Down