Fixed bug 1973 - test/Makefile.in fails on Mac OS X with X11 enabled...
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Jul 2013 12:47:47 -0700
changeset 7495c4ba5e5c2765
parent 7494 25575b2a188f
child 7496 13dfa871f0af
Fixed bug 1973 - test/Makefile.in fails on Mac OS X with X11 enabled...

Ryan C. Gordon

If you have the X11 SDK installed on Mac OS X, you'll build with X11 support, but the Makefile doesn't build anything but the Cocoa testnative code for Mac OS X, which is fine, but then testnative fails to link because testnative.h enables the X11 support based on the SDL config header.

Building the testnativex11.c code on Mac OS X doesn't work because you need to explicitly link with "-L/usr/X11/lib -lX11" if this code is enabled, but you can't link with that by default because the X11 SDK might be missing.

So this needs a little configure magic to do the right thing (or forcibly disabling X11 support on Mac OS X in testnative.h).
test/Makefile.in
test/configure
test/configure.in
     1.1 --- a/test/Makefile.in	Sun Jul 21 12:37:43 2013 -0700
     1.2 +++ b/test/Makefile.in	Sun Jul 21 12:47:47 2013 -0700
     1.3 @@ -150,8 +150,9 @@
     1.4  
     1.5  ifeq (@ISMACOSX@,true)
     1.6  testnative$(EXE): $(srcdir)/testnative.c \
     1.7 -			$(srcdir)/testnativecocoa.m
     1.8 -	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -framework Cocoa
     1.9 +			$(srcdir)/testnativecocoa.m \
    1.10 +			$(srcdir)/testnativex11.c
    1.11 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -framework Cocoa @XLIB@
    1.12  endif
    1.13  
    1.14  ifeq (@ISWINDOWS@,true)
    1.15 @@ -163,7 +164,7 @@
    1.16  ifeq (@ISUNIX@,true)
    1.17  testnative$(EXE): $(srcdir)/testnative.c \
    1.18  			$(srcdir)/testnativex11.c
    1.19 -	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -L/usr/X11/lib -lX11
    1.20 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @XLIB@
    1.21  endif
    1.22  
    1.23  testoverlay2$(EXE): $(srcdir)/testoverlay2.c
     2.1 --- a/test/configure	Sun Jul 21 12:37:43 2013 -0700
     2.2 +++ b/test/configure	Sun Jul 21 12:47:47 2013 -0700
     2.3 @@ -585,6 +585,7 @@
     2.4  ac_subst_vars='LTLIBOBJS
     2.5  LIBOBJS
     2.6  SDL_TTF_LIB
     2.7 +XLIB
     2.8  GLLIB
     2.9  CPP
    2.10  XMKMF
    2.11 @@ -3793,6 +3794,7 @@
    2.12          :
    2.13      else
    2.14          XPATH="-L$ac_x_libraries"
    2.15 +        XLIB="-L$ac_x_libraries -lX11"
    2.16      fi
    2.17  fi
    2.18  
    2.19 @@ -3865,6 +3867,7 @@
    2.20  
    2.21  
    2.22  
    2.23 +
    2.24  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5
    2.25  $as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; }
    2.26  if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then :
     3.1 --- a/test/configure.in	Sun Jul 21 12:37:43 2013 -0700
     3.2 +++ b/test/configure.in	Sun Jul 21 12:47:47 2013 -0700
     3.3 @@ -100,6 +100,7 @@
     3.4          :
     3.5      else
     3.6          XPATH="-L$ac_x_libraries"
     3.7 +        XLIB="-L$ac_x_libraries -lX11"
     3.8      fi
     3.9  fi
    3.10  
    3.11 @@ -141,6 +142,7 @@
    3.12  fi
    3.13  
    3.14  AC_SUBST(GLLIB)
    3.15 +AC_SUBST(XLIB)
    3.16  
    3.17  dnl Check for SDL_ttf
    3.18  AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)