Mercurial > hg > xmms-sid
comparison acinclude.m4 @ 30:fde5167bb736
Updated to have macros for detecting libSIDPlay 1 and 2
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Jun 2003 23:54:00 +0000 |
parents | 183e7cbc1036 |
children | ca6dab6c4ead |
comparison
equal
deleted
inserted
replaced
29:831a1b1f1508 | 30:fde5167bb736 |
---|---|
1 dnl Some handy functions | 1 dnl *** These m4-macros are directly ripped from XSIDPlay's acinclude.m4 |
2 | 2 dnl *** (C) Copyright 2002 Michael Schwendt, licensed under GNU GPL v2. |
3 dnl Try a list of directories, set the first one found | 3 |
4 dnl Usage: AC_CHECK_DIRS(DIRECTORY..., ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) | 4 dnl ------------------------------------------------------------------------- |
5 | 5 dnl Try to find a file (or one of more files in a list of dirs). |
6 AC_DEFUN(AC_CHECK_DIRS, | 6 dnl ------------------------------------------------------------------------- |
7 [ | 7 |
8 for ac_dir in $1 | 8 AC_DEFUN(MY_FIND_FILE, |
9 do | 9 [ |
10 AC_MSG_CHECKING([for directory ${ac_dir}]) | 10 $3="" |
11 if test -d ${ac_dir} | 11 for i in $2; |
12 then | 12 do |
13 AC_MSG_RESULT(yes) | 13 for j in $1; |
14 ifelse([$2], , :, [$2]) | 14 do |
15 break | 15 if test -r "$i/$j"; then |
16 else | 16 $3=$i |
17 AC_MSG_RESULT(no) | 17 break 2 |
18 fi | 18 fi |
19 done | 19 done |
20 if test ! -d ${ac_dir} | 20 done |
21 then | 21 ]) |
22 ifelse([$3], , :, [$3]) | 22 |
23 fi | 23 dnl ------------------------------------------------------------------------- |
24 ]) | 24 |
25 | 25 AC_DEFUN(MY_SUBST, |
26 # sidplay.m4 sidplay checks | 26 dnl Substitute an instance of @$1@ with value "$2". |
27 | 27 dnl Example: MY_SUBST(FOO,BAR) <-> @FOO@ => BAR |
28 AC_DEFUN(AC_FIND_FILE, | 28 [ |
29 eval "$1=$2" | |
30 AC_SUBST($1) | |
31 ]) | |
32 | |
33 AC_DEFUN(MY_SUBST_DEF, | |
34 dnl Substitute an instance of @$1@ with value "#define $1". | |
35 dnl Example: MY_SUBST_DEF(FOO) <-> @FOO@ => #define FOO | |
36 [ | |
37 eval "$1=\"#define $1\"" | |
38 AC_SUBST($1) | |
39 ]) | |
40 | |
41 AC_DEFUN(MY_SUBST_UNDEF, | |
42 dnl Substitute an instance of @$1@ with value "#undef $1". | |
43 dnl Example: MY_SUBST_UNDEF(FOO) <-> @FOO@ => #undef FOO | |
44 [ | |
45 eval "$1=\"#undef $1\"" | |
46 AC_SUBST($1) | |
47 ]) | |
48 | |
49 dnl ------------------------------------------------------------------------- | |
50 dnl Check whether compiler has a working ``bool'' type. | |
51 dnl ------------------------------------------------------------------------- | |
52 | |
53 AC_DEFUN(MY_CHECK_BOOL, | |
54 [ | |
55 AC_MSG_CHECKING([for bool]) | |
56 AC_CACHE_VAL(my_cv_have_bool, | |
29 [ | 57 [ |
30 $3=NO | 58 AC_TRY_COMPILE( |
31 for i in $2; | 59 [], |
32 do | 60 [bool aBool = true;], |
33 for j in $1; | 61 [my_cv_have_bool=yes], |
34 do | 62 [my_cv_have_bool=no] |
35 if test -r "$i/$j"; then | 63 ) |
36 $3=$i | 64 ]) |
37 break 2 | 65 AC_MSG_RESULT($my_cv_have_bool) |
38 fi | 66 if test "$my_cv_have_bool" = yes; then |
39 done | 67 AC_DEFINE(XSID_HAVE_BOOL) |
40 done | 68 fi |
41 ] | 69 ]) |
42 ) | 70 |
43 | 71 dnl ------------------------------------------------------------------------- |
44 AC_DEFUN(AC_PATH_LIBSIDPLAY, | 72 dnl Check whether C++ library has openmode ios::bin instead of ios::binary. |
45 [ | 73 dnl Will define XSID_HAVE_IOS_BIN if ios::binary is not available. |
46 AC_MSG_CHECKING([for SIDPLAY includes and library]) | 74 dnl ------------------------------------------------------------------------- |
47 AC_LANG_SAVE | 75 |
48 AC_LANG_CPLUSPLUS | 76 AC_DEFUN(MY_CHECK_IOS_BIN, |
49 ac_sidplay_cflags=NO | 77 [ |
50 ac_sidplay_library=NO | 78 AC_MSG_CHECKING(whether standard openmode ios::binary is available) |
51 sidplay_cflags="" | 79 AC_CACHE_VAL(my_cv_have_ios_binary, |
52 sidplay_library="" | 80 [ |
53 | 81 AC_TRY_COMPILE( |
54 AC_ARG_WITH(sidplay-prefix, | 82 [#include <fstream.h>], |
55 [ --with-sidplay-prefix=DIR | 83 [ifstream myTest("test",ios::in|ios::binary);], |
56 where the sidplay includes and library are located], | 84 [my_cv_have_ios_binary=yes], |
57 [ac_sidplay_cflags="${withval}/include" | 85 [my_cv_have_ios_binary=no] |
58 ac_sidplay_library="${withval}/lib" | 86 ) |
59 ]) | 87 ]) |
60 | 88 AC_MSG_RESULT($my_cv_have_ios_binary) |
61 AC_ARG_WITH(sidplay-includes, | 89 if test "$my_cv_have_ios_binary" = no; then |
62 [ --with-sidplay-includes=DIR | 90 AC_DEFINE(XSID_HAVE_IOS_BIN) |
63 where the sidplay includes are located], | 91 fi |
64 [ac_sidplay_cflags="$withval" | 92 ]) |
65 ]) | 93 |
66 | 94 dnl ------------------------------------------------------------------------- |
67 AC_ARG_WITH(sidplay-library, | 95 dnl Check whether C++ compiler supports the "nothrow allocator". |
68 [ --with-sidplay-library=DIR | 96 dnl Will define XSID_HAVE_NOTHROW if test code compiles. |
69 where the sidplay library is installed], | 97 dnl ------------------------------------------------------------------------- |
70 [ac_sidplay_library="$withval" | 98 |
71 ]) | 99 AC_DEFUN(MY_CHECK_NOTHROW, |
72 | 100 [ |
73 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then | 101 AC_MSG_CHECKING(whether nothrow allocator is available) |
74 #search common locations | 102 AC_CACHE_VAL(my_cv_have_nothrow, |
75 | 103 [ |
76 AC_CACHE_VAL(ac_cv_have_sidplay, | 104 AC_TRY_COMPILE( |
77 [ | 105 [#include <new>], |
78 sidplay_incdirs="$ac_sidplay_cflags /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include" | 106 [char* buf = new(std::nothrow) char[1024];], |
79 AC_FIND_FILE(sidplay/sidtune.h,$sidplay_incdirs,sidplay_foundincdir) | 107 [my_cv_have_nothrow=yes], |
80 ac_sidplay_cflags=$sidplay_foundincdir | 108 [my_cv_have_nothrow=no] |
81 | 109 ) |
82 sidplay_libdirs="$ac_sidplay_library /usr/lib /usr/local/lib /usr/lib/sidplay /usr/local/lib/sidplay" | 110 ]) |
83 AC_FIND_FILE(libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,$sidplay_libdirs,sidplay_foundlibdir) | 111 AC_MSG_RESULT($my_cv_have_nothrow) |
84 ac_sidplay_library=$sidplay_foundlibdir | 112 if test "$my_cv_have_nothrow" = yes; then |
85 | 113 AC_DEFINE(XSID_HAVE_NOTHROW) |
86 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then | 114 fi |
87 ac_cv_have_sidplay="have_sidplay=no" | 115 ]) |
88 ac_sidplay_notfound="" | 116 |
89 if test "$ac_sidplay_cflags" = NO; then | 117 dnl ------------------------------------------------------------------------- |
90 if test "$ac_sidplay_library" = NO; then | 118 dnl Pass C++ compiler options to libtool which supports C only. |
91 ac_sidplay_notfound="(headers and library)"; | 119 dnl ------------------------------------------------------------------------- |
92 else | 120 |
93 ac_sidplay_notfound="(headers)"; | 121 AC_DEFUN(MY_PROG_LIBTOOL, |
94 fi | 122 [ |
95 else | 123 my_save_cc="$CC" |
96 ac_sidplay_notfound="(library)"; | 124 my_save_cflags="$CFLAGS" |
97 fi | 125 CC="$CXX" |
98 eval "$ac_cv_have_sidplay" | 126 CFLAGS="$CXXFLAGS" |
99 AC_MSG_RESULT([$have_sidplay]) | 127 AM_PROG_LIBTOOL |
100 else | 128 CC="$my_save_cc" |
101 have_sidplay=yes | 129 CFLAGS="$my_save_cflags" |
102 fi | 130 ]) |
103 | 131 |
104 ]) dnl AC_CACHE_VAL(ac_cv_have_sidplay, | 132 dnl ------------------------------------------------------------------------- |
105 else | 133 |
106 have_sidplay=yes | 134 AC_DEFUN(MY_TRY_LINK_SAVE, |
107 fi dnl if (have_to_search) | 135 [ |
108 | 136 my_cxx_save="$CXX" |
109 eval "$ac_cv_have_sidplay" | 137 my_cxxflags_save="$CXXFLAGS" |
110 | 138 my_ldflags_save="$LDFLAGS" |
111 if test "$have_sidplay" != yes; then | 139 my_libs_save="$LIBS" |
112 AC_MSG_RESULT([$have_sidplay]); | 140 ]) |
113 else | 141 |
114 ac_cv_have_sidplay="have_sidplay=yes \ | 142 AC_DEFUN(MY_TRY_LINK_RESTORE, |
115 ac_sidplay_cflags=$ac_sidplay_cflags ac_sidplay_library=$ac_sidplay_library" | 143 [ |
116 AC_MSG_RESULT([library $ac_sidplay_library, headers $ac_sidplay_cflags]) | 144 CXX="$my_cxx_save" |
117 | 145 CXXFLAGS="$my_cxxflags_save" |
118 sidplay_library=$ac_sidplay_library | 146 LDFLAGS="$my_ldflags_save" |
119 sidplay_cflags=$ac_sidplay_cflags | 147 LIBS="$my_libs_save" |
120 | 148 ]) |
121 SIDPLAY_LIBS="-L$sidplay_library -lsidplay" | 149 |
122 all_libraries="$SIDPLAY_LIBS $all_libraries" | 150 AC_DEFUN(MY_PROG_PKGCONFIG, |
123 SIDPLAY_CFLAGS="-I$sidplay_cflags" | 151 [ |
124 all_includes="$SIDPLAY_CFLAGS $all_includes" | 152 AC_PATH_PROG(PKG_CONFIG, pkg-config, "") |
125 fi | 153 ]) |
126 | 154 |
127 dnl Test compilation. | 155 AC_DEFUN(MY_NEED_PKGCONFIG, |
128 | 156 [ |
129 AC_MSG_CHECKING([whether -lsidplay works]) | 157 AC_REQUIRE([MY_PROG_PKGCONFIG]) |
130 ac_cxxflags_safe=$CXXFLAGS | 158 if test -z "$PKG_CONFIG"; then |
131 ac_ldflags_safe=$LDFLAGS | 159 AC_MSG_ERROR([pkg-config not found. See http://pkgconfig.sourceforge.net]) |
132 ac_libs_safe=$LIBS | 160 fi |
133 | 161 if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then |
134 CXXFLAGS="$CXXFLAGS -I$sidplay_cflags" | 162 AC_MSG_ERROR([pkg-config too old; version 0.5 or better required.]) |
135 LDFLAGS="$LDFLAGS -L$sidplay_library" | 163 fi |
136 LIBS="-lsidplay" | 164 ]) |
137 | 165 |
138 AC_CACHE_VAL(ac_cv_sidplay_works, | 166 dnl ------------------------------------------------------------------------- |
139 [ | 167 dnl Try to find SIDPLAY library and header files. |
168 dnl $my_cv_have_sidplay will be "yes" or "no" | |
169 dnl @SIDPLAY_LDADD@ will be substituted with linker parameters | |
170 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters | |
171 dnl ------------------------------------------------------------------------- | |
172 | |
173 AC_DEFUN(MY_PATH_LIBSIDPLAY, | |
174 [ | |
175 AC_MSG_CHECKING([for working SIDPLAY library and headers]) | |
176 AC_REQUIRE([MY_ARGS_LIBSIDPLAY]) | |
177 | |
178 # Use include path given by user (if any). | |
179 if test -n "$my_sidplay_includes"; then | |
180 my_sidplay_cxxflags="-I$my_sidplay_includes" | |
181 else | |
182 my_sidplay_cxxflags="" | |
183 fi | |
184 | |
185 # Use library path given by user (if any). | |
186 if test -n "$my_sidplay_library"; then | |
187 my_sidplay_ldflags="-L$my_sidplay_library" | |
188 else | |
189 my_sidplay_ldflags="" | |
190 fi | |
191 | |
192 AC_CACHE_VAL(my_cv_have_sidplay, | |
193 [ | |
194 # Run test compilation with either standard search path | |
195 # or user-defined paths. | |
196 MY_TRY_LIBSIDPLAY | |
197 if test "$my_sidplay_works" = yes; then | |
198 my_cv_have_sidplay="my_have_sidplay=yes \ | |
199 my_sidplay_cxxflags=\"$my_sidplay_cxxflags\" \ | |
200 my_sidplay_ldflags=\"$my_sidplay_ldflags\" " | |
201 else | |
202 MY_FIND_LIBSIDPLAY | |
203 fi | |
204 ]) | |
205 eval "$my_cv_have_sidplay" | |
206 if test "$my_have_sidplay" = yes; then | |
207 if test -n "$my_sidplay_cxxflags" || test -n "$my_sidplay_ldflags"; then | |
208 AC_MSG_RESULT([$my_sidplay_cxxflags $my_sidplay_ldflags]) | |
209 else | |
210 AC_MSG_RESULT([yes]) | |
211 fi | |
212 else | |
213 AC_MSG_RESULT([no]) | |
214 fi | |
215 SIDPLAY_LDADD="$my_sidplay_ldflags -lsidplay" | |
216 SIDPLAY_INCLUDES="$my_sidplay_cxxflags" | |
217 AC_SUBST(SIDPLAY_LDADD) | |
218 AC_SUBST(SIDPLAY_INCLUDES) | |
219 ]) | |
220 | |
221 dnl Functions used by MY_PATH_LIBSIDPLAY. | |
222 | |
223 AC_DEFUN(MY_FIND_LIBSIDPLAY, | |
224 [ | |
225 # Search common locations where header files might be stored. | |
226 my_sidplay_incdirs="$my_sidplay_includes /usr/include /usr/local/include \ | |
227 /usr/lib/sidplay/include /usr/local/lib/sidplay/include" | |
228 MY_FIND_FILE(sidplay/sidtune.h, $my_sidplay_incdirs, \ | |
229 my_sidplay_includes) | |
230 | |
231 # Search common locations where library might be stored. | |
232 my_sidplay_libdirs="$my_sidplay_library /usr/lib /usr/lib/sidplay \ | |
233 /usr/local/lib/sidplay" | |
234 MY_FIND_FILE(libsidplay.a libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37, | |
235 $my_sidplaylibdirs, my_sidplay_library) | |
236 | |
237 if test -z "$my_sidplay_includes" || test -z "$my_sidplay_library"; then | |
238 my_cv_have_sidplay="my_have_sidplay=no \ | |
239 my_sidplay_ldflags=\"\" my_sidplay_cxxflags=\"\" " | |
240 else | |
241 # Test compilation with found paths. | |
242 my_sidplay_ldflags="-L$my_sidplay_library" | |
243 my_sidplay_cxxflags="-I$my_sidplay_includes" | |
244 MY_TRY_LIBSIDPLAY | |
245 my_cv_have_sidplay="my_have_sidplay=$my_sidplay_works \ | |
246 my_sidplay_ldflags=\"$my_sidplay_ldflags\" \ | |
247 my_sidplay_cxxflags=\"$my_sidplay_cxxflags\" " | |
248 fi | |
249 ]) | |
250 | |
251 AC_DEFUN(MY_TRY_LIBSIDPLAY, | |
252 [ | |
253 MY_TRY_LINK_SAVE | |
254 | |
255 CXXFLAGS="$CXXFLAGS $my_sidplay_cxxflags" | |
256 LDFLAGS="$LDFLAGS $my_sidplay_ldflags" | |
257 LIBS="$LIBS -lsidplay" | |
258 | |
140 AC_TRY_LINK( | 259 AC_TRY_LINK( |
141 [#include <sidplay/sidtune.h>], | 260 [#include <sidplay/sidtune.h>], |
142 [sidTune* myTest;], | 261 [sidTune* myTest = new sidTune(0);], |
143 [ac_cv_sidplay_works=yes], | 262 [my_sidplay_works=yes], |
144 [ac_cv_sidplay_works=no] | 263 [my_sidplay_works=no] |
145 ) | 264 ) |
146 ]) | 265 MY_TRY_LINK_RESTORE |
147 | 266 ]) |
148 CXXFLAGS="$ac_cxxflags_safe" | 267 |
149 LDFLAGS="$ac_ldflags_safe" | 268 dnl ------------------------------------------------------------------------- |
150 LIBS="$ac_libs_safe" | 269 dnl Try to find SIDPLAY2 library and header files. |
151 | 270 dnl $my_cv_have_sidplay2 will be "yes" or "no" |
152 AC_MSG_RESULT([$ac_cv_sidplay_works]) | 271 dnl @SIDPLAY_LDADD@ will be substituted with linker parameters |
153 if test "$ac_cv_sidplay_works" != yes; then | 272 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters |
154 have_sidplay=no | 273 dnl ------------------------------------------------------------------------- |
155 fi | 274 |
156 | 275 AC_DEFUN(MY_PATH_LIBSIDPLAY2, |
157 dnl | 276 [ |
158 | 277 AC_MSG_CHECKING([for working SIDPLAY2 library and headers]) |
159 AC_SUBST(SIDPLAY_CFLAGS) | 278 |
160 AC_SUBST(SIDPLAY_LIBS) | 279 AC_REQUIRE([MY_PROG_PKGCONFIG]) |
161 | 280 if test -n "$PKG_CONFIG" && $PKG_CONFIG --atleast-version $LIBSIDPLAY2_REQUIRED_VERSION libsidplay2; then |
162 AC_SUBST(sidplay_library) | 281 my_pkgcfg_knows=yes |
163 AC_SUBST(sidplay_cflags) | 282 else |
164 | 283 my_pkgcfg_knows=no |
165 AC_LANG_RESTORE | 284 fi |
166 | 285 dnl echo "(" pkg-config knows = $my_pkgcfg_knows ")" |
167 ]) | 286 |
287 AC_REQUIRE([MY_ARGS_LIBSIDPLAY]) | |
288 # Share --with-* args with libsidplay1. | |
289 my_sidplay2_library="$my_sidplay_library" | |
290 my_sidplay2_includes="$my_sidplay_includes" | |
291 | |
292 # Derive sidbuilders path from libsidplay2 root. | |
293 if test -n "$my_sidplay2_library"; then | |
294 my_sidplay2_builders="$my_sidplay2_library/sidplay/builders" | |
295 elif test "$my_pkgcfg_knows" = yes ; then | |
296 my_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` | |
297 fi | |
298 | |
299 AC_CACHE_VAL(my_cv_have_sidplay2, | |
300 [ | |
301 # Run test compilation with either standard search path | |
302 # or user-defined paths. | |
303 my_sidplay2_ldadd="-lsidplay2" | |
304 MY_TRY_LIBSIDPLAY2 | |
305 if test "$my_sidplay2_works" = yes; then | |
306 my_cv_have_sidplay2="my_have_sidplay2=yes \ | |
307 my_sidplay2_cxxflags=\"$my_sidplay2_cxxflags\" \ | |
308 my_sidplay2_ldadd=\"$my_sidplay2_ldadd\" \ | |
309 my_sidplay2_builders=\"$my_sidplay2_builders\" " | |
310 else | |
311 MY_FIND_LIBSIDPLAY2 | |
312 fi | |
313 ]) | |
314 eval "$my_cv_have_sidplay2" | |
315 if test "$my_have_sidplay2" = yes; then | |
316 if test -n "$my_sidplay2_cxxflags" || test -n "$my_sidplay2_ldadd"; then | |
317 AC_MSG_RESULT([$my_sidplay2_cxxflags $my_sidplay2_ldadd]) | |
318 else | |
319 AC_MSG_RESULT([yes]) | |
320 fi | |
321 else | |
322 AC_MSG_RESULT([no]) | |
323 fi | |
324 SIDPLAY_LDADD="$my_sidplay2_ldadd" | |
325 SIDPLAY_INCLUDES="$my_sidplay2_cxxflags" | |
326 AC_SUBST(SIDPLAY_LDADD) | |
327 AC_SUBST(SIDPLAY_INCLUDES) | |
328 ]) | |
329 | |
330 dnl Functions used by MY_PATH_LIBSIDPLAY. | |
331 | |
332 AC_DEFUN(MY_FIND_LIBSIDPLAY2, | |
333 [ | |
334 # See whether user didn't provide paths. | |
335 if test -z "$my_sidplay2_includes"; then | |
336 if test "$my_pkgcfg_knows" = yes ; then | |
337 my_sidplay2_includes=`$PKG_CONFIG --variable=includedir libsidplay2` | |
338 my_sidplay2_cxxflags=`$PKG_CONFIG --cflags libsidplay2` | |
339 else | |
340 # Search common locations where header files might be stored. | |
341 my_sidplay2_incdirs="$my_sidplay2_includes $my_sidplay2_includes/include" | |
342 MY_FIND_FILE(sidplay/sidplay2.h,$my_sidplay2_incdirs,my_sidplay2_includes) | |
343 my_sidplay2_cxxflags="-I$my_sidplay2_includes" | |
344 fi | |
345 else | |
346 my_sidplay2_cxxflags="-I$my_sidplay2_includes" | |
347 fi | |
348 if test -z "$my_sidplay2_library"; then | |
349 if test "$my_pkgcfg_knows" = yes ; then | |
350 my_sidplay2_library=`$PKG_CONFIG --variable=libdir libsidplay2` | |
351 my_sidplay2_ldadd=`$PKG_CONFIG --libs libsidplay2` | |
352 my_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` | |
353 else | |
354 # Search common locations where library might be stored. | |
355 my_sidplay2_libdirs="$my_sidplay2_library $my_sidplay2_library/lib \ | |
356 $my_sidplay2_library/src" | |
357 MY_FIND_FILE(libsidplay2.la,$my_sidplay2_libdirs,my_sidplay2_library) | |
358 my_sidplay2_ldadd="-L$my_sidplay2_library -lsidplay2" | |
359 my_sidplay2_builders="$my_sidplay2_library/sidplay/builders" | |
360 fi | |
361 else | |
362 my_sidplay2_ldadd="-L$my_sidplay2_library -lsidplay2" | |
363 fi | |
364 if test -z "$my_sidplay2_includes" || test -z "$my_sidplay2_library"; then | |
365 my_cv_have_sidplay2="my_have_sidplay2=no \ | |
366 my_sidplay2_ldadd=\"\" my_sidplay2_cxxflags=\"\" \ | |
367 my_sidplay2_builders=\"\" " | |
368 else | |
369 # Test compilation with found paths. | |
370 my_sidplay2_ldadd="-L$my_sidplay2_library -lsidplay2" | |
371 my_sidplay2_cxxflags="-I$my_sidplay2_includes" | |
372 MY_TRY_LIBSIDPLAY2 | |
373 my_cv_have_sidplay2="my_have_sidplay2=$my_sidplay2_works \ | |
374 my_sidplay2_ldadd=\"$my_sidplay2_ldadd\" \ | |
375 my_sidplay2_cxxflags=\"$my_sidplay2_cxxflags\" \ | |
376 my_sidplay2_builders=\"$my_sidplay2_builders\" " | |
377 fi | |
378 echo "DEBUG: $my_sidplay2_cxxflags" | |
379 echo "DEBUG: $my_sidplay2_ldadd" | |
380 ]) | |
381 | |
382 AC_DEFUN(MY_TRY_LIBSIDPLAY2, | |
383 [ | |
384 MY_TRY_LINK_SAVE | |
385 | |
386 CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX" | |
387 CXXFLAGS="$CXXFLAGS $my_sidplay2_cxxflags -DHAVE_UNIX" | |
388 LDFLAGS="$LDFLAGS $my_sidplay2_ldadd" | |
389 | |
390 AC_TRY_LINK( | |
391 [#include <sidplay/sidplay2.h>], | |
392 [sidplay2 *myEngine;], | |
393 [my_sidplay2_works=yes], | |
394 [my_sidplay2_works=no] | |
395 ) | |
396 MY_TRY_LINK_RESTORE | |
397 ]) | |
398 | |
399 dnl ------------------------------------------------------------------------- | |
400 dnl Find libsidplay2 builders (sidbuilders) dir. | |
401 dnl @BUILDERS_INCLUDES@ | |
402 dnl @BUILDERS_LDFLAGS@ | |
403 dnl ------------------------------------------------------------------------- | |
404 AC_DEFUN(BUILDERS_FIND, | |
405 [ | |
406 AC_MSG_CHECKING([for SIDPLAY2 builders directory]) | |
407 AC_REQUIRE([MY_PATH_LIBSIDPLAY2]) | |
408 | |
409 dnl Be pessimistic. | |
410 builders_available=no | |
411 | |
412 dnl Sidbuilder headers are included with "builders" prefix. | |
413 builders_includedir=$my_sidplay2_includes | |
414 builders_libdir=$my_sidplay2_builders | |
415 | |
416 dnl If libsidplay2 is in standard library search path, we need | |
417 dnl to get an argument whether /usr, /usr/local, etc. Else we | |
418 dnl can only use ${libdir}/sidplay/builders, but then are | |
419 dnl unable to check whether files exist as long as ${exec_prefix} | |
420 dnl is not defined in the configure script. So, this is a bit | |
421 dnl ugly, but a satisfactory fallback default for those who | |
422 dnl define ${prefix} and ${exec_prefix}. | |
423 if test -z $builders_libdir; then | |
424 eval "builders_libdir=$libdir/sidplay/builders" | |
425 fi | |
426 | |
427 AC_ARG_WITH(sidbuilders, | |
428 [ --with-sidbuilders=DIR what the SIDPLAY2 builders install PREFIX is], | |
429 [builders_includedir="$withval/include" | |
430 builders_libdir="$withval/lib/sidplay/builders"] | |
431 ) | |
432 AC_ARG_WITH(builders-inc, | |
433 [ --with-builders-inc=DIR where the SIDPLAY2 builders headers are located], | |
434 [builders_includedir="$withval"] | |
435 ) | |
436 AC_ARG_WITH(builders-lib, | |
437 [ --with-builders-lib=DIR where the SIDPLAY2 builders libraries are installed], | |
438 [builders_libdir="$withval"] | |
439 ) | |
440 | |
441 if test -n "$builders_includedir"; then | |
442 BUILDERS_INCLUDES="-I$builders_includedir" | |
443 fi | |
444 if test -n "$builders_libdir"; then | |
445 BUILDERS_LDFLAGS="-L$builders_libdir" | |
446 fi | |
447 if test -d $builders_libdir; then | |
448 my_have_sidbuilders_dir=yes | |
449 AC_MSG_RESULT([$builders_libdir]) | |
450 else | |
451 my_have_sidbuilders_dir=no | |
452 AC_MSG_RESULT([$my_have_sidbuilders_dir]) | |
453 AC_MSG_ERROR([$builders_libdir not found! | |
454 Check --help on how to specify SIDPLAY2 and/or builders library and | |
455 header path, or set --exec-prefix to the same prefix as your installation | |
456 of libsidplay2. | |
457 ]) | |
458 fi | |
459 AC_SUBST(BUILDERS_INCLUDES) | |
460 AC_SUBST(BUILDERS_LDFLAGS) | |
461 ]) | |
462 | |
463 dnl ------------------------------------------------------------------------- | |
464 dnl Test for working reSID builder. | |
465 dnl sets $(RESID_LDADD), substitutes @RESID_LDADD@ | |
466 dnl ------------------------------------------------------------------------- | |
467 AC_DEFUN(BUILDERS_FIND_RESID, | |
468 [ | |
469 AC_MSG_CHECKING([for reSID builder module]) | |
470 MY_TRY_LINK_SAVE | |
471 | |
472 CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX" | |
473 CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES" | |
474 LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS" | |
475 LIBS="$LIBS -lresid-builder" | |
476 | |
477 AC_TRY_LINK( | |
478 [#include <sidplay/builders/resid.h>], | |
479 [ReSIDBuilder *sid;], | |
480 [builders_work=yes], | |
481 [builders_work=no] | |
482 ) | |
483 MY_TRY_LINK_RESTORE | |
484 | |
485 if test "$builders_work" = yes; then | |
486 builders_available=yes | |
487 AC_DEFINE(XSID_HAVE_RESID_BUILDER) | |
488 RESID_LDADD="-lresid-builder" | |
489 fi | |
490 AC_MSG_RESULT($builders_work) | |
491 AC_SUBST(RESID_LDADD) | |
492 ]) | |
493 | |
494 dnl ------------------------------------------------------------------------- | |
495 dnl Test for working HardSID builder. | |
496 dnl sets $(HARDSID_LDADD), substitutes @HARDSID_LDADD@ | |
497 dnl ------------------------------------------------------------------------- | |
498 AC_DEFUN(BUILDERS_FIND_HARDSID, | |
499 [ | |
500 AC_MSG_CHECKING([for HardSID builder module]) | |
501 MY_TRY_LINK_SAVE | |
502 | |
503 CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX" | |
504 CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES" | |
505 LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS" | |
506 LIBS="$LIBS -lhardsid-builder" | |
507 | |
508 AC_TRY_LINK( | |
509 [#include <sidplay/builders/hardsid.h>], | |
510 [HardSID *sid;], | |
511 [builders_work=yes], | |
512 [builders_work=no] | |
513 ) | |
514 MY_TRY_LINK_RESTORE | |
515 | |
516 if test "$builders_work" = yes; then | |
517 builders_available=yes | |
518 AC_DEFINE(XSID_HAVE_HARDSID_BUILDER) | |
519 HARDSID_LDADD="-lhardsid-builder" | |
520 fi | |
521 AC_MSG_RESULT($builders_work) | |
522 AC_SUBST(HARDSID_LDADD) | |
523 ]) |