From 0e513f7ae3e41c69baba66d1b68749860879a3f6 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 1 May 2013 14:47:56 -0700 Subject: [PATCH] configure: add GLUT detection; build vwebp Change-Id: I7f0964db2d04c22ff9ec274e8cd1cbed7379a165 --- configure.ac | 95 ++++++++++++++++++++++++++++++++++++++++++-- examples/Makefile.am | 21 +++++++--- examples/vwebp.c | 5 ++- makefile.unix | 1 + 4 files changed, 111 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index b60a683c..e24f41f1 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,92 @@ if test "$enable_threading" = "yes"; then fi AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}]) +dnl === check for OpenGL/GLUT support === +CLEAR_LIBVARS([GL]) +WITHLIB_OPTION([gl], [GL]) + +LIBCHECK_PROLOGUE([GL]) + +glut_cflags="none" +glut_ldflags="none" +case $host_os in + darwin*) + # Special case for OSX builds. Append these to give the user a chance to + # override with --with-gl* + glut_cflags="$glut_cflags|-framework GLUT -framework OpenGL" + glut_ldflags="$glut_ldflags|-framework GLUT -framework OpenGL" + ;; +esac + +GLUT_SAVED_CPPFLAGS="$CPPFLAGS" +SAVED_IFS="$IFS" +IFS="|" +for flag in $glut_cflags; do + # restore IFS immediately as the autoconf macros may need the default. + IFS="$SAVED_IFS" + unset ac_cv_header_GL_glut_h + unset ac_cv_header_OpenGL_glut_h + + case $flag in + none) ;; + *) CPPFLAGS="$flag $CPPFLAGS";; + esac + AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h], + [glut_headers=yes; + test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS"; + break]) + CPPFLAGS="$GLUT_SAVED_CPPFLAGS" + test "$glut_headers" = "yes" && break +done +IFS="$SAVED_IFS" + +if test "$glut_headers" = "yes"; then + AC_LANG_PUSH([C]) + GLUT_SAVED_LDFLAGS="$LDFLAGS" + SAVED_IFS="$IFS" + IFS="|" + for flag in $glut_ldflags; do + # restore IFS immediately as the autoconf macros may need the default. + IFS="$SAVED_IFS" + unset ac_cv_search_glBegin + + case $flag in + none) ;; + *) LDFLAGS="$flag $LDFLAGS";; + esac + + # find libGL + GL_SAVED_LIBS="$LIBS" + AC_SEARCH_LIBS([glBegin], [GL OpenGL]) + LIBS="$GL_SAVED_LIBS" + + # A direct link to libGL may not be necessary on e.g., linux. + for lib in "" $ac_cv_search_glBegin; do + unset ac_cv_search_glutMainLoop + AC_SEARCH_LIBS([glutMainLoop], [glut], [glut_support=yes], [], [$lib]) + if test "$glut_support" = "yes"; then + GL_LIBS="$LDFLAGS" + if test "$ac_cv_search_glutMainLoop" != "none required"; then + GL_LIBS="$GL_LIBS $ac_cv_search_glutMainLoop" + fi + GL_LIBS="$GL_LIBS $lib" + break + fi + done + LDFLAGS="$GLUT_SAVED_LDFLAGS" + test "$glut_support" = "yes" && break + done + IFS="$SAVED_IFS" + AC_LANG_POP +fi + +LIBCHECK_EPILOGUE([GL]) + +if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then + build_vwebp=yes +fi +AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"]) + dnl === check for PNG support === CLEAR_LIBVARS([PNG]) @@ -305,18 +391,19 @@ libwebpdemux: ${enable_libwebpdemux-no} libwebpmux: ${enable_libwebpmux-no} Tools: -cwebp: yes +cwebp : yes Input format support ==================== JPEG : ${jpeg_support-no} PNG : ${png_support-no} TIFF : ${tiff_support-no} WIC : ${wic_support-no} -dwebp: yes +dwebp : yes Output format support ===================== PNG : ${png_support-no} WIC : ${wic_support-no} -gif2webp: ${build_gif2webp-no} -webpmux: ${enable_libwebpmux-no} +gif2webp : ${build_gif2webp-no} +webpmux : ${enable_libwebpmux-no} +vwebp : ${build_vwebp-no} ]) diff --git a/examples/Makefile.am b/examples/Makefile.am index b09a9798..20e925a1 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,6 +1,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/src bin_PROGRAMS = dwebp cwebp +if BUILD_VWEBP + bin_PROGRAMS += vwebp +endif if WANT_MUX bin_PROGRAMS += webpmux endif @@ -18,12 +21,6 @@ dwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES) dwebp_LDADD = libexampleutil.la $(PNG_LIBS) $(JPEG_LIBS) -if BUILD_LIBWEBPDECODER - dwebp_LDADD += ../src/libwebpdecoder.la -else - dwebp_LDADD += ../src/libwebp.la -endif - cwebp_SOURCES = cwebp.c metadata.c metadata.h stopwatch.h cwebp_SOURCES += jpegdec.c jpegdec.h cwebp_SOURCES += pngdec.c pngdec.h @@ -41,3 +38,15 @@ gif2webp_LDADD += $(GIF_LIBS) webpmux_SOURCES = webpmux.c webpmux_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) webpmux_LDADD = libexampleutil.la ../src/mux/libwebpmux.la ../src/libwebp.la + +vwebp_SOURCES = vwebp.c +vwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(GL_INCLUDES) +vwebp_LDADD = libexampleutil.la ../src/demux/libwebpdemux.la $(GL_LIBS) + +if BUILD_LIBWEBPDECODER + dwebp_LDADD += ../src/libwebpdecoder.la + vwebp_LDADD += ../src/libwebpdecoder.la +else + dwebp_LDADD += ../src/libwebp.la + vwebp_LDADD += ../src/libwebp.la +endif diff --git a/examples/vwebp.c b/examples/vwebp.c index 8fe49acd..e231cde5 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -14,12 +14,15 @@ // gcc -o vwebp vwebp.c -lwebp -lwebpmux -framework GLUT -framework OpenGL // // Author: Skal (pascal.massimino@gmail.com) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include -#ifdef __APPLE__ +#if defined(HAVE_GLUT_GLUT_H) #include #else #include diff --git a/makefile.unix b/makefile.unix index 0f8cf311..6c787f54 100644 --- a/makefile.unix +++ b/makefile.unix @@ -24,6 +24,7 @@ ifeq ($(strip $(shell uname)), Darwin) # cf., src/enc/yuv.[hc] # Failure observed with: gcc 4.2.1 and 4.0.1. EXTRA_FLAGS += -fno-common + EXTRA_FLAGS += -DHAVE_GLUT_GLUT_H EXTRA_FLAGS += -I/opt/local/include EXTRA_LIBS += -L/opt/local/lib GL_LIBS = -framework GLUT -framework OpenGL