Add libraw1394 autoconf macro (not yet complete).

Add functions and symbols to let macro determine version.


git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@53 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
aeb 2001-02-05 02:38:03 +00:00
parent de323c4338
commit 6fc01c2077
5 changed files with 183 additions and 1 deletions

View File

@ -1,7 +1,7 @@
# process this file with autoconf to get a configure script
AC_INIT(Makefile.am)
AM_INIT_AUTOMAKE(libraw1394, 0.9pre)
AM_INIT_AUTOMAKE(libraw1394, 0.8.99)
AM_CONFIG_HEADER(config.h)
AC_PROG_CC

153
libraw1394.m4 Normal file
View File

@ -0,0 +1,153 @@
dnl
dnl AC_LIB_RAW1394_FLAGS
dnl This just unconditionally sets the options. It should offer an option for
dnl explicitly giving the path to libraw1394 on the configure command line.
dnl
AC_DEFUN(AC_LIB_RAW1394_FLAGS, [
LIBRAW1394_CPPFLAGS=""
LIBRAW1394_CFLAGS=""
LIBRAW1394_LIBS="-lraw1394"
AC_SUBST(LIBRAW1394_CPPFLAGS)
AC_SUBST(LIBRAW1394_CFLAGS)
AC_SUBST(LIBRAW1394_LIBS)
])
dnl
dnl AC_LIB_RAW1394_HEADERS([ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]])
dnl
AC_DEFUN(AC_LIB_RAW1394_HEADERS, [
AC_REQUIRE(AC_LIB_RAW1394_FLAGS)
ac_libraw1394_save_cppflags=$CPPFLAGS
CPPFLAGS="$LIBRAW1394_CPPFLAGS $CPPFLAGS"
ac_libraw1394_headers=no
AC_CHECK_HEADER(libraw1394/raw1394.h, ac_libraw1394_headers=yes)
CPPFLAGS=$ac_libraw1394_save_cppflags
if test $ac_libraw1394_headers = yes ; then $1; else $2; fi
])
dnl
dnl AC_LIB_RAW1394_LIBVERSION(MINIMUMVERSION[,ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]])
dnl
AC_DEFUN(AC_LIB_RAW1394_LIBVERSION, [
AC_REQUIRE(AC_LIB_RAW1394_HEADERS)
ac_libraw1394_save_cppflags=$CPPFLAGS
ac_libraw1394_save_cflags=$CFLAGS
ac_libraw1394_save_libs=$LIBS
CPPFLAGS="$LIBRAW1394_CPPFLAGS $CPPFLAGS"
CFLAGS="$LIBRAW1394_CFLAGS $CFLAGS"
LIBS="$LIBRAW1394_LIBS $LIBS"
ac_libraw1394_versiontest_success=no
ac_libraw1394_ver_symbol=`echo __libraw1394_version_$0 | sed 's/\./_/g'`
AC_TRY_LINK([], [{
extern char $ac_libraw1394_ver_symbol;
$ac_libraw1394_ver_symbol++;
}], ac_libraw1394_versiontest_success=yes)
CPPFLAGS=$ac_libraw1394_save_cppflags
CFLAGS=$ac_libraw1394_save_cflags
LIBS=$ac_libraw1394_save_libs
if test $ac_libraw1394_versiontest_success = yes; then $1; else $2; fi
])
dnl
dnl AC_LIB_RAW1394_RUNTEST(MINIMUMVERSION[,ACTION_IF_FOUND
dnl [,ACTION_IF_NOT_FOUND[,ACTION_IF_CROSS_COMPILING]]])
AC_DEFUN(AC_LIB_RAW1394_RUNTEST, [
AC_REQUIRE(AC_LIB_RAW1394_HEADERS)
ac_libraw1394_save_cppflags=$CPPFLAGS
ac_libraw1394_save_cflags=$CFLAGS
ac_libraw1394_save_libs=$LIBS
CPPFLAGS="$LIBRAW1394_CPPFLAGS $CPPFLAGS"
CFLAGS="$LIBRAW1394_CFLAGS $CFLAGS"
LIBS="$LIBRAW1394_LIBS $LIBS"
dnl This program compares two version strings and returns with code 0 if
dnl req_ver <= lib_ver, returns 1 otherwise.
dnl
dnl "1.23" < "1.23.1" (missing fields assumed zero)
dnl "1.23pre" <> "1.23" (undefined, do not use text as version)
dnl "1.21" > "1.3" (no implicit delimiters)
AC_TRY_RUN([
#include <stdlib.h>
#include <libraw1394/raw1394.h>
int main()
{
char *req_ver, *lib_ver;
unsigned int req_i, lib_i;
req_ver = "$1";
lib_ver = raw1394_get_libversion();
while (1) {
req_i = strtoul(req_ver, &req_ver, 10);
lib_i = strtoul(lib_ver, &lib_ver, 10);
if (req_i > lib_i) exit(1);
if (req_i < lib_i) exit(0);
if (*req_ver != '.' || *lib_ver != '.') exit(0);
req_ver++;
lib_ver++;
}
}
], ac_libraw1394_run=yes, ac_libraw1394_run=no, ac_libraw1394_run=cross)
CPPFLAGS=$ac_libraw1394_save_cppflags
CFLAGS=$ac_libraw1394_save_cflags
LIBS=$ac_libraw1394_save_libs
if test $ac_libraw1394_run = yes; then
$2
elif test $ac_libraw1394_run = no; then
$3
else
ifelse([$4], ,
AC_MSG_ERROR([$0 called without directions for cross compiling]),
[$4])
fi
])
dnl
dnl AC_LIB_RAW1394(MINIMUMVERSION[,ACTION_IF_FOUND[,ACTION_IF_NOT_FOUND]])
dnl
dnl Versions before 0.9 can't be checked, so this will always fail if the
dnl installed libraw1394 is older than 0.9 as if the library weren't found.
dnl
AC_DEFUN(AC_LIB_RAW1394, [
AC_LIB_RAW1394_FLAGS
AC_LIB_RAW1394_HEADERS(ac_libraw1394_found=yes, ac_libraw1394_found=no
if test $ac_libraw1394_found = yes ; then
AC_MSG_CHECKING(for libraw1394 version >= [$1])
AC_LIB_RAW1394_RUNTEST([$1], , ac_libraw1394_found=no,
AC_LIB_RAW1394_LIBVERSION([$1], , ac_libraw1394_found=no))
if test $ac_libraw1394_found = yes ; then
AC_MSG_RESULT(yes)
$2
else
AC_MSG_RESULT(no)
$3
fi
fi
])

View File

@ -12,6 +12,7 @@ libraw1394_la_SOURCES = \
readwrite.c \
iso.c \
fcp.c \
version.c \
kernel-raw1394.h \
raw1394_private.h

View File

@ -193,6 +193,13 @@ int raw1394_stop_iso_rcv(raw1394handle_t handle, unsigned int channel);
int raw1394_start_fcp_listen(raw1394handle_t handle);
int raw1394_stop_fcp_listen(raw1394handle_t handle);
/*
* Returns the version string. Designed to be used by the autoconf macro to
* detect the libraw version, not really intended for general use.
*/
const char *raw1394_get_libversion(void);
#ifdef __cplusplus
}
#endif

21
src/version.c Normal file
View File

@ -0,0 +1,21 @@
/*
* libraw1394 - library for raw access to the 1394 bus with the Linux subsystem.
*
* Copyright (C) 1999,2000,2001 Andreas Bombe
*
* This library is licensed under the GNU Lesser General Public License (LGPL),
* version 2.1 or later. See the file COPYING.LIB in the distribution for
* details.
*/
#include <config.h>
/* Variables to find version by linking (avoid need for test program) */
char __libraw1394_version_0_8_99;
/* This function is to be used by the autoconf macro to find the lib version */
const char *raw1394_get_libversion()
{
return VERSION;
}