mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-25 08:35:31 +00:00
4349cb5769
Denis Bernard This patch to Android.mk adds support for static linking of libSDL for Android applications. A patched readme with static build instructions is also provided. It does not break existing build environments setup according to the README-android.txt since the static library version will not be built in not required. The static build uses the Android NDK module system (see docs/IMPORT-MODULE.html in the NDK folder and step 5 in the instructions below). Instructions: 1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project. 2. Create a symlink to SDL/src/main/android/SDL_android_main.c as <project>/jni/src/SDL_android_main.c 3. Rename <project>/jni/src/Android_static.mk to <project>/jni/src/Android.mk (overwrite the existing one) 4. Edit <project>/jni/src/Android.mk to include your source files 5. create and export an environment variable named NDK_MODULE_PATH that points to the parent directory of this SDL directory. e.g.: export NDK_MODULE_PATH="$PWD"/.. 6. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to System.loadLibrary("SDL2") line 42. 7. Run 'ndk-build' (a script provided by the NDK). This compiles the C source Although this requires an environment variable to be setup, it can be added once and for all to the main Android.mk of the project.
69 lines
2.1 KiB
Makefile
Executable file
69 lines
2.1 KiB
Makefile
Executable file
LOCAL_PATH := $(call my-dir)
|
|
|
|
###########################
|
|
#
|
|
# SDL shared library
|
|
#
|
|
###########################
|
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_MODULE := SDL2
|
|
|
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
|
|
|
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
|
|
|
|
LOCAL_SRC_FILES := \
|
|
$(subst $(LOCAL_PATH)/,, \
|
|
$(wildcard $(LOCAL_PATH)/src/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
|
|
$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
|
|
$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
|
|
$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/events/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/file/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/render/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
|
|
$(wildcard $(LOCAL_PATH)/src/test/*.c))
|
|
|
|
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
|
|
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
|
|
|
|
include $(BUILD_SHARED_LIBRARY)
|
|
|
|
###########################
|
|
#
|
|
# SDL static library
|
|
#
|
|
###########################
|
|
|
|
LOCAL_MODULE := SDL2_static
|
|
|
|
LOCAL_MODULE_FILENAME := libSDL2
|
|
|
|
LOCAL_SRC_FILES += $(LOCAL_PATH)/src/main/android/SDL_android_main.c
|
|
|
|
LOCAL_LDLIBS :=
|
|
LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
|
|
|
|
include $(BUILD_STATIC_LIBRARY)
|