0
|
1 dnl @synopsis CHECK_PNGDRIVER()
|
|
2 dnl
|
|
3 dnl This macro searches for an installed png/gd/zlib library. If nothing
|
|
4 dnl was specified when calling configure, it searches first in /usr/local
|
|
5 dnl and then in /usr. If the --with-pngdriver=DIR is specified, it will try
|
|
6 dnl to find it in DIR/include/zlib.h and DIR/lib/libz.a. If --without-pngdriver
|
|
7 dnl is specified, the library is not searched at all.
|
|
8 dnl
|
|
9 dnl It defines the symbol PLD_png if the librarys are found. You should
|
|
10 dnl use autoheader to include a definition for this symbol in a config.h
|
|
11 dnl file.
|
|
12 dnl
|
|
13 dnl Sources files should then use something like
|
|
14 dnl
|
|
15 dnl #ifdef PLD_png
|
|
16 dnl #include <zlib.h>
|
|
17 dnl #endif /* PLD_png */
|
|
18 dnl
|
|
19 dnl @author Ian Longden <il@sanger.ac.uk>
|
|
20 dnl Modified: Alan Bleasby. Corrected library order
|
|
21 dnl
|
|
22
|
|
23 AC_DEFUN([CHECK_PNGDRIVER],
|
|
24 #
|
|
25 # Handle user hints
|
|
26 #
|
|
27 [AC_MSG_CHECKING([if png driver is wanted])
|
|
28 AC_ARG_WITH([pngdriver],
|
|
29 [AS_HELP_STRING([--with-pngdriver=@<:@DIR@:>@],
|
|
30 [root directory path of png/gd/zlib installation (defaults to /usr)])],
|
|
31 [if test "$withval" != no ; then
|
|
32 AC_MSG_RESULT([yes])
|
|
33 ALT_HOME="$withval"
|
|
34 else
|
|
35 AC_MSG_RESULT([no])
|
|
36 fi], [
|
|
37 AC_MSG_RESULT([yes])
|
|
38 ALT_HOME=/usr
|
|
39 ])
|
|
40
|
|
41
|
|
42 #
|
|
43 # Locate png/gd/zlib, if wanted
|
|
44 #
|
|
45 if test -d "${ALT_HOME}"
|
|
46 then
|
|
47
|
|
48 #
|
|
49 # Keep a copy if it fails
|
|
50 #
|
|
51 ALT_LDFLAGS="$LDFLAGS"
|
|
52 ALT_CPPFLAGS="$CPPFLAGS"
|
|
53
|
|
54 #
|
|
55 # Set
|
|
56 #
|
|
57 LDFLAGS="${LDFLAGS} -L${ALT_HOME}/lib"
|
|
58 CPPFLAGS="$CPPFLAGS -I$ALT_HOME/include"
|
|
59
|
|
60 ICCHECK=0
|
|
61 case $host_os in
|
|
62 solaris*)
|
|
63 AC_CHECK_LIB(iconv, libiconv_close, ICCHECK=1, ICCHECK=0, -L${ALT_HOME}/lib -liconv)
|
|
64 if test $ICCHECK = "1" ; then
|
|
65 LDFLAGS="${LDFLAGS} -L${ALT_HOME}/lib -liconv"
|
|
66 fi
|
|
67 LDFLAGS="$LDFLAGS -R$ALT_HOME/lib"
|
|
68 ;;
|
|
69 esac
|
|
70
|
|
71
|
|
72
|
|
73
|
|
74
|
|
75 #
|
|
76 # Check for zlib in ALT_HOME
|
|
77 #
|
|
78 AC_CHECK_LIB(z, inflateEnd, CHECK=1, CHECK=0, -L${ALT_HOME}/lib -lz)
|
|
79 #
|
|
80
|
|
81 #
|
|
82 # Check for png
|
|
83 #
|
|
84 if test $CHECK = "1" ; then
|
|
85 AC_CHECK_LIB(png, png_destroy_read_struct, CHECK=1, CHECK=0 , -L${ALT_HOME}/lib -lz)
|
|
86 fi
|
|
87
|
|
88
|
|
89
|
|
90
|
|
91 #
|
|
92 # Check for gd
|
|
93 #
|
|
94 if test $CHECK = "1"; then
|
|
95 AC_CHECK_LIB(gd, gdImageCreateFromPng, CHECK=1, CHECK=0 , -L${ALT_HOME}/lib -lgd -lpng -lz -lm)
|
|
96 if test $CHECK = "0"; then
|
|
97 echo need to upgrade gd for png driver for plplot
|
|
98 fi
|
|
99 fi
|
|
100 #
|
|
101 # If everything found okay then proceed to include png driver in config.
|
|
102 #
|
|
103 if test $CHECK = "1" ; then
|
|
104 LIBS="$LIBS -lgd -lpng -lz -lm"
|
|
105
|
|
106 if test $ICCHECK = "1" ; then
|
|
107 LIBS="$LIBS -liconv"
|
|
108 fi
|
|
109
|
|
110 case $host_os in
|
|
111 solaris*)
|
|
112 LDFLAGS="$LDFLAGS -R$ALT_HOME/lib"
|
|
113 ;;
|
|
114 esac
|
|
115
|
|
116 AC_DEFINE([PLD_png], [1], [Define to 1 is PNG support is available])
|
|
117 AM_CONDITIONAL(AMPNG, true)
|
|
118 echo PNG libraries found
|
|
119 if test $ALT_HOME = "/usr" ; then
|
|
120 LDFLAGS="$ALT_LDFLAGS"
|
|
121 CPPFLAGS="$ALT_CPPFLAGS"
|
|
122 fi
|
|
123 else
|
|
124 #
|
|
125 # If not okay then reset FLAGS.
|
|
126 #
|
|
127 AM_CONDITIONAL(AMPNG, false)
|
|
128 LDFLAGS="$ALT_LDFLAGS"
|
|
129 CPPFLAGS="$ALT_CPPFLAGS"
|
|
130 echo No png driver will be made due to librarys missing/old.
|
|
131 fi
|
|
132 # echo PNG STUFF FOLLOWS!!!
|
|
133 # echo CHECK = $CHECK
|
|
134 # echo LIBS = $LIBS
|
|
135 # echo LDFLAGS = $LDFLAGS
|
|
136 # echo CPPFLAGS = $CPPFLAGS
|
|
137
|
|
138
|
|
139 else
|
|
140 if test $withval != "no"; then
|
|
141 echo "Directory $ALT_HOME does not exist"
|
|
142 exit 0
|
|
143 fi
|
|
144 fi
|
|
145 ])
|