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,
16 AC_HELP_STRING([--with-libmikmod-prefix=PFX],
17 [prefix where libmikmod is installed (optional)]),
18 libmikmod_config_prefix="$withval", libmikmod_config_prefix="")
20 AC_ARG_WITH(libmikmod-exec-prefix,
21 AC_HELP_STRING([--with-libmikmod-exec-prefix=PFX],
22 [exec prefix where libmikmod is installed (optional)]),
23 libmikmod_config_exec_prefix="$withval", libmikmod_config_exec_prefix="")
25 AC_ARG_ENABLE(libmikmodtest,
26 AC_HELP_STRING([--disable-libmikmodtest],
27 [Do not try to compile and run a test libmikmod program]),
28 , enable_libmikmodtest=yes)
30 if test x$libmikmod_config_exec_prefix != x ; then
31 libmikmod_config_args="$libmikmod_config_args --exec-prefix=$libmikmod_config_exec_prefix"
32 if test x${LIBMIKMOD_CONFIG+set} != xset ; then
33 LIBMIKMOD_CONFIG=$libmikmod_config_exec_prefix/bin/libmikmod-config
36 if test x$libmikmod_config_prefix != x ; then
37 libmikmod_config_args="$libmikmod_config_args --prefix=$libmikmod_config_prefix"
38 if test x${LIBMIKMOD_CONFIG+set} != xset ; then
39 LIBMIKMOD_CONFIG=$libmikmod_config_prefix/bin/libmikmod-config
43 AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no)
44 min_libmikmod_version=ifelse([$1], ,3.1.5,$1)
45 AC_MSG_CHECKING(for libmikmod - version >= $min_libmikmod_version)
47 if test "$LIBMIKMOD_CONFIG" = "no" ; then
50 LIBMIKMOD_CFLAGS=`$LIBMIKMOD_CONFIG $libmikmod_config_args --cflags`
51 LIBMIKMOD_LIBS=`$LIBMIKMOD_CONFIG $libmikmod_config_args --libs`
52 LIBMIKMOD_LDADD=`$LIBMIKMOD_CONFIG $libmikmod_config_args --ldadd`
53 libmikmod_config_major_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
55 libmikmod_config_minor_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \
56 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
57 libmikmod_config_micro_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \
58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'`
59 if test "x$enable_libmikmodtest" = "xyes" ; then
60 ac_save_CFLAGS="$CFLAGS"
64 CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS $LIBMIKMOD_LDADD"
65 LIBS="$LIBMIKMOD_LIBS $LIBS"
67 dnl Now check if the installed libmikmod is sufficiently new. (Also sanity
68 dnl checks the results of libmikmod-config to some extent
77 char* my_strdup (char *str)
82 new_str = malloc ((strlen (str) + 1) * sizeof(char));
83 strcpy (new_str, str);
92 int major,minor,micro;
93 int libmikmod_major_version,libmikmod_minor_version,libmikmod_micro_version;
96 system("touch conf.mikmodtest");
98 /* HP/UX 9 (%@#!) writes to sscanf strings */
99 tmp_version = my_strdup("$min_libmikmod_version");
100 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
101 printf("%s, bad version string\n", "$min_libmikmod_version");
105 libmikmod_major_version=(MikMod_GetVersion() >> 16) & 255;
106 libmikmod_minor_version=(MikMod_GetVersion() >> 8) & 255;
107 libmikmod_micro_version=(MikMod_GetVersion() ) & 255;
109 if ((libmikmod_major_version != $libmikmod_config_major_version) ||
110 (libmikmod_minor_version != $libmikmod_config_minor_version) ||
111 (libmikmod_micro_version != $libmikmod_config_micro_version))
113 printf("\n*** 'libmikmod-config --version' returned %d.%d.%d, but libmikmod (%d.%d.%d)\n",
114 $libmikmod_config_major_version, $libmikmod_config_minor_version, $libmikmod_config_micro_version,
115 libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version);
116 printf ("*** was found! If libmikmod-config was correct, then it is best\n");
117 printf ("*** to remove the old version of libmikmod. You may also be able to fix the error\n");
118 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
119 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
120 printf("*** required on your system.\n");
121 printf("*** If libmikmod-config was wrong, set the environment variable LIBMIKMOD_CONFIG\n");
122 printf("*** to point to the correct copy of libmikmod-config, and remove the file config.cache\n");
123 printf("*** before re-running configure\n");
125 else if ((libmikmod_major_version != LIBMIKMOD_VERSION_MAJOR) ||
126 (libmikmod_minor_version != LIBMIKMOD_VERSION_MINOR) ||
127 (libmikmod_micro_version != LIBMIKMOD_REVISION))
129 printf("*** libmikmod header files (version %ld.%ld.%ld) do not match\n",
130 LIBMIKMOD_VERSION_MAJOR, LIBMIKMOD_VERSION_MINOR, LIBMIKMOD_REVISION);
131 printf("*** library (version %d.%d.%d)\n",
132 libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version);
136 if ((libmikmod_major_version > major) ||
137 ((libmikmod_major_version == major) && (libmikmod_minor_version > minor)) ||
138 ((libmikmod_major_version == major) && (libmikmod_minor_version == minor) && (libmikmod_micro_version >= micro)))
144 printf("\n*** An old version of libmikmod (%d.%d.%d) was found.\n",
145 libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version);
146 printf("*** You need a version of libmikmod newer than %d.%d.%d.\n",
147 major, minor, micro);
149 printf("*** If you have already installed a sufficiently new version, this error\n");
150 printf("*** probably means that the wrong copy of the libmikmod-config shell script is\n");
151 printf("*** being found. The easiest way to fix this is to remove the old version\n");
152 printf("*** of libmikmod, but you can also set the LIBMIKMOD_CONFIG environment to point to the\n");
153 printf("*** correct copy of libmikmod-config. (In this case, you will have to\n");
154 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
155 printf("*** so that the correct libraries are found at run-time))\n");
160 ],, no_libmikmod=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
161 CFLAGS="$ac_save_CFLAGS"
166 if test "x$no_libmikmod" = x ; then
167 AC_MSG_RESULT([yes, `$LIBMIKMOD_CONFIG --version`])
168 ifelse([$2], , :, [$2])
171 if test "$LIBMIKMOD_CONFIG" = "no" ; then
172 echo "*** The libmikmod-config script installed by libmikmod could not be found"
173 echo "*** If libmikmod was installed in PREFIX, make sure PREFIX/bin is in"
174 echo "*** your path, or set the LIBMIKMOD_CONFIG environment variable to the"
175 echo "*** full path to libmikmod-config."
177 if test -f conf.mikmodtest ; then
180 echo "*** Could not run libmikmod test program, checking why..."
181 CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS"
182 LIBS="$LIBS $LIBMIKMOD_LIBS"
188 ], [ return (MikMod_GetVersion()!=0); ],
189 [ echo "*** The test program compiled, but did not run. This usually means"
190 echo "*** that the run-time linker is not finding libmikmod or finding the wrong"
191 echo "*** version of libmikmod. If it is not finding libmikmod, you'll need to set your"
192 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
193 echo "*** to the installed location. Also, make sure you have run ldconfig if that"
194 echo "*** is required on your system."
196 echo "*** If you have an old version installed, it is best to remove it, although"
197 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
198 [ echo "*** The test program failed to compile or link. See the file config.log for the"
199 echo "*** exact error that occured. This usually means libmikmod was incorrectly installed"
200 echo "*** or that you have moved libmikmod since it was installed. In the latter case, you"
201 echo "*** may want to edit the libmikmod-config script: $LIBMIKMOD_CONFIG" ])
202 CFLAGS="$ac_save_CFLAGS"
210 ifelse([$3], , :, [$3])
212 AC_SUBST(LIBMIKMOD_CFLAGS)
213 AC_SUBST(LIBMIKMOD_LIBS)
214 AC_SUBST(LIBMIKMOD_LDADD)
215 rm -f conf.mikmodtest