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