]> git.draconx.ca Git - liblbx.git/commitdiff
lbximg: Make libpng a soft dependency.
authorNick Bowler <nbowler@draconx.ca>
Fri, 14 Jun 2013 22:15:25 +0000 (18:15 -0400)
committerNick Bowler <nbowler@draconx.ca>
Fri, 14 Jun 2013 22:15:25 +0000 (18:15 -0400)
Now that we have Netpbm output formats which do not depend on
any external libraries, we can make it possible to build lbximg
without libpng.  Adjust the build system so that lbximg is built
unconditionally and PNG output can be selectively disabled.

Makefile.am
configure.ac
src/lbximg.c

index 48398a646e64c202bfb5ad3d471baccdf67ea7f4..966ad2ea7d587517c209867b2b54c078bb8e4c23 100644 (file)
@@ -25,10 +25,7 @@ lib_LTLIBRARIES = liblbx.la
 liblbx_la_SOURCES = src/lbx.c src/fops.c src/image.c src/pack.c src/error.c
 liblbx_la_LDFLAGS = -export-symbols-regex '^lbx_'
 
 liblbx_la_SOURCES = src/lbx.c src/fops.c src/image.c src/pack.c src/error.c
 liblbx_la_LDFLAGS = -export-symbols-regex '^lbx_'
 
-bin_PROGRAMS = lbxtool
-if BUILD_LBXIMG
-bin_PROGRAMS += lbximg
-endif
+bin_PROGRAMS = lbxtool lbximg
 if BUILD_LBXGUI
 bin_PROGRAMS += lbxgui
 endif
 if BUILD_LBXGUI
 bin_PROGRAMS += lbxgui
 endif
@@ -37,10 +34,14 @@ lbxtool_SOURCES = src/lbxtool.c src/tools.c
 lbxtool_LDADD = liblbx.la libgnu.la
 $(lbxtool_OBJECTS): $(gnulib_headers)
 
 lbxtool_LDADD = liblbx.la libgnu.la
 $(lbxtool_OBJECTS): $(gnulib_headers)
 
-lbximg_SOURCES = src/lbximg.c src/tools.c src/png.c src/pnm.c
+lbximg_SOURCES = src/lbximg.c src/tools.c src/pnm.c
 lbximg_LDADD = liblbx.la libgnu.la $(LIBPNG_LIBS)
 $(lbximg_OBJECTS): $(gnulib_headers)
 
 lbximg_LDADD = liblbx.la libgnu.la $(LIBPNG_LIBS)
 $(lbximg_OBJECTS): $(gnulib_headers)
 
+if HAVE_LIBPNG
+lbximg_SOURCES += src/png.c
+endif
+
 nodist_lbxgui_SOURCES = src/gui/lbxgui.glade.c
 lbxgui_SOURCES = src/gui/lbxgui.c src/gui/render.c src/gui/render.h \
        src/gui/bg.xbm
 nodist_lbxgui_SOURCES = src/gui/lbxgui.glade.c
 lbxgui_SOURCES = src/gui/lbxgui.c src/gui/render.c src/gui/render.h \
        src/gui/bg.xbm
index 9ba3d42a008c495b04bbb9ea7667b609a0fb3aeb..224469a4817b98dfe99b40a5926f3cd693ac442d 100644 (file)
@@ -1,10 +1,10 @@
-dnl Copyright (C) 2009 Nick Bowler
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved.  This file is offered as-is,
-dnl without any warranty.
+dnl Copyright © 2009, 2013 Nick Bowler
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
 
 
-AC_PREREQ([2.62])
+AC_PREREQ([2.68])
 AC_INIT([liblbx], [0.1], [toom-devel@lists.sourceforge.net])
 AC_CONFIG_SRCDIR([src/lbx.c])
 AC_CONFIG_HEADER([config.h])
 AC_INIT([liblbx], [0.1], [toom-devel@lists.sourceforge.net])
 AC_CONFIG_SRCDIR([src/lbx.c])
 AC_CONFIG_HEADER([config.h])
