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