Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 199 lines (166 sloc) 5.908 kB
a9461cd initializing repo from version 0.10.2 minus the example files
Julian authored
1 # Configure paths for SVGAlib
2 # Created by Pierre Sarrazin <http://sarrazip.com/>
3 # Tiny changes by Julian Albo.
4 # This file is in the public domain.
5 # Created from sdl.m4.
6
7 # This test must be executed in C mode (AC_LANG_C), not C++ mode.
8
9 # Defines SVGALIB_CFLAGS and SVGALIB_LIBS and submits them to AC_SUBST()
10
11 dnl AM_PATH_SVGALIB([MINIMUM-VERSION [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
12 dnl Test for SVGAlib, and define SVGALIB_CFLAGS and SVGALIB_LIBS
13 dnl
14 AC_DEFUN(AM_PATH_SVGALIB,
15 [
16 AC_ARG_WITH(svgalib-prefix,
17 AC_HELP_STRING([--with-svgalib-prefix=PFX],
18 [Prefix where SVGAlib is installed [[/usr]]] ),
19 svgalib_prefix="$withval",
20 svgalib_prefix="/usr"
21 )
22 AC_MSG_RESULT([using $svgalib_prefix as SVGAlib prefix])
23 AC_ARG_ENABLE(svgalibtest,
24 AC_HELP_STRING([--disable-svgalibtest],
25 [Do not try to compile and run a test program] ),
26 ,
27 enable_svgalibtest=yes
28 )
29
30 dnl Changed this check.
31 dnl AC_REQUIRE([AC_CANONICAL_TARGET])
32 AC_REQUIRE([AC_CANONICAL_HOST])
33 min_svgalib_version=ifelse([$1], ,1.4.0, $1)
34 AC_MSG_CHECKING([for SVGAlib - version >= $min_svgalib_version])
35 no_svgalib=""
36
37
38 if test "$svgalib_prefix" = /usr; then
39 # Avoid the switch -I/usr/include - it might break gcc 3.x
40 SVGALIB_CFLAGS=
41 else
42 SVGALIB_CFLAGS="-I$svgalib_prefix/include"
43 fi
44
45 SVGALIB_LIBS="-L$svgalib_prefix/lib -lvgagl -lvga"
46
47 # Get the version number, which appears to be in the lib*.so.* filename:
48 #
49 if test -f $svgalib_prefix/lib/libvga.so.*.*.*; then
50
51 _f=`echo $svgalib_prefix/lib/libvga.so.*.*.* | \
52 sed 's/^.*\.so\.//'`
53 svgalib_major_version=`echo $_f | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
55 svgalib_minor_version=`echo $_f | \
56 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
57 svgalib_micro_version=`echo $_f | \
58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
59
60 unset _f
61
62 else
63 AC_MSG_ERROR([could not find $svgalib_prefix/lib/libvga.so.*.*.*])
64 fi
65
66 if test "_$enable_svgalibtest" = "_yes" ; then
67 ac_save_CFLAGS="$CFLAGS"
68 ac_save_LIBS="$LIBS"
69 CFLAGS="$CFLAGS $SVGALIB_CFLAGS"
70 LIBS="$LIBS $SVGALIB_LIBS"
71 dnl
72 dnl Check if the installed SVGAlib is sufficiently new.
73 dnl
74 rm -f conf.svgalibtest
75 AC_TRY_RUN([
76 #include <stdio.h>
77 #include <stdlib.h>
78 #include <string.h>
79 #include "vga.h"
80
81 char*
82 my_strdup (char *str)
83 {
84 char *new_str;
85
86 if (str)
87 {
88 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
89 strcpy (new_str, str);
90 }
91 else
92 new_str = NULL;
93
94 return new_str;
95 }
96
97 int main (int argc, char *argv[])
98 {
99 int major, minor, micro;
100 char *tmp_version;
101
102 /* This hangs on some systems (?)
103 system ("touch conf.svgalibtest");
104 */
105 { FILE *fp = fopen("conf.svgalibtest", "a"); if ( fp ) fclose(fp); }
106
107 /* HP/UX 9 (%@#!) writes to sscanf strings */
108 tmp_version = my_strdup("$min_svgalib_version");
109 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
110 printf("%s, bad version string\n", "$min_svgalib_version");
111 exit(1);
112 }
113
114 if (($svgalib_major_version > major) ||
115 (($svgalib_major_version == major) && ($svgalib_minor_version > minor)) ||
116 (($svgalib_major_version == major) && ($svgalib_minor_version == minor) && ($svgalib_micro_version >= micro)))
117 {
118 return 0;
119 }
120 else
121 {
122 printf("\n*** Installed SVGAlib version is %d.%d.%d, but the minimum version\n", $svgalib_major_version, $svgalib_minor_version, $svgalib_micro_version);
123 printf("*** of SVGAlib required is %d.%d.%d.\n", major, minor, micro);
124 printf("*** It is best to upgrade to the required version.\n");
125 printf("*** The web site is http://www.svgalib.org/\n");
126 printf("*** See also --with-svgalib-prefix\n");
127 return 1;
128 }
129 }
130
131 ],
132 ,
133 no_svgalib=yes,
134 [echo $ac_n "cross compiling; assumed OK... $ac_c"]
135 )
136
137 CFLAGS="$ac_save_CFLAGS"
138 LIBS="$ac_save_LIBS"
139 fi
140
141
142 if test "_$no_svgalib" = _ ; then
143 AC_MSG_RESULT([found $svgalib_major_version.$svgalib_minor_version.$svgalib_micro_version])
144 ifelse([$2], , :, [$2])
145 else
146 AC_MSG_ERROR([SVGAlib >= min_svgalib_version not found])
147
148 if test -f conf.svgalibtest ; then
149 :
150 else
151 echo "*** Could not run SVGAlib test program, checking why..."
152
153 CFLAGS="$CFLAGS $SVGALIB_CFLAGS"
154 LIBS="$LIBS $SVGALIB_LIBS"
155
156 AC_TRY_LINK([
157 #include <stdio.h>
158 #include "vga.h"
159
160 int main(int argc, char *argv[])
161 { return 0; }
162 #undef main
163 #define main K_and_R_C_main
164 ], [ return 0; ],
165 [ echo "*** The test program compiled, but did not run. This usually means"
166 echo "*** that the run-time linker is not finding SVGAlib or finding the wrong"
167 echo "*** version of SVGAlib. If it is not finding SVGAlib, you'll need to set your"
168 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
169 echo "*** to the installed location Also, make sure you have run ldconfig if that"
170 echo "*** is required on your system"
171 echo "***"
172 echo "*** If you have an old version installed, it is best to remove it, although"
173 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
174 ],
175 [ echo "*** The test program failed to compile or link. See the file config.log for the"
176 echo "*** exact error that occured. This usually means SVGAlib was incorrectly installed"
177 echo "*** or that you have moved SVGAlib since it was installed."
178 echo "***"
179 echo "*** SVGAlib web site: http://www.svgalib.org/"
180 ]
181 )
182
183 CFLAGS="$ac_save_CFLAGS"
184 LIBS="$ac_save_LIBS"
185
186 AC_MSG_ERROR([SVGAlib >= min_svgalib_version not found])
187
188 fi
189
190 SVGALIB_CFLAGS=""
191 SVGALIB_LIBS=""
192 ifelse([$3], , :, [$3])
193 fi
194
195 AC_SUBST(SVGALIB_CFLAGS)
196 AC_SUBST(SVGALIB_LIBS)
197 rm -f conf.svgalibtest
198 ])
Something went wrong with that request. Please try again.