-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
288 lines (259 loc) · 8.2 KB
/
configure.ac
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# Process this file with autoconf to produce a configure script.
AC_INIT(Cairo, 1.3, [email protected])
AC_CONFIG_SRCDIR([src/cairogd.c])
AC_CONFIG_HEADER([src/cconfig.h])
# find R home and set CC/CFLAGS
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
RBIN="${R_HOME}/bin/R"
CC=`"${RBIN}" CMD config CC`;
CFLAGS=`"${RBIN}" CMD config CFLAGS`
CPP="${CC} -E"
AC_SUBST(R_HOME)
# platform check
#AC_CANONICAL_HOST
# Checks for programs.
AC_LANG(C)
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([string.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
#AC_HEADER_TIME
# Checks for library functions.
#AC_FUNC_MALLOC
#AC_TYPE_SIGNAL
AC_PATH_PROG([PKGCONF],[pkg-config],[],[$PATH:/usr/local/bin:ext/bin:ext:/sw/bin:/opt/bin])
have_cairo=no
if test "xx$CAIRO_LIBS" == "xx"; then
if test "xx$PKGCONF" != "xx"; then
AC_MSG_CHECKING([whether pkg-config knows about cairo])
if "${PKGCONF}" --exists cairo; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for configurable backends])
modlist="cairo"
for module in cairo-ft cairo-pdf cairo-png cairo-ps cairo-svn cairo-xlib cairo-xlib-xrender cairo-win32; do
if "${PKGCONF}" --exists ${module}; then
modlist="${modlist} ${module}"
fi
done
AC_MSG_RESULT(${modlist})
CAIRO_CFLAGS=`"${PKGCONF}" --cflags ${modlist}`
CAIRO_LIBS=`"${PKGCONF}" --libs ${modlist}`
AC_MSG_CHECKING([whether --static is needed])
saveLIBS="$LIBS"
LIBS="$saveLIBS ${CAIRO_LIBS}"
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY(cairo_reset_clip)],
[AC_MSG_RESULT([no])],
[CAIRO_LIBS=`"${PKGCONF}" --libs --static ${modlist}`
LIBS="$saveLIBS ${CAIRO_LIBS}"
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY(cairo_reset_clip)],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([neither works, abandoning pkg-config])
CAIRO_LIBS=''
])
])
LIBS="$saveLIBS"
else
AC_MSG_RESULT([no])
fi
fi
fi
if test -z "${CAIRO_LIBS}"; then
AC_MSG_NOTICE([CAIRO_LIBS is unset, attempting to guess it.])
cpre=''
for pre in /usr /usr/local /usr/X11 /usr/X11R6 /opt /sw; do
if test -e "${pre}/include/cairo/cairo.h"; then
cpre=${pre}; break
fi
done
if test -n "${cpre}"; then
CAIRO_CFLAGS="-I${cpre}/include/cairo"
if test "${cpre}" = /usr; then
CAIRO_LIBS="-lcairo"
else
CAIRO_LIBS="-L${cpre}/lib -lcairo"
fi
fi
fi
AC_MSG_NOTICE([CAIRO_CFLAGS=${CAIRO_CFLAGS}])
# Check for Rconn patch
AC_MSG_CHECKING([if R was compiled with the RConn patch])
if test -f "${R_HOME}/include/R_ext/RConn.h"; then
AC_MSG_RESULT([yes])
HAVE_RCONN_H="-DHAVE_RCONN_H"
else
AC_MSG_RESULT([no])
HAVE_RCONN_H=""
fi
CPPFLAGS="$CPPFLAGS ${CAIRO_CFLAGS} ${HAVE_RCONN_H}"
AC_CHECK_HEADER(cairo.h,,AC_MSG_ERROR([Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly.]))
AC_MSG_CHECKING([for PNG support in Cairo])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include "cairo.h"
int main(void) {
#ifndef CAIRO_HAS_PNG_FUNCTIONS
#error no PNG support
#endif
return 0;
}])],[AC_MSG_RESULT([yes])] ,[AC_MSG_RESULT([no])
AC_MSG_ERROR([Cairo library has no PNG support.])])
uses_ats=no
AC_MSG_CHECKING([for ATS font support in Cairo])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include "cairo.h"
int main(void) {
#ifndef CAIRO_HAS_ATSUI_FONT
#error no PNG support
#endif
return 0;
}])],[AC_MSG_RESULT([yes])
uses_ats=yes],[AC_MSG_RESULT([no])])
if test "xx${CAIRO_LIBS}" == "xx"; then
if test $uses_ats == "yes"; then
CAIRO_LIBS="-lcairo -lpng -lz -framework ApplicationServices"
else
CAIRO_LIBs="-lcairo -lpng -lz"
fi
fi
AC_MSG_NOTICE([CAIRO_LIBS=${CAIRO_LIBS}])
LIBS="$LIBS ${CAIRO_LIBS}"
#AC_CHECK_LIB(cairo, cairo_create,,
#[AC_MSG_ERROR([Cannot link to cairo library. Please check config.log for details and set CAIRO_LIBS accordingly.])])
AC_SEARCH_LIBS(deflate, z)
AC_MSG_CHECKING([whether Cairo programs can be compiled])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <cairo.h>
int main(void) {
cairo_surface_t *cs = 0;
cairo_t *cr;
cr = cairo_create(cs);
return 0;
}
])],[AC_MSG_RESULT(yes)],[AC_MSG_ERROR([Cannot compile a simple Cairo program. See config.log for details.])])
dnl AC_CHECK_LIB(cairo, cairo_image_surface_get_format)
dnl if test "$ac_cv_lib_cairo_cairo_image_surface_get_format" != "yes"; then
dnl AC_MSG_ERROR([Cairo is too old: >= 1.2 is needed.])
dnl fi
AC_CHECK_DECLS([cairo_image_surface_get_format], [#include <cairo.h>])
has_cairo_ft=no
AC_MSG_CHECKING([for FreeType support in cairo])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <cairo.h>
#ifndef CAIRO_HAS_FT_FONT
#error nope, no ft
#endif
])],[has_cairo_ft=yes])
AC_MSG_RESULT(${has_cairo_ft})
need_xtra_ft_flags=no
if test "${has_cairo_ft}" = yes; then
AC_MSG_CHECKING([whether FreeType needs additional flags])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <cairo.h>
#include <cairo-ft.h>
int main(void) {
cairo_ft_font_face_create_for_pattern(0);
return 0;
}
])],[],[need_xtra_ft_flags=yes])
AC_MSG_RESULT(${need_xtra_ft_flags})
fi
if test "${need_xtra_ft_flags}" = yes; then
if test -n "${PKGCONF}"; then
AC_MSG_CHECKING([whether pkg-config knows about fontconfig or freetype2])
ftmod=''
for module in fontconfig freetype2; do
if "${PKGCONF}" --exists ${module}; then ftmod="${ftmod} ${module}"; fi
done
if test -n "${ftmod}"; then
AC_MSG_RESULT(yes)
FT_CPPFLAGS=`"${PKGCONF}" --cflags ${ftmod}`
FT_LIBS=`"${PKGCONF}" --libs ${ftmod}`
else
AC_MSG_RESULT(no)
fi
fi
if test -z "${FT_LIBS}"; then
AC_MSG_CHECKING([whether fontconfig/freetype2 location can be guessed])
FCI=''; FTI=''; FCL=''; FTL=''
for pre in /usr /usr/X11 /usr/X11R6 /usr/local /opt /sw; do
if test -z "${FCI}" -a -e "${pre}/include/fontconfig/fontconfig.h"; then
FCI="-I${pre}/include"
FCL="-L${pre}/lib"
fi
if test -z "{FTI}" -a -e "${pre}/include/freetype2/freetype/freetype.h"; then
FTI="-I${pre}/include/freetype2"
FTL="-L${pre}/lib"
fi
done
if test "${FCI}" = -I/usr/include; then FCI=''; fi
if test "${FCL}" = "-L/usr/lib"; then FCL=''; fi
if test "${FTL}" = "-L/usr/lib"; then FTL=''; fi
if test "${FTL}" = "${FCL}"; then FTL=''; fi
if test -z "${FCI}" -a -z "${FTI}"; then
AC_MSG_RESULT(no)
AC_MSG_ERROR([Cannot find fontconfig/freetype2 although cairo claims to support it. Please check your cairo installation and/or update cairo if necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly.])
fi
FT_CPPFLAGS="${FCI} ${FTI}"
FT_LIBS="${FCL} ${FTL} -lfontconfig -lfreetype -lz"
AC_MSG_RESULT([possibly])
fi
zLIBS="${LIBS}"
LIBS="${LIBS} ${FT_LIBS}"
zCPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${FT_CPPFLAGS}"
AC_MSG_CHECKING([whether additional flags work])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <cairo.h>
#include <cairo-ft.h>
int main(void) {
cairo_ft_font_face_create_for_pattern(0);
return 0;
}
])],[AC_MSG_RESULT(yes)
CAIRO_LIBS="${CAIRO_LIBS} ${FT_LIBS}"
CAIRO_CFLAGS="${CAIRO_CFLAGS} ${FT_CPPFLAGS}"
],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([Cannot use cairo-ft backend, although cairo claims it is working. Please check your caito installation and/or update cairo if necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly.])
])
fi
# --- check for JPEG support ---
AC_MSG_CHECKING([wheter libjpeg works])
zLIBS="${LIBS}"
LIBS="${LIBS} -ljpeg"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <stdio.h>
#include <jpeglib.h>
int main(void) {
struct jpeg_compress_struct cinfo;
jpeg_create_compress(&cinfo);
return 0;
}
])],[ AC_MSG_RESULT([yes])
AC_DEFINE(SUPPORTS_JPEG, 1, [Define to 1 if libjpeg is present and working])],
[ AC_MSG_RESULT(no)
LIBS="${zLIBS}"])
# --- check for TIFF support
AC_MSG_CHECKING([wheter libtiff works])
zLIBS="${LIBS}"
LIBS="${LIBS} -ltiff"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <tiffio.h>
int main(void) {
TIFF *out = TIFFOpen("new.tif", "w");
TIFFSetField (out, TIFFTAG_IMAGEWIDTH, 100);
return 0;
}
])],[ AC_MSG_RESULT([yes])
AC_DEFINE(SUPPORTS_TIFF, 1, [Define to 1 if libtiff is present and working])],
[ AC_MSG_RESULT(no)
LIBS="${zLIBS}"])
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT