From 7d0f4f2b5baf59b76eb0a1d910dc8fa2aa96b93b Mon Sep 17 00:00:00 2001 From: jsancho Date: Wed, 11 Jan 2012 20:44:29 +0000 Subject: [PATCH] Experimenting with autotools --- Makefile | 4 +++- configure | 46 +++++++++++++++++++++++++++++----------------- configure.ac | 17 +++++++++-------- src/Makefile.am | 8 +++++++- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index c367279..84eb1c5 100644 --- a/Makefile +++ b/Makefile @@ -153,6 +153,8 @@ ECHO_T = EGREP = /bin/grep -E EXEEXT = FGREP = /bin/grep -F +FTGL_LIBS = -lftgl +GL_LIBS = -lGL -lGLU GREP = /bin/grep GUILE = /usr/bin/guile GUILE_CFLAGS = -pthread -I/usr/include/guile/2.0 @@ -192,7 +194,7 @@ PACKAGE_URL = PACKAGE_VERSION = 0.5 PATH_SEPARATOR = : RANLIB = ranlib -SDL_LIBS = -lSDL_mixer -lSDL_gfx -lSDL_image -lSDL +SDL_LIBS = -lSDL -lSDL_image -lSDL_gfx -lSDL_mixer SED = /bin/sed SET_MAKE = SHELL = /bin/bash diff --git a/configure b/configure index 1334f49..4d0e906 100755 --- a/configure +++ b/configure @@ -616,6 +616,8 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +FTGL_LIBS +GL_LIBS SDL_LIBS GUILE_LDFLAGS GUILE_CFLAGS @@ -12328,8 +12330,9 @@ $as_echo "$GUILE_LDFLAGS" >&6; } + for lib in SDL SDL_image SDL_gfx SDL_mixer ; do - as_ac_Lib=`$as_echo "ac_cv_lib_${lib}''_main" | $as_tr_sh` + as_ac_Lib=`$as_echo "ac_cv_lib_${lib}''_main" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -l${lib}" >&5 $as_echo_n "checking for main in -l${lib}... " >&6; } if eval \${$as_ac_Lib+:} false; then : @@ -12362,15 +12365,16 @@ eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : - SDL_LIBS="-l${lib} $SDL_LIBS" + SDL_LIBS="${SDL_LIBS} -l${lib}" else as_fn_error $? "*** ${lib} library not found!" "$LINENO" 5 fi -done + done + for lib in GL GLU ; do - as_ac_Lib=`$as_echo "ac_cv_lib_${lib}''_main" | $as_tr_sh` + as_ac_Lib=`$as_echo "ac_cv_lib_${lib}''_main" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -l${lib}" >&5 $as_echo_n "checking for main in -l${lib}... " >&6; } if eval \${$as_ac_Lib+:} false; then : @@ -12403,19 +12407,23 @@ eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : - GL_LIBS="-l${lib} $GL_LIBS" + GL_LIBS="${GL_LIBS} -l${lib}" else as_fn_error $? "*** ${lib} library not found!" "$LINENO" 5 fi -done -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lftgl" >&5 -$as_echo_n "checking for main in -lftgl... " >&6; } -if ${ac_cv_lib_ftgl_main+:} false; then : + done + + +for lib in ftgl ; do + as_ac_Lib=`$as_echo "ac_cv_lib_${lib}''_main" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -l${lib}" >&5 +$as_echo_n "checking for main in -l${lib}... " >&6; } +if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lftgl $LIBS" +LIBS="-l${lib} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -12429,22 +12437,26 @@ return main (); } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ftgl_main=yes + eval "$as_ac_Lib=yes" else - ac_cv_lib_ftgl_main=no + eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ftgl_main" >&5 -$as_echo "$ac_cv_lib_ftgl_main" >&6; } -if test "x$ac_cv_lib_ftgl_main" = xyes; then : - FTGL_LIBS="-lftgl $FTGL_LIBS" +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + FTGL_LIBS="${FTGL_LIBS} -l${lib}" else - as_fn_error $? "*** FTGL library not found!" "$LINENO" 5 + as_fn_error $? "*** ${lib} library not found!" "$LINENO" 5 fi + done + + diff --git a/configure.ac b/configure.ac index 5fe8860..cf0bed8 100644 --- a/configure.ac +++ b/configure.ac @@ -5,14 +5,15 @@ AC_PROG_CC AC_PROG_LIBTOOL GUILE_FLAGS -for lib in SDL SDL_image SDL_gfx SDL_mixer ; do - AC_CHECK_LIB(${lib}, main, [SDL_LIBS="-l${lib} $SDL_LIBS"], AC_MSG_ERROR([*** ${lib} library not found!])) -done -AC_SUBST(SDL_LIBS) -for lib in GL GLU ; do - AC_CHECK_LIB(${lib}, main, [GL_LIBS="-l${lib} $GL_LIBS"], AC_MSG_ERROR([*** ${lib} library not found!])) -done -AC_CHECK_LIB(ftgl, main, [FTGL_LIBS="-lftgl $FTGL_LIBS"], AC_MSG_ERROR([*** FTGL library not found!])) +AC_DEFUN([GACELA_DEPS], + for lib in $1 ; do + AC_CHECK_LIB(${lib}, main, [$2="${$2} -l${lib}"], AC_MSG_ERROR([*** ${lib} library not found!])) + done + [AC_SUBST([$2])] +) +GACELA_DEPS(SDL SDL_image SDL_gfx SDL_mixer, SDL_LIBS) +GACELA_DEPS(GL GLU, GL_LIBS) +GACELA_DEPS(ftgl, FTGL_LIBS) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/sdl.c]) diff --git a/src/Makefile.am b/src/Makefile.am index c795f39..4d253b9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,10 @@ -lib_LTLIBRARIES = libguile-gacela-sdl.la +lib_LTLIBRARIES = libguile-gacela-sdl.la libguile-gacela-gl.la libguile-gacela-ftgl.la libguile_gacela_sdl_la_SOURCES = sdl.c libguile_gacela_sdl_la_LIBADD = $(SDL_LIBS) libguile_gacela_sdl_la_CFLAGS = $(GUILE_CFLAGS) +libguile_gacela_gl_la_SOURCES = gl.c +libguile_gacela_gl_la_LIBADD = $(GL_LIBS) +libguile_gacela_gl_la_CFLAGS = $(GUILE_CFLAGS) +libguile_gacela_ftgl_la_SOURCES = ftgl.c +libguile_gacela_ftgl_la_LIBADD = $(FTGL_LIBS) +libguile_gacela_ftgl_la_CFLAGS = $(GUILE_CFLAGS) -I/usr/include/freetype2 -- 2.39.5