Debian Codegraph @

bin/avifile.m4

raw
1 # AM_PATH_AVIFILE 0.1.0
2 # CXXFLAGS and LIBS for avifile
3 # taken from Autostar Sandbox, http://autostars.sourceforge.net/
4 # constructed by careful cross-pollination from various sources and lots of
5 # hard labour
6
7 dnl Usage:
8 dnl AM_PATH_AVIFILE(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
9 dnl Test for avifile, and defines
10 dnl - AVIFILE_CXXFLAGS (C++ compiler flags)
11 dnl - AVIFILE_LDFLAGS (linker flags, stripping and path)
12 dnl as well as set HAVE_AVIFILE to yes or no
13 dnl
14 dnl FIXME: should define AVIFILE_VERSION
15 dnl
16 dnl prerequisites:
17 dnl - working C++ compiler
18 dnl - usable libstdc++
19 dnl - AC_PATH_XTRA
20
21 AC_DEFUN([AM_PATH_AVIFILE],
22 [
23 AC_REQUIRE([AC_PROG_CXX])
24 AC_REQUIRE([AC_PATH_XTRA])
25 HAVE_AVIFILE=no
26
27 dnl first look for avifile-config
28 AC_PATH_PROG(AVIFILE_CONFIG, avifile-config, no)
29 min_avifile_version=ifelse([$1], ,0.7.0, $1)
30 if test "x$AVIFILE_CONFIG" != "xno"; then
31 dnl now that we have it, we need to save libs and cflags
32 AVIFILE_LDFLAGS=`avifile-config --libs`
33 AVIFILE_CXXFLAGS=`avifile-config --cflags`
34 AC_SUBST(AVIFILE_LDFLAGS)
35 AC_SUBST(AVIFILE_CXXFLAGS)
36 HAVE_AVIFILE=yes
37 fi
38
39 dnl we got this far, now start checking if we have the right version
40 if test x$HAVE_AVIFILE = xyes ; then
41 AC_MSG_CHECKING(for avifile - version >= $min_avifile_version)
42 dnl first get the version number from avifile-config
43 avifile_major_version=`$AVIFILE_CONFIG $avifile_args --version | \
44 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
45 avifile_minor_version=`$AVIFILE_CONFIG $avifile_args --version | \
46 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
47 avifile_micro_version=`$AVIFILE_CONFIG $avifile_config_args --version | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
49
50 dnl now run a short C app that tells us if the version is ok or not
51 dnl all of this is boilerplate code from other examples
52 rm -f conf.avifiletest
53 AC_TRY_RUN([
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <string.h>
57
58 int
59 main ()
60 {
61 int major, minor, micro;
62 char ver[50];
63
64 system ("touch conf.avifiletest");
65
66 /* HP/UX 9 (%@#!) writes to sscanf strings */
67 strncpy(ver, "$min_avifile_version", sizeof(ver) - 1);
68 if (sscanf(ver, "%d.%d.%d", &major, &minor, &micro) != 3)
69 {
70 printf ("%s, bad version string\n", "$min_avifile_version");
71 exit (1);
72 }
73 if (($avifile_major_version > major) ||
74 (($avifile_major_version == major) && ($avifile_minor_version > minor)) ||
75 (($avifile_major_version == major) && ($avifile_minor_version == minor) && ($avifile_micro_version >= micro)))
76 return 0;
77 else
78 {
79 printf ("\n*** 'avifile-config --version' returned %d.%d.%d, but the minimum version\n", $avifile_major_version, $avifile_minor_version, $avifile_micro_version);
80 printf ("*** of AVIFILE required is %d.%d.%d. If avifile-config is correct, then it is\n", major, minor, micro);
81 printf ("*** best to upgrade to the required version.\n");
82 printf ("*** If avifile-config was wrong, set the environment variable AVIFILE_CONFIG\n");
83 printf ("*** to point to the correct copy of avifile-config, and remove the file\n");
84 printf ("*** config.cache (if it exists) before re-running configure\n");
85 return 1;
86 }
87 }
88 ],
89 [
90 AC_MSG_RESULT(yes)
91 HAVE_AVIFILE=yes
92 ],
93 [
94 HAVE_AVIFILE=no
95 ])
96 fi
97
98 if test x$HAVE_AVIFILE = xyes ; then
99 dnl now try to compile a sample test app
100
101 dnl first save whatever language we're currently testing in
102 dnl AC_LANG_SAVE
103 dnl AC_LANG_CPLUSPLUS
104 AC_LANG_PUSH(C++)
105 ac_save_CXXFLAGS=$CXXFLAGS
106 ac_save_LDFLAGS=$LDFLAGS
107 dnl add X flags, because it looks like avifile needs libXv and libXxf86vm
108 CXXFLAGS="$CXXFLAGS $AVIFILE_CXXFLAGS"
109 LDFLAGS="$LDFLAGS $AVIFILE_LDFLAGS $X_LIBS -lXv -lXxf86vm"
110
111 AC_MSG_CHECKING(compilation of avifile test program)
112 dnl try the compile
113 AC_TRY_LINK([
114 #include <stdio.h>
115 #include <stdlib.h>
116 #include <avifile.h>
117 #include <creators.h>
118 ], [
119 /* function body */
120 IVideoDecoder *decoder;
121 BITMAPINFOHEADER bh;
122
123 decoder = Creators::CreateVideoDecoder(bh) ],
124 [ AC_MSG_RESULT(succeeded) ],
125 [ AC_MSG_RESULT(failed) ; HAVE_AVIFILE=no ] )
126 AC_LANG_POP
127 CXXFLAGS="$ac_save_CXXFLAGS"
128 LDFLAGS="$ac_save_LDFLAGS"
129 fi
130 ])
131