1 # Configure paths for libmikmod
3 # Derived from glib.m4 (Owen Taylor 97-11-3)
4 # Improved by Chris Butler
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
11 AC_DEFUN([AM_PATH_LIBMIKMOD],
13 dnl Get the cflags and libraries from the libmikmod-config script
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)
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
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
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)
39 if test "$LIBMIKMOD_CONFIG" = "no" ; then
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"
56 CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS $LIBMIKMOD_LDADD"
57 LIBS="$LIBMIKMOD_LIBS $LIBS"
59 dnl Now check if the installed libmikmod is sufficiently new. (Also sanity
60 dnl checks the results of libmikmod-config to some extent
68 char* my_strdup (char *str)
73 new_str = malloc ((strlen (str) + 1) * sizeof(char));
74 strcpy (new_str, str);
83 int major,minor,micro;
84 int libmikmod_major_version,libmikmod_minor_version,libmikmod_micro_version;
87 system("touch conf.mikmodtest");
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");
96 libmikmod_major_version=(MikMod_GetVersion() >> 16) & 255;
97 libmikmod_minor_version=(MikMod_GetVersion() >> 8) & 255;
98 libmikmod_micro_version=(MikMod_GetVersion() ) & 255;
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))
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");
116 else if ((libmikmod_major_version != LIBMIKMOD_VERSION_MAJOR) ||
117 (libmikmod_minor_version != LIBMIKMOD_VERSION_MINOR) ||
118 (libmikmod_micro_version != LIBMIKMOD_REVISION))
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);
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)))
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);
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");
151 ],, no_libmikmod=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
152 CFLAGS="$ac_save_CFLAGS"
157 if test "x$no_libmikmod" = x ; then
158 AC_MSG_RESULT([yes, `$LIBMIKMOD_CONFIG --version`])
159 ifelse([$2], , :, [$2])
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."
168 if test -f conf.mikmodtest ; then
171 echo "*** Could not run libmikmod test program, checking why..."
172 CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS"
173 LIBS="$LIBS $LIBMIKMOD_LIBS"
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."
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"
201 ifelse([$3], , :, [$3])
203 AC_SUBST(LIBMIKMOD_CFLAGS)
204 AC_SUBST(LIBMIKMOD_LIBS)
205 AC_SUBST(LIBMIKMOD_LDADD)
206 rm -f conf.mikmodtest