-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfig.m4
116 lines (98 loc) · 3.34 KB
/
config.m4
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
dnl config.m4 for extension opengl
PHP_ARG_WITH(opengl, for opengl support,
[ --with-opengl=DIR Include OpenGL support])
PHP_ARG_ENABLE(opengl-debug, whether to enable PHP-OpenGL debug support,
[ --enable-opengl-debug Enable OpenGL debug support], no, no)
CFLAGS="$CFLAGS -Wall -Wfatal-errors"
if test "$PHP_OPENGL" != "no"; then
if test -r $PHP_OPENGL/include/GL/gl.h; then
OPENGL_DIR=$PHP_OPENGL
else
AC_MSG_CHECKING(for OpenGL development files in default path)
for i in /usr/X11R6 /usr/local /usr /System/Library/Frameworks/OpenGL.framework/Headers; do
if test -r $i/include/GL/gl.h ; then
OPENGL_DIR=$i
AC_MSG_RESULT(found in $i)
fi
if test -r $i/gl.h ; then
OPENGL_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$OPENGL_DIR"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Please make sure OpenGL is properly installed - gl.h should be in <opengl-dir>/include/GL/)
fi
saved_LIBS="$LIBS"
failed=yes
for additional_libs in "" -lm; do
if test ! -z "$additional_libs"; then
AC_MSG_RESULT(with additional library $additional_libs)
fi
AC_MSG_CHECKING(if OpenGL links properly)
case $build_os in
darwin*)
LIBS="$saved_LIBS -Framework GL $additional_libs"
;;
*)
LIBS="$saved_LIBS -lGL $additional_libs"
;;
esac
AC_TRY_LINK( ,[char glBegin(); glBegin(); ], have_GL=yes, have_GL=no)
AC_MSG_RESULT($have_GL)
if test "$have_GL" = "no"; then
AC_MSG_CHECKING(if MesaGL links properly)
LIBS="$saved_LIBS -lMesaGL $additional_libs"
AC_TRY_LINK( ,[char glBegin(); glBegin(); ], have_MesaGL=yes, have_MesaGL=no)
AC_MSG_RESULT($have_MesaGL)
if test "$have_MesaGL" = "no"; then
AC_MSG_CHECKING(if MesaGL with pthreads links properly)
LIBS="$saved_LIBS -L$OPENGL_DIR/lib -lMesaGL -lpthread $additional_libs"
AC_TRY_LINK( ,[char glBegin(); glBegin(); ], have_MesaGL_pthreads=yes, have_MesaGL_pthreads=no)
AC_MSG_RESULT($have_MesaGL_pthreads)
if test "$have_MesaGL_pthreads" != "no"; then
LIBS="$saved_LIBS"
PHP_ADD_LIBRARY_WITH_PATH(pthread, $OPENGL_DIR/lib, OPENGL_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(MesaGL, $OPENGL_DIR/lib, OPENGL_SHARED_LIBADD)
failed=no
fi
else
LIBS="$saved_LIBS"
PHP_ADD_LIBRARY_WITH_PATH(MesaGL, $OPENGL_DIR/lib, OPENGL_SHARED_LIBADD)
failed=no
fi
else
LIBS="$saved_LIBS"
failed=no
fi
if test "$failed" = "no"; then
if test ! -z "$additional_libs"; then
PHP_EVAL_LIBLINE($additional_libs, OPENGL_SHARED_LIBADD)
fi
break
fi
done
if test "$failed" = "yeso"; then
AC_MSG_ERROR(Can't find OpenGL nor MesaGL)
fi
unset additional_libs
dnl {{{ --enable-opengl-debug
if test "$PHP_OPENGL_DEBUG" != "no"; then
CFLAGS="$CFLAGS -Wall -Wpedantic -g -ggdb -O0"
fi
dnl }}}
case $build_os in
darwin*)
PHP_ADD_FRAMEWORK(GL)
PHP_ADD_INCLUDE(/System/Library/Frameworks/OpenGL.framework/Headers)
;;
*)
PHP_ADD_LIBRARY_WITH_PATH(GL, /usr/$PHP_LIBDIR, OPENGL_SHARED_LIBADD)
;;
esac
PHP_ADD_INCLUDE($OPENGL_DIR/include)
PHP_NEW_EXTENSION(opengl, php_convert.c php_opengl.c, $ext_shared)
PHP_SUBST(OPENGL_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(opengl, sdl)
fi