[Fink-devel] OT: M4 the SDL Framework
I raised an issue with the libSDL project that their provided automake macro is incapable of detecting and configuring their provided runtime framework. Sam Lantinga responded with: I typically build and install SDL on Mac OS X using the unix style configure/install which works fine. Can you submit a patch for sdl.m4 which does the right thing for you? I'm attaching the file for you. I don't speak M4 and have only rudimentary understanding of frameworks. However, it does seem like the macro is searching for a file called 'sdl-config' and i don't see such a file inside the SDL framework. At this point i'm not sure if: 1) 'sdl-config' is in the framework but hidden. 2) The framework needs to be built differently to include 'sdl-config'. 3) The macro needs to test for some other file inside the framework. Here is the M4 file: # Configure paths for SDL # Sam Lantinga 9/21/99 # stolen from Manish Singh # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor # serial 1 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL2], [dnl dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix=$withval, sdl_prefix=) AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], sdl_exec_prefix=$withval, sdl_exec_prefix=) AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) min_sdl_version=ifelse([$1], ,0.9.0,$1) if test x$sdl_prefix$sdl_exec_prefix = x ; then PKG_CHECK_MODULES([SDL], [sdl2 = $min_sdl_version], [sdl_pc=yes], [sdl_pc=no]) else sdl_pc=no if test x$sdl_exec_prefix != x ; then sdl_config_args=$sdl_config_args --exec-prefix=$sdl_exec_prefix if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_exec_prefix/bin/sdl2-config fi fi if test x$sdl_prefix != x ; then sdl_config_args=$sdl_config_args --prefix=$sdl_prefix if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_prefix/bin/sdl2-config fi fi fi if test x$sdl_pc = xyes ; then no_sdl= SDL_CONFIG=pkg-config sdl2 else as_save_PATH=$PATH if test x$prefix != xNONE test $cross_compiling != yes; then PATH=$prefix/bin:$prefix/usr/bin:$PATH fi AC_PATH_PROG(SDL_CONFIG, sdl2-config, no, [$PATH]) PATH=$as_save_PATH AC_MSG_CHECKING(for SDL - version = $min_sdl_version) no_sdl= if test $SDL_CONFIG = no ; then no_sdl=yes else SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags` SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test x$enable_sdltest = xyes ; then ac_save_CFLAGS=$CFLAGS ac_save_CXXFLAGS=$CXXFLAGS ac_save_LIBS=$LIBS CFLAGS=$CFLAGS $SDL_CFLAGS CXXFLAGS=$CXXFLAGS $SDL_CFLAGS LIBS=$LIBS $SDL_LIBS dnl dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest AC_TRY_RUN([ #include stdio.h #include stdlib.h #include string.h #include SDL.h char* my_strdup (char *str) { char *new_str; if (str) { new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); strcpy (new_str, str); } else new_str = NULL; return new_str; } int main (int argc, char *argv[]) { int major, minor, micro; char *tmp_version; /* This hangs on some systems (?) system (touch conf.sdltest); */ { FILE *fp = fopen(conf.sdltest, a); if ( fp ) fclose(fp); } /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = my_strdup($min_sdl_version); if (sscanf(tmp_version, %d.%d.%d, major, minor, micro) != 3) { printf(%s, bad version string\n, $min_sdl_version); exit(1); } if (($sdl_major_version major) || (($sdl_major_version == major) ($sdl_minor_version minor)) || (($sdl_major_version == major) ($sdl_minor_version == minor) ($sdl_micro_version = micro))) { return 0; } else { printf(\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n, $sdl_major_version,
Re: [Fink-devel] OT: M4 the SDL Framework
dpkg -S sdl-config sdl: /sw/bin/sdl-config sdl is the dev files for fink installed sdl, I'm not sure what you are trying to build that needs sdl but it likely just does no know about your fink installation. Check that you have sdl installed, if you do then check whatever you are trying use sdl with to see if configure has an --sdl-prefix type switch to tell it that it's in whatever your fink install is, default /sw --- TS http://www.southofheaven.org/ Life begins and ends with chaos, live between the chaos! On 2012-07-31, at 5:05 PM, David Lowe wrote: I raised an issue with the libSDL project that their provided automake macro is incapable of detecting and configuring their provided runtime framework. Sam Lantinga responded with: I typically build and install SDL on Mac OS X using the unix style configure/install which works fine. Can you submit a patch for sdl.m4 which does the right thing for you? I'm attaching the file for you. I don't speak M4 and have only rudimentary understanding of frameworks. However, it does seem like the macro is searching for a file called 'sdl-config' and i don't see such a file inside the SDL framework. At this point i'm not sure if: 1) 'sdl-config' is in the framework but hidden. 2) The framework needs to be built differently to include 'sdl-config'. 3) The macro needs to test for some other file inside the framework. Here is the M4 file: # Configure paths for SDL # Sam Lantinga 9/21/99 # stolen from Manish Singh # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor # serial 1 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL2], [dnl dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix=$withval, sdl_prefix=) AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], sdl_exec_prefix=$withval, sdl_exec_prefix=) AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) min_sdl_version=ifelse([$1], ,0.9.0,$1) if test x$sdl_prefix$sdl_exec_prefix = x ; then PKG_CHECK_MODULES([SDL], [sdl2 = $min_sdl_version], [sdl_pc=yes], [sdl_pc=no]) else sdl_pc=no if test x$sdl_exec_prefix != x ; then sdl_config_args=$sdl_config_args --exec-prefix=$sdl_exec_prefix if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_exec_prefix/bin/sdl2-config fi fi if test x$sdl_prefix != x ; then sdl_config_args=$sdl_config_args --prefix=$sdl_prefix if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_prefix/bin/sdl2-config fi fi fi if test x$sdl_pc = xyes ; then no_sdl= SDL_CONFIG=pkg-config sdl2 else as_save_PATH=$PATH if test x$prefix != xNONE test $cross_compiling != yes; then PATH=$prefix/bin:$prefix/usr/bin:$PATH fi AC_PATH_PROG(SDL_CONFIG, sdl2-config, no, [$PATH]) PATH=$as_save_PATH AC_MSG_CHECKING(for SDL - version = $min_sdl_version) no_sdl= if test $SDL_CONFIG = no ; then no_sdl=yes else SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags` SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test x$enable_sdltest = xyes ; then ac_save_CFLAGS=$CFLAGS ac_save_CXXFLAGS=$CXXFLAGS ac_save_LIBS=$LIBS CFLAGS=$CFLAGS $SDL_CFLAGS CXXFLAGS=$CXXFLAGS $SDL_CFLAGS LIBS=$LIBS $SDL_LIBS dnl dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest AC_TRY_RUN([ #include stdio.h #include stdlib.h #include string.h #include SDL.h char* my_strdup (char *str) { char *new_str; if (str) { new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); strcpy (new_str, str); } else new_str = NULL; return new_str; } int main (int argc, char *argv[]) { int major, minor, micro; char *tmp_version; /* This hangs on some systems (?) system (touch conf.sdltest); */ { FILE *fp = fopen(conf.sdltest, a); if ( fp ) fclose(fp); } /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = my_strdup($min_sdl_version); if