File: pngdriver.m4

package info (click to toggle)
emboss 6.6.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 571,584 kB
  • sloc: ansic: 460,579; java: 29,383; perl: 13,573; sh: 12,753; makefile: 3,294; csh: 706; asm: 351; xml: 239; pascal: 237; modula3: 8
file content (145 lines) | stat: -rw-r--r-- 3,338 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
dnl @synopsis CHECK_PNGDRIVER()
dnl
dnl This macro searches for an installed png/gd/zlib library. If nothing
dnl was specified when calling configure, it searches first in /usr/local
dnl and then in /usr. If the --with-pngdriver=DIR is specified, it will try
dnl to find it in DIR/include/zlib.h and DIR/lib/libz.a. If --without-pngdriver
dnl is specified, the library is not searched at all.
dnl
dnl It defines the symbol PLD_png if the librarys are found. You should
dnl use autoheader to include a definition for this symbol in a config.h
dnl file.
dnl
dnl Sources files should then use something like
dnl
dnl   #ifdef PLD_png
dnl   #include <zlib.h>
dnl   #endif /* PLD_png */
dnl
dnl @author Ian Longden <il@sanger.ac.uk>
dnl Modified: Alan Bleasby. Corrected library order
dnl

AC_DEFUN([CHECK_PNGDRIVER],
#
# Handle user hints
#
[AC_MSG_CHECKING([if png driver is wanted])
AC_ARG_WITH([pngdriver],
    [AS_HELP_STRING([--with-pngdriver=@<:@DIR@:>@],
        [root directory path of png/gd/zlib installation (defaults to /usr)])],
[if test "$withval" != no ; then
  AC_MSG_RESULT([yes])
  ALT_HOME="$withval"
else
  AC_MSG_RESULT([no])
fi], [
AC_MSG_RESULT([yes])
ALT_HOME=/usr
])


#
# Locate png/gd/zlib, if wanted
#
if test -d "${ALT_HOME}"
then

#
# Keep a copy if it fails
#
	ALT_LDFLAGS="$LDFLAGS"
	ALT_CPPFLAGS="$CPPFLAGS"

#
# Set 
#
        LDFLAGS="${LDFLAGS} -L${ALT_HOME}/lib"
        CPPFLAGS="$CPPFLAGS -I$ALT_HOME/include"

	  ICCHECK=0
	  case $host_os in
          solaris*)
	        AC_CHECK_LIB(iconv, libiconv_close, ICCHECK=1, ICCHECK=0, -L${ALT_HOME}/lib -liconv)
	           if test $ICCHECK = "1" ; then
	               LDFLAGS="${LDFLAGS} -L${ALT_HOME}/lib -liconv"
	           fi
	        LDFLAGS="$LDFLAGS -R$ALT_HOME/lib"
                ;;
          esac





#
# Check for zlib in ALT_HOME
#
        AC_CHECK_LIB(z, inflateEnd, CHECK=1, CHECK=0, -L${ALT_HOME}/lib -lz)
#

#
# Check for png
#
	if test $CHECK = "1" ; then
	  AC_CHECK_LIB(png, png_destroy_read_struct, CHECK=1, CHECK=0 , -L${ALT_HOME}/lib -lz)
	fi
	



#
# Check for gd
#
	if test $CHECK = "1"; then
	  AC_CHECK_LIB(gd, gdImageCreateFromPng, CHECK=1, CHECK=0 , -L${ALT_HOME}/lib -lgd -lpng -lz -lm)
          if test $CHECK = "0"; then
		echo need to upgrade gd for png driver for plplot
	  fi
	fi
#
# If everything found okay then proceed to include png driver in config.
#
	if test $CHECK = "1" ; then
	  LIBS="$LIBS -lgd -lpng -lz -lm"

	  if test $ICCHECK = "1" ; then
		  LIBS="$LIBS -liconv"
	  fi
        
          case $host_os in
          solaris*)
	      LDFLAGS="$LDFLAGS -R$ALT_HOME/lib"
              ;;
          esac

	  AC_DEFINE([PLD_png], [1], [Define to 1 is PNG support is available])
	  AM_CONDITIONAL(AMPNG, true)
	  echo PNG libraries found
	    if test $ALT_HOME = "/usr" ; then
		  LDFLAGS="$ALT_LDFLAGS"
		  CPPFLAGS="$ALT_CPPFLAGS"
	    fi
	else
#
# If not okay then reset FLAGS.
#
  	  AM_CONDITIONAL(AMPNG, false)
	  LDFLAGS="$ALT_LDFLAGS"
	  CPPFLAGS="$ALT_CPPFLAGS"
	  echo No png driver will be made due to librarys missing/old.
	fi
#       echo PNG STUFF FOLLOWS!!!
#       echo CHECK = $CHECK
#       echo LIBS = $LIBS
#       echo LDFLAGS = $LDFLAGS
#       echo CPPFLAGS = $CPPFLAGS


else
        if test $withval != "no"; then
		echo "Directory $ALT_HOME does not exist"
		exit 0
        fi
fi
])