From 6089f00259cd80cace1b567b32344d3e8c8f616c Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 7 Apr 2020 16:57:20 -0400 Subject: Automagically detect SDL2_image, SDL2_ttf, SDL2_mixer library directories. --- Makefile.am | 8 +-- configure.ac | 173 +++++++++++++---------------------------------------- guix.scm | 15 +---- sdl2/config.scm.in | 8 +-- 4 files changed, 52 insertions(+), 152 deletions(-) diff --git a/Makefile.am b/Makefile.am index a3439f4..ecf18a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,7 +56,7 @@ SOURCES = \ sdl2/input/mouse.scm \ sdl2/input/text.scm -if WITH_LIBSDL2_IMAGE +if HAVE_SDL2_IMAGE SOURCES += \ sdl2/bindings/image.scm \ @@ -64,7 +64,7 @@ SOURCES += \ endif -if WITH_LIBSDL2_TTF +if HAVE_SDL2_TTF SOURCES += \ sdl2/bindings/ttf.scm \ @@ -72,7 +72,7 @@ SOURCES += \ endif -if WITH_LIBSDL2_MIXER +if HAVE_SDL2_MIXER SOURCES += \ sdl2/bindings/mixer.scm \ @@ -90,7 +90,7 @@ doc_guile_sdl2_TEXINFOS = \ AM_MAKEINFOHTMLFLAGS = --css-ref=https://dthompson.us/css/dthompson.css \ --css-include=doc/manual.css -dvi: # Don't build dvi docs +#dvi: # Don't build dvi docs EXTRA_DIST += \ pre-inst-env.in \ diff --git a/configure.ac b/configure.ac index bb1d591..4308b4e 100644 --- a/configure.ac +++ b/configure.ac @@ -33,143 +33,52 @@ GUILE_PROGS # Core SDL2 PKG_CHECK_MODULES([SDL2], [sdl2]) - -LIBSDL2="libSDL2" -LIBSDL2_LIBDIR="no" -LIBSDL2_PREFIX="no" - -AC_ARG_WITH([libsdl2-prefix], - [AS_HELP_STRING([--with-libsdl2-prefix=DIR], [search for SDL2 in DIR])], - [case "$withval" in - yes|no) - ;; - *) - LIBSDL2="$withval/lib/libSDL2" - LIBSDL2_PREFIX="$withval" - LIBSDL2_LIBDIR="$withval/lib" - ;; - esac]) - -dnl Library name suitable for `dynamic-link'. -AC_MSG_CHECKING([for libSDL2 shared library name]) -AC_MSG_RESULT([$LIBSDL2]) -AC_SUBST([LIBSDL2]) -AC_SUBST([LIBSDL2_PREFIX]) -AC_SUBST([LIBSDL2_LIBDIR]) +PKG_CHECK_VAR([SDL2_LIBDIR], [sdl2], [libdir]) +AC_MSG_CHECKING([SDL2 library path]) +AS_IF([test "x$SDL2_LIBDIR" = "x"], [ + AC_MSG_FAILURE([unable to find SDL2 library directory]) +], [ + AC_MSG_RESULT([$SDL2_LIBDIR]) +]) +AC_SUBST([SDL2_LIBDIR]) # SDL2_image -AC_ARG_WITH([libsdl2_image], - AS_HELP_STRING([--with-libsdl2-image], - [Build with the SDL2_image library]), - [], [with_libsdl2_image=yes]) - - -if test "x$with_libsdl2_image" = "xyes"; then - PKG_CHECK_MODULES([SDL2_image], [SDL2_image]) -fi - -LIBSDL2_IMAGE="libSDL2_image" -LIBSDL2_IMAGE_LIBDIR="no" -LIBSDL2_IMAGE_PREFIX="no" - -AC_ARG_WITH([libsdl2-image-prefix], - [AS_HELP_STRING([--with-libsdl2-image-prefix=DIR], - [search for SDL2_image in DIR])], - [case "$withval" in - yes|no) - ;; - *) - LIBSDL2_IMAGE="$withval/lib/libSDL2_image" - LIBSDL2_IMAGE_PREFIX="$withval" - LIBSDL2_IMAGE_LIBDIR="$withval/lib" - ;; - esac]) - -AM_CONDITIONAL([WITH_LIBSDL2_IMAGE], [test "x$with_libsdl2_image" = "xyes"]) - -if test "x$with_libsdl2_image" = "xyes"; then - AC_MSG_CHECKING([for libSDL2_image shared library name]) - AC_MSG_RESULT([$LIBSDL2_IMAGE]) -fi - -AC_SUBST([LIBSDL2_IMAGE]) -AC_SUBST([LIBSDL2_IMAGE_PREFIX]) -AC_SUBST([LIBSDL2_IMAGE_LIBDIR]) +PKG_CHECK_MODULES([SDL2_image], [SDL2_image], [ + PKG_CHECK_VAR([SDL2_IMAGE_LIBDIR], [SDL2_image], [libdir]) + AC_MSG_CHECKING([SDL2_image library path]) + AS_IF([test "x$SDL2_IMAGE_LIBDIR" = "x"], [ + AC_MSG_RESULT([none]) + ], [ + AC_MSG_RESULT([$SDL2_IMAGE_LIBDIR]) + ]) +], [ ]) # do not throw an error if lib is not found +AM_CONDITIONAL([HAVE_SDL2_IMAGE], [test "x$SDL2_IMAGE_LIBDIR" != "x"]) +AC_SUBST([SDL2_IMAGE_LIBDIR]) # SDL2_ttf -AC_ARG_WITH([libsdl2_ttf], - AS_HELP_STRING([--with-libsdl2-ttf], - [Build with the SDL2_ttf library]), - [], [with_libsdl2_ttf=yes]) - -if test "x$with_libsdl2_ttf" = "xyes"; then - PKG_CHECK_MODULES([SDL2_ttf], [SDL2_ttf]) -fi - -LIBSDL2_TTF="libSDL2_ttf" -LIBSDL2_TTF_LIBDIR="no" -LIBSDL2_TTF_PREFIX="no" - -AC_ARG_WITH([libsdl2-ttf-prefix], - [AS_HELP_STRING([--with-libsdl2-ttf-prefix=DIR], - [search for SDL2_ttf in DIR])], - [case "$withval" in - yes|no) - ;; - *) - LIBSDL2_TTF="$withval/lib/libSDL2_ttf" - LIBSDL2_TTF_PREFIX="$withval" - LIBSDL2_TTF_LIBDIR="$withval/lib" - ;; - esac]) - -AM_CONDITIONAL([WITH_LIBSDL2_TTF], [test "x$with_libsdl2_ttf" = "xyes"]) - -if test "x$with_libsdl2_ttf" = "xyes"; then - AC_MSG_CHECKING([for libSDL2_ttf shared library name]) - AC_MSG_RESULT([$LIBSDL2_TTF]) -fi - -AC_SUBST([LIBSDL2_TTF]) -AC_SUBST([LIBSDL2_TTF_PREFIX]) -AC_SUBST([LIBSDL2_TTF_LIBDIR]) +PKG_CHECK_MODULES([SDL2_ttf], [SDL2_ttf], [ + PKG_CHECK_VAR([SDL2_TTF_LIBDIR], [SDL2_ttf], [libdir]) + AC_MSG_CHECKING([SDL2_ttf library path]) + AS_IF([test "x$SDL2_TTF_LIBDIR" = "x"], [ + AC_MSG_RESULT([none]) + ], [ + AC_MSG_RESULT([$SDL2_TTF_LIBDIR]) + ]) +], [ ]) # do not throw an error if lib is not found +AM_CONDITIONAL([HAVE_SDL2_TTF], [test "x$SDL2_TTF_LIBDIR" != "x"]) +AC_SUBST([SDL2_TTF_LIBDIR]) # SDL2_mixer -AC_ARG_WITH([libsdl2_mixer], - AS_HELP_STRING([--with-libsdl2-mixer], - [Build with the SDL2_mixer library]), - [], [with_libsdl2_mixer=yes]) - -if test "x$with_libsdl2_mixer" = "xyes"; then - PKG_CHECK_MODULES([SDL2_mixer], [SDL2_mixer]) -fi - -LIBSDL2_MIXER="libSDL2_mixer" -LIBSDL2_MIXER_LIBDIR="no" -LIBSDL2_MIXER_PREFIX="no" - -AC_ARG_WITH([libsdl2-mixer-prefix], - [AS_HELP_STRING([--with-libsdl2-mixer-prefix=DIR], - [search for SDL2_mixer in DIR])], - [case "$withval" in - yes|no) - ;; - *) - LIBSDL2_MIXER="$withval/lib/libSDL2_mixer" - LIBSDL2_MIXER_PREFIX="$withval" - LIBSDL2_MIXER_LIBDIR="$withval/lib" - ;; - esac]) - -AM_CONDITIONAL([WITH_LIBSDL2_MIXER], [test "x$with_libsdl2_mixer" = "xyes"]) - -if test "x$with_libsdl2_mixer" = "xyes"; then - AC_MSG_CHECKING([for libSDL2_mixer shared library name]) - AC_MSG_RESULT([$LIBSDL2_MIXER]) -fi - -AC_SUBST([LIBSDL2_MIXER]) -AC_SUBST([LIBSDL2_MIXER_PREFIX]) -AC_SUBST([LIBSDL2_MIXER_LIBDIR]) +PKG_CHECK_MODULES([SDL2_mixer], [SDL2_mixer], [ + PKG_CHECK_VAR([SDL2_MIXER_LIBDIR], [SDL2_mixer], [libdir]) + AC_MSG_CHECKING([SDL2_mixer library path]) + AS_IF([test "x$SDL2_MIXER_LIBDIR" = "x"], [ + AC_MSG_RESULT([none]) + ], [ + AC_MSG_RESULT([$SDL2_MIXER_LIBDIR]) + ]) +], [ ]) # do not throw an error if lib is not found +AM_CONDITIONAL([HAVE_SDL2_MIXER], [test "x$SDL2_MIXER_LIBDIR" != "x"]) +AC_SUBST([SDL2_MIXER_LIBDIR]) AC_OUTPUT diff --git a/guix.scm b/guix.scm index 6fa780e..4f131f7 100644 --- a/guix.scm +++ b/guix.scm @@ -68,20 +68,11 @@ (package (name "guile-sdl2") - (version "0.1.2") + (version "0.4.0") (source (local-file %source-dir #:recursive? #t #:select? git-file?)) (build-system gnu-build-system) (arguments - '(#:configure-flags - (list (string-append "--with-libsdl2-prefix=" - (assoc-ref %build-inputs "sdl2")) - (string-append "--with-libsdl2-image-prefix=" - (assoc-ref %build-inputs "sdl2-image")) - (string-append "--with-libsdl2-ttf-prefix=" - (assoc-ref %build-inputs "sdl2-ttf")) - (string-append "--with-libsdl2-mixer-prefix=" - (assoc-ref %build-inputs "sdl2-mixer"))) - #:make-flags '("GUILE_AUTO_COMPILE=0") + '(#:make-flags '("GUILE_AUTO_COMPILE=0") #:phases (modify-phases %standard-phases (add-after 'unpack 'bootstrap @@ -92,7 +83,7 @@ ("pkg-config" ,pkg-config) ("texinfo" ,texinfo))) (inputs - `(("guile" ,guile-2.2) + `(("guile" ,guile-3.0) ("sdl2" ,sdl2) ("sdl2-image" ,sdl2-image) ("sdl2-mixer" ,sdl2-mixer) diff --git a/sdl2/config.scm.in b/sdl2/config.scm.in index 06f5519..c3e0ba6 100644 --- a/sdl2/config.scm.in +++ b/sdl2/config.scm.in @@ -8,7 +8,7 @@ ;; this check at runtime allows a Linux machine to cross-compile ;; guile-sdl2 for a Windows target. (define %windows? (string-prefix? "Windows" (utsname:sysname (uname)))) -(define %libsdl2 (if %windows? "SDL2" "@LIBSDL2@")) -(define %libsdl2-image (if %windows? "SDL2_image" "@LIBSDL2_IMAGE@")) -(define %libsdl2-ttf (if %windows? "SDL2_ttf" "@LIBSDL2_TTF@")) -(define %libsdl2-mixer (if %windows? "SDL2_mixer" "@LIBSDL2_MIXER@")) +(define %libsdl2 (if %windows? "SDL2" "@SDL2_LIBDIR@/libSDL2")) +(define %libsdl2-image (if %windows? "SDL2_image" "@SDL2_IMAGE_LIBDIR@/libSDL2_image")) +(define %libsdl2-ttf (if %windows? "SDL2_ttf" "@SDL2_TTF_LIBDIR@/libSDL2_ttf")) +(define %libsdl2-mixer (if %windows? "SDL2_mixer" "@SDL2_MIXER_LIBDIR/libSDL2_mixer@")) -- cgit v1.2.3