Fixed bug 2812 - Make libSDL2main.a usable on Android via a dummy symbol
authorSam Lantinga <slouken@libsdl.org>
Sun, 13 Aug 2017 18:12:06 -0700
changeset 11263f85618f8ba81
parent 11262 8e5441ab6c63
child 11264 d631b3dac8be
Fixed bug 2812 - Make libSDL2main.a usable on Android via a dummy symbol

Jonas Kulla

This eliminates the need to manually compile in SDL_main_android.c.
Instead, add "-lSDL2main -Wl,-u,SDL_main_dummy" when linking.

I don't know how the nkd-build process works, but unless it was
for some reason linking libSDL2main.a it should be unaffected.
configure
configure.in
src/main/android/SDL_android_main.c
     1.1 --- a/configure	Sun Aug 13 17:59:59 2017 -0700
     1.2 +++ b/configure	Sun Aug 13 18:12:06 2017 -0700
     1.3 @@ -23555,8 +23555,10 @@
     1.4                  ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
     1.5                  CFLAGS="$CFLAGS $ANDROID_CFLAGS"
     1.6                  SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
     1.7 +                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
     1.8                  EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
     1.9                  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
    1.10 +                SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
    1.11  
    1.12                  if test x$enable_video = xyes; then
    1.13                      SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
     2.1 --- a/configure.in	Sun Aug 13 17:59:59 2017 -0700
     2.2 +++ b/configure.in	Sun Aug 13 18:12:06 2017 -0700
     2.3 @@ -3160,8 +3160,10 @@
     2.4                  ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
     2.5                  CFLAGS="$CFLAGS $ANDROID_CFLAGS"
     2.6                  SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
     2.7 +                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
     2.8                  EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
     2.9                  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
    2.10 +                SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
    2.11  
    2.12                  if test x$enable_video = xyes; then
    2.13                      SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
     3.1 --- a/src/main/android/SDL_android_main.c	Sun Aug 13 17:59:59 2017 -0700
     3.2 +++ b/src/main/android/SDL_android_main.c	Sun Aug 13 18:12:06 2017 -0700
     3.3 @@ -15,6 +15,9 @@
     3.4  *******************************************************************************/
     3.5  #include <jni.h>
     3.6  
     3.7 +/* Dummy symbol so '-u SDL_main_dummy' forces ld to link in libSDL2main.a */
     3.8 +JNIEXPORT int SDL_main_dummy;
     3.9 +
    3.10  /* Called before SDL_main() to initialize JNI bindings in SDL library */
    3.11  extern void SDL_Android_Init(JNIEnv* env, jclass cls);
    3.12