Contents of /trunk/xmms/gentoo-m4/libmikmod.m4
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 5 months ago) by niro
File size: 9201 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 5 months ago) by niro
File size: 9201 byte(s)
-import
1 | # Configure paths for libmikmod |
2 | # |
3 | # Derived from glib.m4 (Owen Taylor 97-11-3) |
4 | # Improved by Chris Butler |
5 | # |
6 | |
7 | dnl AM_PATH_LIBMIKMOD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) |
8 | dnl Test for libmikmod, and define LIBMIKMOD_CFLAGS, LIBMIKMOD_LIBS and |
9 | dnl LIBMIKMOD_LDADD |
10 | dnl |
11 | AC_DEFUN(AM_PATH_LIBMIKMOD, |
12 | [dnl |
13 | dnl Get the cflags and libraries from the libmikmod-config script |
14 | dnl |
15 | AC_ARG_WITH(libmikmod-prefix,[ --with-libmikmod-prefix=PFX Prefix where libmikmod is installed (optional)], |
16 | libmikmod_config_prefix="$withval", libmikmod_config_prefix="") |
17 | AC_ARG_WITH(libmikmod-exec-prefix,[ --with-libmikmod-exec-prefix=PFX Exec prefix where libmikmod is installed (optional)], |
18 | libmikmod_config_exec_prefix="$withval", libmikmod_config_exec_prefix="") |
19 | AC_ARG_ENABLE(libmikmodtest, [ --disable-libmikmodtest Do not try to compile and run a test libmikmod program], |
20 | , enable_libmikmodtest=yes) |
21 | |
22 | if test x$libmikmod_config_exec_prefix != x ; then |
23 | libmikmod_config_args="$libmikmod_config_args --exec-prefix=$libmikmod_config_exec_prefix" |
24 | if test x${LIBMIKMOD_CONFIG+set} != xset ; then |
25 | LIBMIKMOD_CONFIG=$libmikmod_config_exec_prefix/bin/libmikmod-config |
26 | fi |
27 | fi |
28 | if test x$libmikmod_config_prefix != x ; then |
29 | libmikmod_config_args="$libmikmod_config_args --prefix=$libmikmod_config_prefix" |
30 | if test x${LIBMIKMOD_CONFIG+set} != xset ; then |
31 | LIBMIKMOD_CONFIG=$libmikmod_config_prefix/bin/libmikmod-config |
32 | fi |
33 | fi |
34 | |
35 | AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no) |
36 | min_libmikmod_version=ifelse([$1], ,3.1.5,$1) |
37 | AC_MSG_CHECKING(for libmikmod - version >= $min_libmikmod_version) |
38 | no_libmikmod="" |
39 | if test "$LIBMIKMOD_CONFIG" = "no" ; then |
40 | no_libmikmod=yes |
41 | else |
42 | LIBMIKMOD_CFLAGS=`$LIBMIKMOD_CONFIG $libmikmod_config_args --cflags` |
43 | LIBMIKMOD_LIBS=`$LIBMIKMOD_CONFIG $libmikmod_config_args --libs` |
44 | LIBMIKMOD_LDADD=`$LIBMIKMOD_CONFIG $libmikmod_config_args --ldadd` |
45 | libmikmod_config_major_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \ |
46 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\1/'` |
47 | libmikmod_config_minor_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \ |
48 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\2/'` |
49 | libmikmod_config_micro_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \ |
50 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'` |
51 | if test "x$enable_libmikmodtest" = "xyes" ; then |
52 | ac_save_CFLAGS="$CFLAGS" |
53 | ac_save_LIBS="$LIBS" |
54 | AC_LANG_SAVE |
55 | AC_LANG_C |
56 | CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS $LIBMIKMOD_LDADD" |
57 | LIBS="$LIBMIKMOD_LIBS $LIBS" |
58 | dnl |
59 | dnl Now check if the installed libmikmod is sufficiently new. (Also sanity |
60 | dnl checks the results of libmikmod-config to some extent |
61 | dnl |
62 | rm -f conf.mikmodtest |
63 | AC_TRY_RUN([ |
64 | #include <mikmod.h> |
65 | #include <stdio.h> |
66 | #include <stdlib.h> |
67 | |
68 | char* my_strdup (char *str) |
69 | { |
70 | char *new_str; |
71 | |
72 | if (str) { |
73 | new_str = malloc ((strlen (str) + 1) * sizeof(char)); |
74 | strcpy (new_str, str); |
75 | } else |
76 | new_str = NULL; |
77 | |
78 | return new_str; |
79 | } |
80 | |
81 | int main() |
82 | { |
83 | int major,minor,micro; |
84 | int libmikmod_major_version,libmikmod_minor_version,libmikmod_micro_version; |
85 | char *tmp_version; |
86 | |
87 | system("touch conf.mikmodtest"); |
88 | |
89 | /* HP/UX 9 (%@#!) writes to sscanf strings */ |
90 | tmp_version = my_strdup("$min_libmikmod_version"); |
91 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { |
92 | printf("%s, bad version string\n", "$min_libmikmod_version"); |
93 | exit(1); |
94 | } |
95 | |
96 | libmikmod_major_version=(MikMod_GetVersion() >> 16) & 255; |
97 | libmikmod_minor_version=(MikMod_GetVersion() >> 8) & 255; |
98 | libmikmod_micro_version=(MikMod_GetVersion() ) & 255; |
99 | |
100 | if ((libmikmod_major_version != $libmikmod_config_major_version) || |
101 | (libmikmod_minor_version != $libmikmod_config_minor_version) || |
102 | (libmikmod_micro_version != $libmikmod_config_micro_version)) |
103 | { |
104 | printf("\n*** 'libmikmod-config --version' returned %d.%d.%d, but libmikmod (%d.%d.%d)\n", |
105 | $libmikmod_config_major_version, $libmikmod_config_minor_version, $libmikmod_config_micro_version, |
106 | libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version); |
107 | printf ("*** was found! If libmikmod-config was correct, then it is best\n"); |
108 | printf ("*** to remove the old version of libmikmod. You may also be able to fix the error\n"); |
109 | printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); |
110 | printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); |
111 | printf("*** required on your system.\n"); |
112 | printf("*** If libmikmod-config was wrong, set the environment variable LIBMIKMOD_CONFIG\n"); |
113 | printf("*** to point to the correct copy of libmikmod-config, and remove the file config.cache\n"); |
114 | printf("*** before re-running configure\n"); |
115 | } |
116 | else if ((libmikmod_major_version != LIBMIKMOD_VERSION_MAJOR) || |
117 | (libmikmod_minor_version != LIBMIKMOD_VERSION_MINOR) || |
118 | (libmikmod_micro_version != LIBMIKMOD_REVISION)) |
119 | { |
120 | printf("*** libmikmod header files (version %d.%d.%d) do not match\n", |
121 | LIBMIKMOD_VERSION_MAJOR, LIBMIKMOD_VERSION_MINOR, LIBMIKMOD_REVISION); |
122 | printf("*** library (version %d.%d.%d)\n", |
123 | libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version); |
124 | } |
125 | else |
126 | { |
127 | if ((libmikmod_major_version > major) || |
128 | ((libmikmod_major_version == major) && (libmikmod_minor_version > minor)) || |
129 | ((libmikmod_major_version == major) && (libmikmod_minor_version == minor) && (libmikmod_micro_version >= micro))) |
130 | { |
131 | return 0; |
132 | } |
133 | else |
134 | { |
135 | printf("\n*** An old version of libmikmod (%d.%d.%d) was found.\n", |
136 | libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version); |
137 | printf("*** You need a version of libmikmod newer than %d.%d.%d.\n", |
138 | major, minor, micro); |
139 | printf("***\n"); |
140 | printf("*** If you have already installed a sufficiently new version, this error\n"); |
141 | printf("*** probably means that the wrong copy of the libmikmod-config shell script is\n"); |
142 | printf("*** being found. The easiest way to fix this is to remove the old version\n"); |
143 | printf("*** of libmikmod, but you can also set the LIBMIKMOD_CONFIG environment to point to the\n"); |
144 | printf("*** correct copy of libmikmod-config. (In this case, you will have to\n"); |
145 | printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); |
146 | printf("*** so that the correct libraries are found at run-time))\n"); |
147 | } |
148 | } |
149 | return 1; |
150 | } |
151 | ],, no_libmikmod=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
152 | CFLAGS="$ac_save_CFLAGS" |
153 | LIBS="$ac_save_LIBS" |
154 | AC_LANG_RESTORE |
155 | fi |
156 | fi |
157 | if test "x$no_libmikmod" = x ; then |
158 | AC_MSG_RESULT([yes, `$LIBMIKMOD_CONFIG --version`]) |
159 | ifelse([$2], , :, [$2]) |
160 | else |
161 | AC_MSG_RESULT(no) |
162 | if test "$LIBMIKMOD_CONFIG" = "no" ; then |
163 | echo "*** The libmikmod-config script installed by libmikmod could not be found" |
164 | echo "*** If libmikmod was installed in PREFIX, make sure PREFIX/bin is in" |
165 | echo "*** your path, or set the LIBMIKMOD_CONFIG environment variable to the" |
166 | echo "*** full path to libmikmod-config." |
167 | else |
168 | if test -f conf.mikmodtest ; then |
169 | : |
170 | else |
171 | echo "*** Could not run libmikmod test program, checking why..." |
172 | CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS" |
173 | LIBS="$LIBS $LIBMIKMOD_LIBS" |
174 | AC_LANG_SAVE |
175 | AC_LANG_C |
176 | AC_TRY_LINK([ |
177 | #include <mikmod.h> |
178 | #include <stdio.h> |
179 | ], [ return (MikMod_GetVersion()!=0); ], |
180 | [ echo "*** The test program compiled, but did not run. This usually means" |
181 | echo "*** that the run-time linker is not finding libmikmod or finding the wrong" |
182 | echo "*** version of libmikmod. If it is not finding libmikmod, you'll need to set your" |
183 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
184 | echo "*** to the installed location. Also, make sure you have run ldconfig if that" |
185 | echo "*** is required on your system." |
186 | echo "***" |
187 | echo "*** If you have an old version installed, it is best to remove it, although" |
188 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], |
189 | [ echo "*** The test program failed to compile or link. See the file config.log for the" |
190 | echo "*** exact error that occured. This usually means libmikmod was incorrectly installed" |
191 | echo "*** or that you have moved libmikmod since it was installed. In the latter case, you" |
192 | echo "*** may want to edit the libmikmod-config script: $LIBMIKMOD_CONFIG" ]) |
193 | CFLAGS="$ac_save_CFLAGS" |
194 | LIBS="$ac_save_LIBS" |
195 | AC_LANG_RESTORE |
196 | fi |
197 | fi |
198 | LIBMIKMOD_CFLAGS="" |
199 | LIBMIKMOD_LIBS="" |
200 | LIBMIKMOD_LDADD="" |
201 | ifelse([$3], , :, [$3]) |
202 | fi |
203 | AC_SUBST(LIBMIKMOD_CFLAGS) |
204 | AC_SUBST(LIBMIKMOD_LIBS) |
205 | AC_SUBST(LIBMIKMOD_LDADD) |
206 | rm -f conf.mikmodtest |
207 | ]) |