Mercurial > hg > xmms-sid
comparison acinclude.m4 @ 676:60782f6c2bc8
Cleaned up the libSIDPlay-related Autoconf test m4 macros.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 10 May 2008 01:19:49 +0300 |
parents | 06820523d770 |
children | 6843b69895d9 |
comparison
equal
deleted
inserted
replaced
675:d1b32e981e73 | 676:60782f6c2bc8 |
---|---|
1 dnl *** These m4-macros are ripped from XSIDPLAY v1.6.5's acinclude.m4 | 1 dnl *** These m4-macros are ripped from XSIDPLAY v1.6.5's acinclude.m4 |
2 dnl *** (C) Copyright 2002 Michael Schwendt, licensed under GNU GPL v2. | 2 dnl *** (C) Copyright 2002 Michael Schwendt, licensed under GNU GPL v2. |
3 dnl *** Updated for new automake/autoconf plus namespace and other | 3 dnl *** |
4 dnl *** minor fixes and changes by Matti 'ccr' Hämäläinen (C) 2003-2006 TNSP | 4 dnl *** Updated for new automake/autoconf plus namespace, added portability |
5 | 5 dnl *** fixes and other minor changes by Matti 'ccr' Hamalainen |
6 dnl ------------------------------------------------------------------------- | 6 |
7 dnl Try to find a file (or one of more files in a list of dirs). | 7 AC_DEFUN([XS_FIND_FILE], |
8 dnl ------------------------------------------------------------------------- | 8 [ |
9 | 9 $3="" |
10 AC_DEFUN([MY_FIND_FILE], | 10 for i in $2; do |
11 [ | 11 for j in $1; do |
12 $3="" | 12 if test -r "$i/$j"; then |
13 for i in $2; do | 13 $3="$i" |
14 for j in $1; do | 14 break 2 |
15 if test -r "$i/$j"; then | 15 fi |
16 $3="$i" | 16 done |
17 break 2 | 17 done |
18 fi | 18 ]) |
19 done | 19 |
20 done | 20 |
21 ]) | 21 AC_DEFUN([XS_TRY_LIBRARY], |
22 | 22 [ |
23 dnl ------------------------------------------------------------------------- | 23 # xs_try_library ( $1:$2:$3:$4:$5:$6 ) |
24 | 24 AC_LANG_ASSERT([C++]) |
25 AC_DEFUN([MY_SUBST], | 25 m4_ifvaln([$2], [xs_cxxflags_save="$CXXFLAGS" |
26 dnl Substitute an instance of @$1@ with value "$2". | 26 CXXFLAGS="$CXXFLAGS $2"])dnl |
27 dnl Example: MY_SUBST(FOO,BAR) <-> @FOO@ => BAR | 27 m4_ifvaln([$3], [xs_ldflags_save="$LDFLAGS" |
28 [ | 28 LDFLAGS="$LDFLAGS $3"])dnl |
29 eval "$1=$2" | 29 m4_ifvaln([$4], [xs_libs_save="$LIBS" |
30 AC_SUBST($1) | 30 LIBS="$LIBS -l$4"])dnl |
31 ]) | 31 AC_LINK_IFELSE( |
32 | 32 [ |
33 AC_DEFUN([MY_SUBST_DEF], | 33 AC_LANG_PROGRAM( |
34 dnl Substitute an instance of @$1@ with value "#define $1". | 34 [#include <$5>], |
35 dnl Example: MY_SUBST_DEF(FOO) <-> @FOO@ => #define FOO | 35 [$6] |
36 [ | 36 )], |
37 eval "$1=\"#define $1\"" | 37 [xs_$1_works="yes"], |
38 AC_SUBST($1) | 38 [xs_$1_works="no"] |
39 ]) | 39 ) |
40 | 40 m4_ifvaln([$2], [CXXFLAGS="$xs_cxxflags_save"])dnl |
41 AC_DEFUN([MY_SUBST_UNDEF], | 41 m4_ifvaln([$3], [LDFLAGS="$xs_ldflags_save"])dnl |
42 dnl Substitute an instance of @$1@ with value "#undef $1". | 42 m4_ifvaln([$4], [LIBS="$xs_libs_save"])dnl |
43 dnl Example: MY_SUBST_UNDEF(FOO) <-> @FOO@ => #undef FOO | 43 ]) |
44 [ | 44 |
45 eval "$1=\"#undef $1\"" | 45 |
46 AC_SUBST($1) | 46 AC_DEFUN([XS_LIB_RESULT], |
47 ]) | 47 [ |
48 | 48 # xs_lib_result ( $1:$2:$3 ) |
49 dnl ------------------------------------------------------------------------- | 49 define([Name], [translit([$1], [a-z], [A-Z])])dnl |
50 dnl Pass C++ compiler options to libtool which supports C only. | 50 if test "x$xs_have_$1" = "xyes"; then |
51 dnl ------------------------------------------------------------------------- | 51 if test "x$xs_$1_cxxflags" != "x" || test "x$xs_$1_ldflags" != "x"; then |
52 | 52 AC_MSG_RESULT([$xs_$1_cxxflags $2 $xs_$1_ldflags $3]) |
53 AC_DEFUN([MY_PROG_LIBTOOL], | 53 else |
54 [ | 54 AC_MSG_RESULT([yes]) |
55 xs_save_cc="$CC" | 55 fi |
56 xs_save_cflags="$CFLAGS" | 56 |
57 CC="$CXX" | 57 Name[]_LIBS="$xs_$1_ldflags $2" |
58 CFLAGS="$CXXFLAGS" | 58 Name[]_CFLAGS="$xs_$1_cxxflags $3" |
59 AM_PROG_LIBTOOL | 59 AC_SUBST(Name[]_LIBS)dnl |
60 CC="$xs_save_cc" | 60 AC_SUBST(Name[]_CFLAGS)dnl |
61 CFLAGS="$xs_save_cflags" | 61 else |
62 ]) | 62 AC_MSG_RESULT([no]) |
63 | 63 fi |
64 dnl ------------------------------------------------------------------------- | 64 ]) |
65 | 65 |
66 AC_DEFUN([MY_TRY_LINK_SAVE], | 66 |
67 [ | 67 AC_DEFUN([XS_PROG_PKGCONFIG], |
68 xs_cxx_save="$CXX" | 68 [ |
69 xs_cxxflags_save="$CXXFLAGS" | 69 AC_PATH_PROG([PKG_CONFIG], [pkg-config])dnl |
70 xs_ldflags_save="$LDFLAGS" | 70 ]) |
71 xs_libs_save="$LIBS" | 71 |
72 ]) | 72 |
73 | 73 AC_DEFUN([XS_ARG_WITH], [dnl |
74 | 74 # xs_arg_with ( $1:$2:$3 ) |
75 AC_DEFUN([MY_TRY_LINK_RESTORE], | 75 define([Name], [translit([$1], [a-z], [A-Z])])dnl |
76 [ | 76 AH_TEMPLATE(HAVE_[]Name, [Define if you have and want to use $2])dnl |
77 CXX="$xs_cxx_save" | 77 AC_ARG_WITH([$1], |
78 CXXFLAGS="$xs_cxxflags_save" | 78 [ --with-$1=PREFIX Enable $2 with install-PREFIX], [dnl |
79 LDFLAGS="$xs_ldflags_save" | 79 if test "x$withval" = "xyes"; then |
80 LIBS="$xs_libs_save" | 80 xs_use_$1="yes" |
81 ]) | 81 xs_$1_library="" |
82 | 82 xs_$1_includes="" |
83 | 83 else |
84 AC_DEFUN([MY_PROG_PKGCONFIG], | 84 if test "x$withval" = "xno"; then |
85 [ | 85 xs_use_$1="no" |
86 AC_PATH_PROG([PKG_CONFIG], [pkg-config]) | 86 else |
87 ]) | 87 xs_use_$1="yes" |
88 | 88 xs_$1_includes="$withval/include" |
89 | 89 xs_$1_library="$withval/lib" |
90 AC_DEFUN([MY_NEED_PKGCONFIG], | 90 fi |
91 [ | 91 fi |
92 AC_REQUIRE([MY_PROG_PKGCONFIG]) | 92 ],[dnl |
93 if test -z "$PKG_CONFIG"; then | 93 xs_use_$1="try" |
94 AC_MSG_ERROR([[pkg-config not found. See http://pkgconfig.sourceforge.net]]) | 94 xs_$1_library="" |
95 fi | 95 xs_$1_includes="" |
96 if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then | 96 ])dnl |
97 AC_MSG_ERROR([[pkg-config too old; version 0.5 or better required.]]) | 97 AC_ARG_WITH([$1-inc], |
98 fi | 98 [ --with-$1-inc=DIR Where the $2 headers are located], |
99 ]) | 99 [xs_$1_includes="$withval"])dnl |
100 AC_ARG_WITH([$1-lib], | |
101 [ --with-$1-lib=DIR Where the $2 library is installed], | |
102 [xs_$1_library="$withval"])dnl | |
103 | |
104 dnl Okay, handle this | |
105 xs_have_$1="no" | |
106 if test "x$xs_use_$1" = "xtry"; then | |
107 $3 | |
108 elif test "x$xs_use_$1" = "xyes"; then | |
109 $3 | |
110 if test "x$xs_have_$1" = "xno"; then | |
111 AC_MSG_ERROR([$2 library and/or headers were not found!]) | |
112 fi | |
113 fi | |
114 ]) | |
115 | |
100 | 116 |
101 dnl ------------------------------------------------------------------------- | 117 dnl ------------------------------------------------------------------------- |
102 dnl Try to find SIDPLAY library and header files. | 118 dnl Try to find SIDPLAY library and header files. |
103 dnl $xs_have_sidplay1 will be "yes" or "no" | 119 dnl $xs_have_sidplay1 will be "yes" or "no" |
104 dnl @SIDPLAY1_LDADD@ will be substituted with linker parameters | 120 dnl @SIDPLAY1_LIBS@ will be substituted with linker parameters |
105 dnl @SIDPLAY1_INCLUDES@ will be substituted with compiler parameters | 121 dnl @SIDPLAY1_INCLUDES@ will be substituted with compiler parameters |
106 dnl ------------------------------------------------------------------------- | 122 dnl ------------------------------------------------------------------------- |
107 | 123 |
108 AC_DEFUN([XS_PATH_LIBSIDPLAY1], | 124 AC_DEFUN([XS_PATH_LIBSIDPLAY1], |
109 [ | 125 [ |
110 AC_MSG_CHECKING([for working SIDPlay1 library and headers]) | 126 AC_MSG_CHECKING([for working SIDPlay1 library and headers]) |
111 | 127 |
112 AC_LANG_PUSH([C++]) | 128 AC_LANG_PUSH([C++]) |
113 | 129 |
114 # Use include path given by user (if any). | 130 dnl Use include path given by user (if any). |
115 if test -n "$xs_sidplay1_includes"; then | 131 if test "x$xs_sidplay1_includes" != "x"; then |
116 xs_sidplay1_cxxflags="-I$xs_sidplay1_includes" | 132 xs_sidplay1_cxxflags="-I$xs_sidplay1_includes" |
117 else | 133 else |
118 xs_sidplay1_cxxflags="" | 134 xs_sidplay1_cxxflags="" |
119 fi | 135 fi |
120 | 136 |
121 # Use library path given by user (if any). | 137 dnl Use library path given by user (if any). |
122 if test -n "$xs_sidplay1_library"; then | 138 if test "x$xs_sidplay1_library" != "x"; then |
123 xs_sidplay1_ldflags="-L$xs_sidplay1_library" | 139 xs_sidplay1_ldflags="-L$xs_sidplay1_library" |
124 else | 140 else |
125 xs_sidplay1_ldflags="" | 141 xs_sidplay1_ldflags="" |
126 fi | 142 fi |
127 | 143 |
128 AC_CACHE_VAL(xs_cv_have_sidplay1, | 144 AC_CACHE_VAL([xs_cv_have_sidplay1], |
129 [ | 145 [ |
130 # Run test compilation with either standard search path | 146 dnl Run test compilation with either standard search path |
131 # or user-defined paths. | 147 dnl or user-defined paths. |
132 MY_TRY_LIBSIDPLAY1 | 148 XS_TRY_LIBSIDPLAY1 |
133 if test "x$xs_sidplay1_works" = "xyes"; then | 149 if test "x$xs_sidplay1_works" = "xyes"; then |
134 xs_cv_have_sidplay1="xs_have_sidplay1=yes \ | 150 xs_cv_have_sidplay1="xs_have_sidplay1=yes \ |
135 xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" \ | 151 xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" \ |
136 xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" " | 152 xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" " |
137 else | 153 else |
138 MY_FIND_LIBSIDPLAY1 | 154 XS_FIND_LIBSIDPLAY1 |
139 fi | 155 fi |
140 ]) | 156 ]) |
141 | |
142 eval "$xs_cv_have_sidplay1" | 157 eval "$xs_cv_have_sidplay1" |
143 | 158 XS_LIB_RESULT([sidplay1], [-lsidplay], []) |
144 if test "x$xs_have_sidplay1" = "xyes"; then | |
145 if test -n "$xs_sidplay1_cxxflags" || test -n "$xs_sidplay1_ldflags"; then | |
146 AC_MSG_RESULT([$xs_sidplay1_cxxflags $xs_sidplay1_ldflags]) | |
147 else | |
148 AC_MSG_RESULT([yes]) | |
149 fi | |
150 | |
151 SIDPLAY1_LDADD="$xs_sidplay1_ldflags -lsidplay" | |
152 SIDPLAY1_INCLUDES="$xs_sidplay1_cxxflags" | |
153 AC_SUBST([SIDPLAY1_LDADD]) | |
154 AC_SUBST([SIDPLAY1_INCLUDES]) | |
155 else | |
156 AC_MSG_RESULT([no]) | |
157 fi | |
158 | |
159 AC_LANG_POP([C++]) | 159 AC_LANG_POP([C++]) |
160 ]) | 160 ]) |
161 | 161 |
162 dnl Functions used by XS_PATH_LIBSIDPLAY1. | 162 dnl Functions used by XS_PATH_LIBSIDPLAY1. |
163 | 163 |
164 AC_DEFUN([MY_FIND_LIBSIDPLAY1], | 164 AC_DEFUN([XS_FIND_LIBSIDPLAY1], |
165 [ | 165 [ |
166 # Search common locations where header files might be stored. | 166 dnl Search common locations where header files might be stored. |
167 xs_sidplay1_incdirs="$xs_sidplay1_includes /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include" | 167 XS_FIND_FILE([xs_sidplay1_includes], [sidplay/sidtune.h], |
168 MY_FIND_FILE(sidplay/sidtune.h, $xs_sidplay1_incdirs, xs_sidplay1_includes) | 168 [$xs_sidplay1_includes /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include]) |
169 | 169 |
170 # Search common locations where library might be stored. | 170 dnl Search common locations where library might be stored. |
171 xs_sidplay1_libdirs="$xs_sidplay1_library /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib" | 171 XS_FIND_FILE([xs_sidplay1_library], |
172 MY_FIND_FILE(libsidplay.a libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37, | 172 [libsidplay.a libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37], |
173 $xs_sidplay1_libdirs, xs_sidplay1_library) | 173 [$xs_sidplay1_library /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib]) |
174 | 174 |
175 if test -z "$xs_sidplay1_includes" || test -z "$xs_sidplay1_library"; then | 175 if test "x$xs_sidplay1_includes" = "x" || test "x$xs_sidplay1_library" = "x"; then |
176 xs_cv_have_sidplay1="xs_have_sidplay1=no \ | 176 xs_cv_have_sidplay1="xs_have_sidplay1=no \ |
177 xs_sidplay1_ldflags=\"\" xs_sidplay1_cxxflags=\"\" " | 177 xs_sidplay1_ldflags=\"\" xs_sidplay1_cxxflags=\"\" " |
178 else | 178 else |
179 # Test compilation with found paths. | 179 dnl Test compilation with found paths. |
180 xs_sidplay1_ldflags="-L$xs_sidplay1_library" | 180 xs_sidplay1_ldflags="-L$xs_sidplay1_library" |
181 xs_sidplay1_cxxflags="-I$xs_sidplay1_includes" | 181 xs_sidplay1_cxxflags="-I$xs_sidplay1_includes" |
182 MY_TRY_LIBSIDPLAY1 | 182 XS_TRY_LIBSIDPLAY1 |
183 xs_cv_have_sidplay1="xs_have_sidplay1=$xs_sidplay1_works \ | 183 xs_cv_have_sidplay1="xs_have_sidplay1=$xs_sidplay1_works \ |
184 xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" \ | 184 xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" \ |
185 xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" " | 185 xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" " |
186 fi | 186 fi |
187 ]) | 187 ]) |
188 | 188 |
189 AC_DEFUN([MY_TRY_LIBSIDPLAY1], | 189 AC_DEFUN([XS_TRY_LIBSIDPLAY1],[ |
190 [ | 190 XS_TRY_LIBRARY([sidplay1], [$xs_sidplay1_cxxflags], [$xs_sidplay1_ldflags], |
191 MY_TRY_LINK_SAVE | 191 [sidplay], [sidplay/sidtune.h], [sidTune* myTest = new sidTune(0);]) |
192 | |
193 CXXFLAGS="$CXXFLAGS $xs_sidplay1_cxxflags" | |
194 LDFLAGS="$LDFLAGS $xs_sidplay1_ldflags" | |
195 LIBS="$LIBS -lsidplay" | |
196 | |
197 AC_LINK_IFELSE([AC_LANG_PROGRAM( | |
198 [[#include <sidplay/sidtune.h>]], | |
199 [[sidTune* myTest = new sidTune(0);]])], | |
200 [xs_sidplay1_works=yes], | |
201 [xs_sidplay1_works=no] | |
202 ) | |
203 | |
204 MY_TRY_LINK_RESTORE | |
205 ]) | 192 ]) |
206 | 193 |
207 | 194 |
208 dnl ------------------------------------------------------------------------- | 195 dnl ------------------------------------------------------------------------- |
209 dnl Try to find SIDPLAY2 library and header files. | 196 dnl Try to find SIDPLAY2 library and header files. |
210 dnl $xs_have_sidplay2 will be "yes" or "no" | 197 dnl $xs_have_sidplay2 will be "yes" or "no" |
211 dnl @SIDPLAY_LDADD@ will be substituted with linker parameters | 198 dnl @SIDPLAY_LIBS@ will be substituted with linker parameters |
212 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters | 199 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters |
213 dnl ------------------------------------------------------------------------- | 200 dnl ------------------------------------------------------------------------- |
214 AC_DEFUN([XS_PATH_LIBSIDPLAY2], | 201 AC_DEFUN([XS_PATH_LIBSIDPLAY2], |
215 [ | 202 [ |
216 AC_MSG_CHECKING([for working SIDPlay2 library and headers]) | 203 AC_MSG_CHECKING([for working SIDPlay2 library and headers]) |
217 | 204 |
218 AC_LANG_PUSH([C++]) | 205 AC_LANG_PUSH([C++]) |
219 | 206 |
220 AC_REQUIRE([MY_PROG_PKGCONFIG]) | 207 AC_REQUIRE([XS_PROG_PKGCONFIG]) |
221 if test -n "$PKG_CONFIG" && $PKG_CONFIG --atleast-version $LIBSIDPLAY2_REQUIRED_VERSION libsidplay2; then | 208 if test "x$PKG_CONFIG" != "x" && $PKG_CONFIG --atleast-version m4_ifval([$1], [$1], [2.1.0]) libsidplay2; then |
222 xs_pkgcfg_knows=yes | 209 xs_pkgcfg_knows="yes" |
223 else | 210 else |
224 xs_pkgcfg_knows=no | 211 xs_pkgcfg_knows="no" |
225 fi | 212 fi |
226 | 213 |
227 # Derive sidbuilders path from libsidplay2 root. | 214 dnl Derive sidbuilders path from libsidplay2 root. |
228 if test -n "$xs_sidplay2_library"; then | 215 if test "x$xs_sidplay2_library" != "x"; then |
229 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders" | 216 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders" |
230 elif test "x$xs_pkgcfg_knows" = "xyes" ; then | 217 elif test "x$xs_pkgcfg_knows" = "xyes" ; then |
231 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` | 218 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` |
232 fi | 219 fi |
233 | 220 |
234 AC_CACHE_VAL(xs_cv_have_sidplay2, | 221 AC_CACHE_VAL([xs_cv_have_sidplay2], |
235 [ | 222 [ |
236 # Run test compilation with either standard search path | 223 dnl Run test compilation with either standard search path |
237 # or user-defined paths. | 224 dnl or user-defined paths. |
238 xs_sidplay2_ldadd="-lsidplay2" | 225 xs_sidplay2_ldflags="-lsidplay2" |
239 MY_TRY_LIBSIDPLAY2 | 226 XS_TRY_LIBSIDPLAY2 |
240 if test "x$xs_sidplay2_works" = "xyes"; then | 227 if test "x$xs_sidplay2_works" = "xyes"; then |
241 xs_cv_have_sidplay2="xs_have_sidplay2=yes \ | 228 xs_cv_have_sidplay2="xs_have_sidplay2=yes \ |
242 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \ | 229 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \ |
243 xs_sidplay2_ldadd=\"$xs_sidplay2_ldadd\" \ | 230 xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\" \ |
244 xs_sidplay2_builders=\"$xs_sidplay2_builders\" " | 231 xs_sidplay2_builders=\"$xs_sidplay2_builders\" " |
245 else | 232 else |
246 MY_FIND_LIBSIDPLAY2 | 233 XS_FIND_LIBSIDPLAY2 |
247 fi | 234 fi |
248 ]) | 235 ]) |
249 eval "$xs_cv_have_sidplay2" | 236 eval "$xs_cv_have_sidplay2" |
250 if test "x$xs_have_sidplay2" = "xyes"; then | 237 XS_LIB_RESULT([sidplay2], [], []) |
251 if test -n "$xs_sidplay2_cxxflags" || test -n "$xs_sidplay2_ldadd"; then | |
252 AC_MSG_RESULT([$xs_sidplay2_cxxflags $xs_sidplay2_ldadd]) | |
253 else | |
254 AC_MSG_RESULT([yes]) | |
255 fi | |
256 | |
257 SIDPLAY2_LDADD="$xs_sidplay2_ldadd" | |
258 SIDPLAY2_INCLUDES="$xs_sidplay2_cxxflags" | |
259 AC_SUBST([SIDPLAY2_LDADD]) | |
260 AC_SUBST([SIDPLAY2_INCLUDES]) | |
261 else | |
262 AC_MSG_RESULT([no]) | |
263 fi | |
264 | |
265 AC_LANG_POP([C++]) | 238 AC_LANG_POP([C++]) |
266 ]) | 239 ]) |
267 | 240 |
268 | 241 |
269 dnl Functions used by XS_PATH_LIBSIDPLAY2. | 242 dnl Functions used by XS_PATH_LIBSIDPLAY2. |
270 AC_DEFUN([MY_FIND_LIBSIDPLAY2], | 243 AC_DEFUN([XS_FIND_LIBSIDPLAY2], |
271 [ | 244 [ |
272 # See whether user didn't provide paths. | 245 dnl See whether user didn't provide paths. |
273 if test -z "$xs_sidplay2_includes"; then | 246 if test "x$xs_sidplay2_includes" = "x"; then |
274 if test "x$xs_pkgcfg_knows" = "xyes" ; then | 247 if test "x$xs_pkgcfg_knows" = "xyes" ; then |
275 xs_sidplay2_includes=`$PKG_CONFIG --variable=includedir libsidplay2` | 248 xs_sidplay2_includes=`$PKG_CONFIG --variable=includedir libsidplay2` |
276 xs_sidplay2_cxxflags=`$PKG_CONFIG --cflags libsidplay2` | 249 xs_sidplay2_cxxflags=`$PKG_CONFIG --cflags libsidplay2` |
277 else | 250 else |
278 # Search common locations where header files might be stored. | 251 dnl Search common locations where header files might be stored. |
279 xs_sidplay2_incdirs="$xs_sidplay2_includes $xs_sidplay2_includes/include /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include" | 252 XS_FIND_FILE([xs_sidplay2_includes], [sidplay/sidplay2.h], |
280 MY_FIND_FILE(sidplay/sidplay2.h,$xs_sidplay2_incdirs,xs_sidplay2_includes) | 253 [$xs_sidplay2_includes $xs_sidplay2_includes/include /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include]) |
281 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes" | 254 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes" |
282 fi | 255 fi |
283 else | 256 else |
284 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes" | 257 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes" |
285 fi | 258 fi |
286 if test -z "$xs_sidplay2_library"; then | 259 if test "x$xs_sidplay2_library" = "x"; then |
287 if test "x$xs_pkgcfg_knows" = "xyes" ; then | 260 if test "x$xs_pkgcfg_knows" = "xyes" ; then |
288 xs_sidplay2_library=`$PKG_CONFIG --variable=libdir libsidplay2` | 261 xs_sidplay2_library=`$PKG_CONFIG --variable=libdir libsidplay2` |
289 xs_sidplay2_ldadd=`$PKG_CONFIG --libs libsidplay2` | 262 xs_sidplay2_ldflags=`$PKG_CONFIG --libs libsidplay2` |
290 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` | 263 xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` |
291 else | 264 else |
292 # Search common locations where library might be stored. | 265 dnl Search common locations where library might be stored. |
293 xs_sidplay2_libdirs="$xs_sidplay2_library $xs_sidplay2_library/lib $xs_sidplay2_library/src /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib" | 266 XS_FIND_FILE([xs_sidplay2_library], [libsidplay2.la], |
294 MY_FIND_FILE(libsidplay2.la,$xs_sidplay2_libdirs,xs_sidplay2_library) | 267 [$xs_sidplay2_library $xs_sidplay2_library/lib $xs_sidplay2_library/src /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib]) |
295 xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2" | 268 xs_sidplay2_ldflags="-L$xs_sidplay2_library -lsidplay2" |
296 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders" | 269 xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders" |
297 fi | 270 fi |
298 else | 271 else |
299 xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2" | 272 xs_sidplay2_ldflags="-L$xs_sidplay2_library -lsidplay2" |
300 fi | 273 fi |
301 if test -z "$xs_sidplay2_includes" || test -z "$xs_sidplay2_library"; then | 274 if test "x$xs_sidplay2_includes" = "x" || test "x$xs_sidplay2_library" = "x"; then |
302 xs_cv_have_sidplay2="xs_have_sidplay2=no \ | 275 xs_cv_have_sidplay2="xs_have_sidplay2=no \ |
303 xs_sidplay2_ldadd=\"\" xs_sidplay2_cxxflags=\"\" \ | 276 xs_sidplay2_ldflags=\"\" xs_sidplay2_cxxflags=\"\" \ |
304 xs_sidplay2_builders=\"\" " | 277 xs_sidplay2_builders=\"\" " |
305 else | 278 else |
306 # Test compilation with found paths. | 279 dnl Test compilation with found paths. |
307 xs_sidplay2_ldadd="-L$xs_sidplay2_library -lsidplay2" | 280 xs_sidplay2_ldflags="-L$xs_sidplay2_library -lsidplay2" |
308 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes" | 281 xs_sidplay2_cxxflags="-I$xs_sidplay2_includes" |
309 MY_TRY_LIBSIDPLAY2 | 282 XS_TRY_LIBSIDPLAY2 |
310 xs_cv_have_sidplay2="xs_have_sidplay2=$xs_sidplay2_works \ | 283 xs_cv_have_sidplay2="xs_have_sidplay2=$xs_sidplay2_works \ |
311 xs_sidplay2_ldadd=\"$xs_sidplay2_ldadd\" \ | 284 xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\" \ |
312 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \ | 285 xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \ |
313 xs_sidplay2_builders=\"$xs_sidplay2_builders\" " | 286 xs_sidplay2_builders=\"$xs_sidplay2_builders\" " |
314 fi | 287 fi |
315 ]) | 288 ]) |
316 | 289 |
317 | 290 |
318 AC_DEFUN([MY_TRY_LIBSIDPLAY2], | 291 AC_DEFUN([XS_TRY_LIBSIDPLAY2], |
319 [ | 292 [ |
320 MY_TRY_LINK_SAVE | 293 XS_TRY_LIBRARY([sidplay2], |
321 | 294 [$xs_sidplay2_cxxflags -DHAVE_UNIX], [$xs_sidplay2_ldflags], |
322 CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX" | 295 [sidplay2], [sidplay/sidplay2.h], [sidplay2 *myEngine;]) |
323 CXXFLAGS="$CXXFLAGS $xs_sidplay2_cxxflags -DHAVE_UNIX" | |
324 LDFLAGS="$LDFLAGS $xs_sidplay2_ldadd" | |
325 | |
326 AC_LINK_IFELSE([AC_LANG_PROGRAM( | |
327 [[#include <sidplay/sidplay2.h>]], | |
328 [[sidplay2 *myEngine;]])], | |
329 [xs_sidplay2_works=yes], | |
330 [xs_sidplay2_works=no] | |
331 ) | |
332 | |
333 MY_TRY_LINK_RESTORE | |
334 ]) | 296 ]) |
335 | 297 |
336 | 298 |
337 dnl ------------------------------------------------------------------------- | 299 dnl ------------------------------------------------------------------------- |
338 dnl Find libsidplay2 builders (sidbuilders) dir. | 300 dnl Find libsidplay2 builders (sidbuilders) dir. |
339 dnl @BUILDERS_INCLUDES@ | 301 dnl @BUILDERS_CFLAGS@ |
340 dnl @BUILDERS_LDFLAGS@ | 302 dnl @BUILDERS_LDFLAGS@ |
341 dnl ------------------------------------------------------------------------- | 303 dnl ------------------------------------------------------------------------- |
342 AC_DEFUN([BUILDERS_FIND], | 304 AC_DEFUN([XS_BUILDERS_CHECK], |
343 [ | 305 [ |
344 AC_MSG_CHECKING([for SIDPlay2 builders directory]) | 306 AC_MSG_CHECKING([for SIDPlay2 builders directory]) |
345 | 307 AC_LANG_ASSERT([C++]) |
346 AC_LANG_PUSH([C++]) | |
347 | |
348 AC_REQUIRE([XS_PATH_LIBSIDPLAY2]) | 308 AC_REQUIRE([XS_PATH_LIBSIDPLAY2]) |
349 | 309 |
350 dnl Be pessimistic. | 310 dnl Be pessimistic. |
351 builders_available=no | 311 builders_available="no" |
352 | 312 |
353 dnl Sidbuilder headers are included with "builders" prefix. | 313 dnl Sidbuilder headers are included with "builders" prefix. |
354 builders_includedir=$xs_sidplay2_includes | 314 builders_includedir="$xs_sidplay2_includes" |
355 builders_libdir=$xs_sidplay2_builders | 315 builders_libdir="$xs_sidplay2_builders" |
356 | 316 |
357 dnl If libsidplay2 is in standard library search path, we need | 317 dnl If libsidplay2 is in standard library search path, we need |
358 dnl to get an argument whether /usr, /usr/local, etc. Else we | 318 dnl to get an argument whether /usr, /usr/local, etc. Else we |
359 dnl can only use ${libdir}/sidplay/builders, but then are | 319 dnl can only use ${libdir}/sidplay/builders, but then are |
360 dnl unable to check whether files exist as long as ${exec_prefix} | 320 dnl unable to check whether files exist as long as ${exec_prefix} |
361 dnl is not defined in the configure script. So, this is a bit | 321 dnl is not defined in the configure script. So, this is a bit |
362 dnl ugly, but a satisfactory fallback default for those who | 322 dnl ugly, but a satisfactory fallback default for those who |
363 dnl define ${prefix} and ${exec_prefix}. | 323 dnl define ${prefix} and ${exec_prefix}. |
364 if test -z $builders_libdir; then | 324 if test "x$builders_libdir" = "x"; then |
365 eval "builders_libdir=$libdir/sidplay/builders" | 325 eval "builders_libdir=$libdir/sidplay/builders" |
366 fi | 326 fi |
367 | 327 |
368 AC_ARG_WITH(sidbuilders, | 328 AC_ARG_WITH([sidbuilders], |
369 [ --with-sidbuilders=DIR what the SIDPlay2 builders install PREFIX is], | 329 [ --with-sidbuilders=DIR what the SIDPlay2 builders install PREFIX is], |
370 [builders_includedir="$withval/include" | 330 [builders_includedir="$withval/include" |
371 builders_libdir="$withval/lib/sidplay/builders"]) | 331 builders_libdir="$withval/lib/sidplay/builders"]) |
372 | 332 |
373 AC_ARG_WITH(builders-inc, | 333 AC_ARG_WITH([builders-inc], |
374 [ --with-builders-inc=DIR where the SIDPlay2 builders headers are located], | 334 [ --with-builders-inc=DIR where the SIDPlay2 builders headers are located], |
375 [builders_includedir="$withval"]) | 335 [builders_includedir="$withval"]) |
376 | 336 |
377 AC_ARG_WITH(builders-lib, | 337 AC_ARG_WITH([builders-lib], |
378 [ --with-builders-lib=DIR where the SIDPlay2 builders libraries are installed], | 338 [ --with-builders-lib=DIR where the SIDPlay2 builders libraries are installed], |
379 [builders_libdir="$withval"]) | 339 [builders_libdir="$withval"]) |
380 | 340 |
381 if test -n "$builders_includedir"; then | 341 if test "x$builders_includedir" != "x"; then |
382 BUILDERS_INCLUDES="-I$builders_includedir" | 342 BUILDERS_CFLAGS="-I$builders_includedir" |
383 fi | 343 fi |
384 | 344 |
385 if test -n "$builders_libdir"; then | 345 if test "x$builders_libdir" != "x"; then |
386 BUILDERS_LDFLAGS="-L$builders_libdir" | 346 BUILDERS_LDFLAGS="-L$builders_libdir" |
387 fi | 347 fi |
388 | 348 |
389 if test -d "$builders_libdir"; then | 349 if test -d "$builders_libdir"; then |
390 xs_have_sidbuilders_dir=yes | 350 xs_have_sidbuilders_dir="yes" |
391 AC_MSG_RESULT([$builders_libdir]) | 351 AC_MSG_RESULT([$builders_libdir]) |
392 else | 352 else |
393 xs_have_sidbuilders_dir=no | 353 xs_have_sidbuilders_dir="no" |
394 AC_MSG_RESULT([$xs_have_sidbuilders_dir]) | 354 AC_MSG_RESULT([$xs_have_sidbuilders_dir]) |
395 AC_MSG_ERROR([$builders_libdir not found! | 355 AC_MSG_ERROR([$builders_libdir not found! |
396 Check --help on how to specify SIDPlay2 and/or builders library and | 356 Check --help on how to specify SIDPlay2 and/or builders library and |
397 header path, or set --exec-prefix to the same prefix as your installation | 357 header path, or set --exec-prefix to the same prefix as your installation |
398 of libsidplay2. | 358 of libsidplay2. |
399 ]) | 359 ]) |
400 fi | 360 fi |
401 | 361 |
402 AC_SUBST([BUILDERS_INCLUDES]) | 362 AC_SUBST([BUILDERS_CFLAGS]) |
403 AC_SUBST([BUILDERS_LDFLAGS]) | 363 AC_SUBST([BUILDERS_LDFLAGS]) |
404 | 364 ]) |
405 AC_LANG_POP([C++]) | 365 |
406 ]) | 366 |
407 | 367 dnl ------------------------------------------------------------------------- |
408 | 368 dnl Test for working builders |
409 dnl ------------------------------------------------------------------------- | 369 dnl ------------------------------------------------------------------------- |
410 dnl Test for working reSID builder. | 370 AC_DEFUN([XS_BUILDERS_FIND], [dnl |
411 dnl sets $(RESID_LDADD), substitutes @RESID_LDADD@ | 371 define([Name], [translit([$1], [a-z], [A-Z])])dnl |
412 dnl ------------------------------------------------------------------------- | 372 AH_TEMPLATE(HAVE_[]Name[]_BUILDER, [Define if you have $1 for libSIDPlay 2]) |
413 AC_DEFUN([BUILDERS_FIND_RESID], | 373 AC_MSG_CHECKING([for $1 builder module]) |
414 [ | 374 XS_TRY_LIBRARY([builders], [$BUILDERS_CFLAGS], [$BUILDERS_LDFLAGS], |
415 AC_MSG_CHECKING([for reSID builder module]) | 375 [$2], [sidplay/builders/$3], [$4 *sid;]) |
416 AC_LANG_PUSH([C++]) | 376 if test "x$xs_builders_works" = "xyes"; then |
417 MY_TRY_LINK_SAVE | 377 xs_builders_available="yes" |
418 | 378 xs_builders="$1 $xs_builders" |
419 CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX" | 379 AC_DEFINE(HAVE_[]Name[]_BUILDER) |
420 CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES" | 380 BUILDERS_LIBS="$BUILDERS_LIBS -l$2" |
421 LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS" | 381 fi |
422 LIBS="$LIBS -lresid-builder" | 382 AC_MSG_RESULT([$xs_builders_works]) |
423 | 383 AC_SUBST([BUILDERS_LIBS]) |
424 AC_LINK_IFELSE([AC_LANG_PROGRAM( | 384 ]) |
425 [[#include <sidplay/builders/resid.h>]], | |
426 [[ReSIDBuilder *sid;]])], | |
427 [builders_work=yes], | |
428 [builders_work=no] | |
429 ) | |
430 | |
431 MY_TRY_LINK_RESTORE | |
432 | |
433 if test "x$builders_work" = "xyes"; then | |
434 builders_available=yes | |
435 xs_builders="reSID $xs_builders" | |
436 AC_DEFINE(HAVE_RESID_BUILDER) | |
437 RESID_LDADD="-lresid-builder" | |
438 fi | |
439 AC_MSG_RESULT($builders_work) | |
440 AC_SUBST([RESID_LDADD]) | |
441 AC_LANG_POP([C++]) | |
442 ]) | |
443 | |
444 | |
445 dnl ------------------------------------------------------------------------- | |
446 dnl Test for working HardSID builder. | |
447 dnl sets $(HARDSID_LDADD), substitutes @HARDSID_LDADD@ | |
448 dnl ------------------------------------------------------------------------- | |
449 AC_DEFUN([BUILDERS_FIND_HARDSID], | |
450 [ | |
451 AC_MSG_CHECKING([for HardSID builder module]) | |
452 AC_LANG_PUSH([C++]) | |
453 MY_TRY_LINK_SAVE | |
454 | |
455 CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX" | |
456 CXXFLAGS="$CXXFLAGS $BUILDERS_INCLUDES" | |
457 LDFLAGS="$LDFLAGS $BUILDERS_LDFLAGS" | |
458 LIBS="$LIBS -lhardsid-builder" | |
459 | |
460 AC_LINK_IFELSE([AC_LANG_PROGRAM( | |
461 [[#include <sidplay/builders/hardsid.h>]], | |
462 [[HardSID *sid;]])], | |
463 [builders_work=yes], | |
464 [builders_work=no] | |
465 ) | |
466 | |
467 MY_TRY_LINK_RESTORE | |
468 | |
469 if test "x$builders_work" = "xyes"; then | |
470 builders_available=yes | |
471 xs_builders="HardSID $xs_builders" | |
472 AC_DEFINE(HAVE_HARDSID_BUILDER) | |
473 HARDSID_LDADD="-lhardsid-builder" | |
474 fi | |
475 AC_MSG_RESULT($builders_work) | |
476 AC_SUBST([HARDSID_LDADD]) | |
477 AC_LANG_POP([C++]) | |
478 ]) | |
479 | |
480 |