summaryrefslogtreecommitdiff
path: root/ext/gd/config.m4
blob: a3e6585b21b885ff7e1618a6200fea2151f96826 (plain)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
AC_MSG_CHECKING(whether to include GD support)
AC_ARG_WITH(gd,
[  --without-gd            Disable GD support.
  --with-gd[=DIR]         Include GD support (DIR is GD's install dir).
                          Set DIR to "shared" to build as a dl, or 
                          "shared,DIR" to build as a dl and still specify DIR.],
[
  case $withval in
    shared)
      shared=yes
      withval=yes
      ;;
    shared,*)
      shared=yes
      withval=`echo $withval | sed -e 's/^shared,//'`
      ;;
    *)
      shared=no
      ;;
  esac

  case "$withval" in
    no)
      AC_MSG_RESULT(no) ;;
    yes)
      AC_DEFINE(HAVE_LIBGD)
      if test "$shared" = "yes"; then
        AC_MSG_RESULT(yes (shared))
        GD_LIBS="-lgd"
      else
        AC_MSG_RESULT(yes (static))
        AC_ADD_LIBRARY(gd)
      fi
      AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
      ac_cv_lib_gd_gdImageLine=yes
      ;;
    *)
dnl A whole whack of possible places where this might be
      test -f $withval/include/gd1.3/gd.h && GD_INCLUDE="$withval/include/gd1.3"
      test -f $withval/include/gd/gd.h && GD_INCLUDE="$withval/include/gd"
      test -f $withval/include/gd.h && GD_INCLUDE="$withval/include"
      test -f $withval/gd1.3/gd.h && GD_INCLUDE="$withval/gd1.3"
      test -f $withval/gd/gd.h && GD_INCLUDE="$withval/gd"
      test -f $withval/gd.h && GD_INCLUDE="$withval"

      test -f $withval/lib/libgd.so && GD_LIB="$withval/lib"
      test -f $withval/lib/gd/libgd.so && GD_LIB="$withval/lib/gd"
      test -f $withval/lib/gd1.3/libgd.so && GD_LIB="$withval/lib/gd1.3"
      test -f $withval/libgd.so && GD_LIB="$withval"
      test -f $withval/gd/libgd.so && GD_LIB="$withval/gd"
      test -f $withval/gd1.3/libgd.so && GD_LIB="$withval/gd1.3"

      test -f $withval/lib/libgd.a && GD_LIB="$withval/lib"
      test -f $withval/lib/gd/libgd.a && GD_LIB="$withval/lib/gd"
      test -f $withval/lib/gd1.3/libgd.a && GD_LIB="$withval/lib/gd1.3"
      test -f $withval/libgd.a && GD_LIB="$withval"
      test -f $withval/gd/libgd.a && GD_LIB="$withval/gd"
      test -f $withval/gd1.3/libgd.a && GD_LIB="$withval/gd1.3"

      if test -n "$GD_INCLUDE" && test -n "$GD_LIB" ; then
        AC_DEFINE(HAVE_LIBGD)
        if test "$shared" != "yes"; then
          AC_MSG_RESULT(yes (static))
          AC_ADD_LIBRARY_WITH_PATH(gd, $GD_LIB)
        else
          AC_MSG_RESULT(yes (shared))
          GD_LIBS="-lgd"
          GD_LFLAGS="-L$GD_LIB"
        fi
        AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
	ac_cv_lib_gd_gdImageLine=yes
      else
        AC_MSG_ERROR([Unable to find libgd.(a|so) anywhere under $withval])
      fi ;;
  esac
],[
  AC_CHECK_LIB(gd, gdImageLine)
  AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
])
if test "$ac_cv_lib_gd_gdImageLine" = "yes"; then
  CHECK_TTF="yes"
  AC_ARG_WITH(ttf,
  [  --with-ttf[=DIR]        Include Freetype support],[
    if test $withval = "no" ; then
      CHECK_TTF=""
    else
      CHECK_TTF="$withval"
    fi
  ])

  AC_MSG_CHECKING(whether to include ttf support)
  if test -n "$CHECK_TTF" ; then
    for i in /usr /usr/local "$CHECK_TTF" ; do
      if test -f "$i/include/truetype.h" ; then
        FREETYPE_DIR="$i"
      fi
      if test -f "$i/include/freetype.h" ; then
        TTF_DIR="$i"
      fi
    done
    if test -n "$FREETYPE_DIR" ; then
      AC_DEFINE(HAVE_LIBFREETYPE)
      if test "$shared" != "yes"; then
        AC_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE_DIR/lib)
        AC_ADD_INCLUDE($FREETYPE_DIR/include)
      else 
        GD_LIBS="$GD_LIBS -lfreetype"
        GD_LFLAGS="$GD_LFLAGS -L$FREETYPE_DIR/lib"
        GD_INCLUDES="$GD_INCLUDES -I$FREETYPE_DIR/include"
      fi
      AC_MSG_RESULT(yes)
    else
      if test -n "$TTF_DIR" ; then
        AC_DEFINE(HAVE_LIBTTF)
        if test "$shared" != "yes"; then
          AC_ADD_LIBRARY_WITH_PATH(ttf, $TTF_DIR/lib)
          AC_ADD_INCLUDE($TTF_DIR/include)
        else
          GD_LIBS="$GD_LIBS -lttf"
          GD_LFLAGS="$GD_LFLAGS -L$TTF_DIR/lib"
          GD_INCLUDES="$GD_INCLUDES -I$TTF_DIR/include"
        fi
        AC_MSG_RESULT(yes)
      else
        AC_MSG_RESULT(no)
      fi
    fi
  else
    AC_MSG_RESULT(no)
  fi
  
  if test -f /usr/pkg/include/gd/gd.h -a -z "$GD_INCLUDE" ; then
    GD_INCLUDE="/usr/pkg/include/gd"
  fi

  AC_MSG_CHECKING(whether to enable 4bit antialias hack with FreeType2)
  AC_ARG_ENABLE(freetype-4bit-antialias-hack,
  [  --enable-freetype-4bit-antialias-hack  For the crazy with FreeType2.],[
  if test "$enableval" = "yes" ; then
    AC_DEFINE(FREETYPE_4BIT_ANTIALIAS_HACK, 1)
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
  ],[
    AC_MSG_RESULT(no)
  ])
  
  PHP_EXTENSION(gd, $shared)
  if test "$shared" != "yes"; then
    AC_ADD_INCLUDE($GD_INCLUDE)
    GD_STATIC="libphpext_gd.a"
  else 
    if test -n "$GD_INCLUDE"; then
      GD_INCLUDES="$GD_INCLUDES -I$GD_INCLUDE"
    fi
    GD_SHARED="gd.la"
  fi
fi

AC_SUBST(GD_LFLAGS)
AC_SUBST(GD_LIBS)
AC_SUBST(GD_INCLUDES)
AC_SUBST(GD_STATIC)
AC_SUBST(GD_SHARED)