@@ -23,22 +23,20 @@ gl_INIT
 
 m4_include([lib/gnulib.mk])
 
 
 m4_include([lib/gnulib.mk])
 
-PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([libpng],
+       [AS_HELP_STRING([--with-libpng],
+               [build support for PNG output using libpng. [default=auto]])],
+       [with_libpng=$withval],
+       [with_libpng=auto])
 
 
-AC_ARG_ENABLE([lbximg],
-       [AS_HELP_STRING([--enable-lbximg],
-               [build the lbximg tool (requires libpng) [default=auto]])],
-       [enable_lbximg=$enableval],
-       [enable_lbximg=auto])
+AS_CASE([$with_libpng],
+       [no], [have_libpng=false],
+       [yes], [DX_CHECK_LIBPNG([1.5], [have_libpng=true])],
+       [DX_CHECK_LIBPNG([1.5], [have_libpng=true], [have_libpng=false])])
 
 
-have_libpng=no
-if test x"$enable_lbximg" = x"auto"; then
-DX_CHECK_LIBPNG([1.5], [have_libpng=yes], [have_libpng=no])
-fi
-if test x"$enable_lbximg" = x"yes"; then
-DX_CHECK_LIBPNG([1.5], [have_libpng=yes])
-fi
-AM_CONDITIONAL([BUILD_LBXIMG], [test x"$have_libpng" = x"yes"])
+AM_CONDITIONAL([HAVE_LIBPNG], [$have_libpng])
+AS_IF([$have_libpng], [AC_DEFINE([HAVE_LIBPNG], [1],
+       [Define to 1 if libpng support is available])])
 
 AC_ARG_ENABLE([lbxgui],
        [AS_HELP_STRING([--enable-lbxgui],
 
 AC_ARG_ENABLE([lbxgui],
        [AS_HELP_STRING([--enable-lbxgui],
@@ -46,14 +44,12 @@ AC_ARG_ENABLE([lbxgui],
        [enable_lbxgui=$enableval],
        [enable_lbxgui=auto])
 
        [enable_lbxgui=$enableval],
        [enable_lbxgui=auto])
 
-have_gtk=no
-if test x"$enable_lbxgui" = x"auto"; then
-DX_CHECK_GTK2([2.16], [have_gtk=yes], [have_gtk=no])
-fi
-if test x"$enable_lbxgui" = x"yes"; then
-DX_CHECK_GTK2([2.16], [have_gtk=yes])
-fi
-AM_CONDITIONAL([BUILD_LBXGUI], [test x"$have_gtk" = x"yes"])
+AS_CASE([$enable_lbxgui],
+       [no], [have_gtk=false],
+       [yes], [DX_CHECK_GTK2([2.16], [have_gtk=true])],
+       [DX_CHECK_GTK2([2.16], [have_gtk=true], [have_gtk=false])])
+
+AM_CONDITIONAL([BUILD_LBXGUI], [$have_gtk])
 
 AC_CONFIG_FILES([
        Makefile
 
 AC_CONFIG_FILES([
        Makefile
index ada16929a32cf400797b089e849c4bdb371eabf0..b2c97f23ea5cd3e74ec7433357661177885c9d37 100644 (file)
@@ -62,7 +62,9 @@ static const struct img_format {
        char name[4];
        bool enabled;
 } formats[] = {
        char name[4];
        bool enabled;
 } formats[] = {
+#if HAVE_LIBPNG
        { img_output_png, "png", 1 },
        { img_output_png, "png", 1 },
+#endif
        { img_output_pam, "pam", 1 },
        { img_output_ppm, "ppm", 1 },
        { img_output_pbm, "pbm", 1 },
        { img_output_pam, "pam", 1 },
        { img_output_ppm, "ppm", 1 },
        { img_output_pbm, "pbm", 1 },