forked from dmurdoch/rgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
250 lines (218 loc) · 7.19 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
##
## This file is part of RGL
##
## Process configure.ac with autoconf to produce a configure script.
## NB: the files in src/build/autoconf may need updating for a new
## version of autoconf
##
##
##
AC_PREREQ([2.69])
## ---[ VERSION ]-------------------------------------------------------------
AC_INIT
AC_CONFIG_AUX_DIR(src/build/autoconf)
## pick up compiler as will be used by R CMD INSTALL/SHLIB
if test -n "${R_HOME}"; then
CC=`${R_HOME}/bin/R CMD config CC`
CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
HIDE_IF_R42PLUS=`${R_HOME}/bin/Rscript -e 'cat(if (getRversion() >= "4.2.0") "#" else "")'`
else
HIDE_IF_R42PLUS=""
fi
AC_PROG_CPP
AC_PROG_CC
if test `uname` = "Darwin" ; then
darwin="yes"
## we want the *build* cputype and not the host one.
cmd=`echo $CC $CFLAGS | grep -E 'x86_64|ppc64|-m64'`
if test -n "$cmd"; then
have_64bit="yes"
else
have_64bit="no"
fi
else
darwin="no"
fi
## --- LibPNG ----------------------------------------------------------------
AC_ARG_ENABLE([libpng],
[ --disable-libpng compile without PNG image support]
)
AC_ARG_ENABLE([libpng-config],
[ --disable-libpng-config disable libpng-config test and configuration]
)
AC_ARG_ENABLE([libpng-dynamic],
[ --disable-libpng-dynamic disable dynamic libpng linkage, force static version linkage (only with --enable-libpng-config)]
)
if test "x$enable_libpng" != "xno"; then
if test "x$enable_libpng_config" != "xno"; then
AC_CHECK_PROG([HAVE_LIBPNG_CONFIG],[libpng-config],[yes],[no])
fi
if test "x$HAVE_LIBPNG_CONFIG" = "xyes" ; then
AC_MSG_NOTICE([using libpng-config])
CPPFLAGS="${CPPFLAGS} -DHAVE_PNG_H `libpng-config --I_opts`"
if test "x$enable_libpng_dynamic" != "xno"; then
AC_MSG_NOTICE([using libpng dynamic linkage])
LIBS="${LIBS} `libpng-config --ldflags`"
else
AC_MSG_NOTICE([using libpng static linkage])
LIBS="${LIBS} `libpng-config --static --L_opts`/libpng.a"
fi
else
AC_MSG_CHECKING([libpng])
save_LIBS="${LIBS}"
save_CPPFLAGS="${CPPFLAGS}"
AC_CHECK_HEADERS(png.h)
AC_CHECK_LIB(png, png_read_update_info)
if test "${ac_cv_header_png_h}"; then
if test "${ac_cv_lib_png_png_read_update_info}"; then
CPPFLAGS="${CPPFLAGS} -DHAVE_PNG_H"
LIBS="${LIBS} -lpng"
AC_MSG_NOTICE([libpng header and lib found])
if test "x$enable_libpng_dynamic" != "xno"; then
AC_MSG_NOTICE([using libpng dynamic linkage])
else
AC_MSG_NOTICE([using libpng static linkage])
fi
else
LIBS=${save_LIBS}
CPPFLAGS=${save_CPPFLAGS}
AC_MSG_NOTICE([libpng header and lib not found])
fi
fi
fi
fi
# ---[ OpenGL enabled?]---------------------------------------------------------------
AC_ARG_ENABLE([opengl],
[ --disable-opengl compile without OpenGL support]
)
NULL_CPPFLAGS="${CPPFLAGS} -DRGL_NO_OPENGL"
NULL_LIBS="${LIBS}"
# ---[ X11 ]------------------------------------------------------------------
if test "x$enable_opengl" != "xno"; then
AC_PATH_X
if test x$no_x = xyes ; then
AC_MSG_WARN([X11 not found, continuing without OpenGL support.])
enable_opengl=no
else
if test -n "${x_includes}"; then
CPPFLAGS="${CPPFLAGS} -I${x_includes}"
fi
if test -n "${x_libraries}"; then
LIBS="${LIBS} -L${x_libraries} -lX11"
else
LIBS="${LIBS} -lX11"
fi
if test $darwin = yes; then
CPPFLAGS="${CPPFLAGS} -DDarwin"
if test -e /System/Library/Frameworks/GLKit.framework ; then
LIBS="-framework GLKit ${LIBS}"
fi
# X11 must come *after* the OpenGL stuff
CPPFLAGS="${CPPFLAGS} -I/opt/X11/include"
fi
AC_CHECK_FUNC(XAllocClassHint, [], [enable_opengl=no])
fi
fi
if test "x$enable_opengl" != "xno"; then
## --- OpenGL ----------------------------------------------------------------
AC_ARG_WITH(gl-includes,
[ --with-gl-includes=DIR specify location of OpenGL headers],
[CPPFLAGS="${CPPFLAGS} -I${withval}"]
)
if test $darwin != yes; then
AC_CHECK_HEADERS(GL/gl.h GL/glu.h)
if test "x$ac_cv_header_GL_gl_h" = xno; then
AC_MSG_WARN(missing required header GL/gl.h, continuing without OpenGL)
enable_opengl=no
fi
if test "x$ac_cv_header_GL_glu_h" = xno; then
AC_MSG_WARN(missing required header GL/glu.h, continuing without OpenGL)
enable_opengl=no
fi
fi
fi
if test "x$enable_opengl" != "xno"; then
AC_ARG_WITH(gl-libs,
[ --with-gl-libs=DIR specify location of OpenGL libs],
[LDFLAGS="${LDFLAGS} -L${withval}"
L_LIB="-L${withval}"]
)
AC_ARG_WITH(gl-libname,
[ --with-gl-libname=NAME specify Library name (defaults to "GL")],
[lGL=${withval}], [lGL=GL]
)
AC_CHECK_LIB($lGL, glEnd)
this=`eval echo '${'$as_ac_Lib'}'`
if test "x$this" != xyes; then
AC_MSG_WARN(missing required library ${lGL}, continuing without OpenGL)
enable_opengl=no
else
AC_CHECK_FUNC(glEnd, [], [enable_opengl=no])
fi
fi
if test "x$enable_opengl" != "xno"; then
AC_ARG_WITH(glu-libname,
[ --with-glu-libname=NAME specify GLU Library name (defaults to "GLU")],
[lGLU=${withval}], [lGLU=GLU]
)
AC_CHECK_LIB($lGLU, gluErrorString)
this=`eval echo '${'$as_ac_Lib'}'`
if test "x$this" != xyes; then
AC_MSG_WARN(missing required library ${lGLU}, continuing without OpenGL)
enable_opengl=no
else
AC_CHECK_FUNC(gluErrorString, [], [enable_opengl=no])
fi
fi
if test "x$enable_opengl" != "xno"; then
if test x$L_LIB != x; then
LIBS="${L_LIB} ${LIBS}"
fi
## --- FTGL ------------------------------------------------------------------
AC_ARG_ENABLE([ftgl],
[ --disable-ftgl compile without FTGL font support]
)
if test "x$enable_ftgl" != "xno"; then
if test "x$darwin" = "xyes"; then
AC_MSG_NOTICE([Darwin, so ensuring /opt/X11/bin is at the head of the PATH...])
PATH=/opt/X11/bin:${PATH}
fi
## new pkg-config bit
AC_CHECK_PROG([HAVE_PKG_CONFIG],[pkg-config],[yes],[no])
if test "x$HAVE_PKG_CONFIG" = "xyes" -a "x`pkg-config freetype2 --cflags`" != "x"; then
CPPFLAGS="${CPPFLAGS} -DHAVE_FREETYPE -Iext/ftgl `pkg-config freetype2 --cflags`"
LIBS="${LIBS} `pkg-config freetype2 --static --libs`"
AC_MSG_NOTICE([using Freetype and FTGL])
else
AC_CHECK_PROG([HAVE_FREETYPE_CONFIG],[freetype-config],[yes],[no])
if test "x$HAVE_FREETYPE_CONFIG" = "xyes"; then
CPPFLAGS="${CPPFLAGS} -DHAVE_FREETYPE -Iext/ftgl `freetype-config --cflags`"
LIBS="${LIBS} `freetype-config --static --libs`"
AC_MSG_NOTICE([using Freetype and FTGL])
else
AC_MSG_NOTICE([compiling without FTGL support])
fi
fi
else
AC_MSG_NOTICE([compiling without FTGL support])
fi
fi
if test "x$enable_opengl" = "xno"; then
AC_MSG_NOTICE([compiling without OpenGL support])
HIDE_IF_NO_OPENGL="#"
RGL_NO_OPENGL=TRUE
else
HIDE_IF_NO_OPENGL=""
RGL_NO_OPENGL=FALSE
fi
## --- Output ----------------------------------------------------------------
AC_SUBST(CPPFLAGS)
AC_SUBST(LIBS)
AC_SUBST(NULL_CPPFLAGS)
AC_SUBST(NULL_LIBS)
AC_SUBST(HIDE_IF_NO_OPENGL)
AC_SUBST(RGL_NO_OPENGL)
AC_SUBST(HIDE_IF_R42PLUS)
AC_CONFIG_FILES([R/noOpenGL.R src/useNULL/Makevars])
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT