used to be ../aclocal.m4.
[swftools.git] / m4 / swf.m4
1 AC_DEFUN(SWF_CHECK_BYTEORDER,
2 [
3 AC_MSG_CHECKING([for byte order])
4 AC_TRY_RUN([
5 int main (int argc, char *argv[])
6 {
7     int i = 1;
8     return *(char*)&i;
9 }
10 ], BIGENDIAN=1, LITTLEENDIAN=1, CROSSCOMPILE=1)
11 export CROSSCOMPILE 
12
13 if test "x${CROSSCOMPILE}" = "x1"; then
14  AC_MSG_RESULT(we are cross compiling- trying to guess from system type)
15  AC_CANONICAL_SYSTEM
16  AC_MSG_CHECKING([for byte order, try 2])
17  case "${target}" in
18   *86* | *-pc-* )
19      LITTLEENDIAN=1
20      ;;
21   *sparc* | *68* | *88k* | *mac* | *Mac* | *sun* | *Sun* | *Amiga* | *amiga* )
22      BIGENDIAN=1
23      ;;
24  esac
25 fi
26
27 export LITTLEENDIAN
28 if test "x${LITTLEENDIAN}" = "x1"; then
29 AC_MSG_RESULT(little endian)
30 BYTEORDERCHECKOK=1
31 fi
32 export BIGENDIAN
33 if test "x${BIGENDIAN}" = "x1"; then
34 AC_MSG_RESULT(big endian)
35 BYTEORDERCHECKOK=1
36 WORDS_BIGENDIAN=1
37 export WORDS_BIGENDIAN
38 AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, 1)
39 fi
40 if test "x${BYTEORDERCHECKOK}" != "x1"; then
41 AC_MSG_RESULT(unknown)
42 echo Byte order could not determined. Try to insert your system type into aclocal.m4 about line 21
43 exit 1
44 fi
45 ])
46
47 AC_DEFUN(SWF_CHECK_SYSTEM_BACKTICKS,
48 [
49 AC_MSG_CHECKING([whether system() can handle command substitution])
50 AC_TRY_RUN([
51 #include "stdlib.h"
52 int main (int argc, char*argv[])
53 {
54     return system("test `touch config.tmp2`");
55 }
56 ], OK=OK,,CROSSCOMPILE=1)
57
58 if test "x${OK}" = "xOK";then
59     test -f config.tmp2 || OK=
60 fi
61
62 if test "x${CROSSCOMPILE}" = "x1";then
63     OK=OK;
64 fi
65 if test "x${OK}" = "xOK";then
66 rm -f config.tmp2
67 AC_MSG_RESULT(yes)
68 SYSTEM_BACKTICKS=1
69 export SYSTEM_BACKTICKS
70 AC_DEFINE_UNQUOTED(SYSTEM_BACKTICKS, 1)
71 else
72 AC_MSG_RESULT(no)
73 fi
74 ])
75
76 AC_DEFUN(SWF_CHECK_AVI2SWF,
77 [
78 AC_MSG_CHECKING([whether we can compile the avifile test program])
79
80 cat > conftest.$ac_ext << EOF
81 #include <avifile/version.h>
82 #if (AVIFILE_MAJOR_VERSION == 0) && (AVIFILE_MINOR_VERSION==6) 
83    #include <avifile.h>
84    #include <aviplay.h>
85    #include <fourcc.h>
86    #include <creators.h>
87    #include <StreamInfo.h>
88    #define VERSION6
89 #else
90    #include <avifile.h>
91    #include <aviplay.h>
92    #include <aviutil.h>
93    #define Width width
94    #define Height height
95    #define Data data
96    #define Bpp bpp
97 #endif
98
99 int main (int argc, char*argv[])
100 {
101   IAviReadFile* player;
102   IAviReadStream* astream;
103   IAviReadStream* vstream;
104   player = CreateIAviReadFile(0);
105   astream = player->GetStream(0, AviStream::Audio);
106   vstream = player->GetStream(0, AviStream::Video);
107   vstream -> StartStreaming();
108   astream -> StartStreaming();
109 #ifndef VERSION6
110   MainAVIHeader head;
111   player->GetFileHeader(&head);
112   head.dwMicroSecPerFrame;
113   head.dwTotalFrames;
114   head.dwStreams;
115   head.dwWidth;
116   head.dwHeight;
117   head.dwMicroSecPerFrame;
118   astream->GetEndPos(),
119   astream->GetEndTime());
120   player->StreamCount();
121 #else
122   StreamInfo*audioinfo;
123   StreamInfo*videoinfo;
124   audioinfo = astream->GetStreamInfo();
125   videoinfo = vstream->GetStreamInfo();
126   videoinfo->GetVideoWidth();
127   videoinfo->GetVideoHeight();
128   audioinfo->GetAudioSamplesPerSec();
129   videoinfo->GetFps();
130 #endif
131   CImage*img = vstream->GetFrame();
132   img->ToRGB();
133   img->Data();
134   img->Bpp();
135   img->Width();
136   img->Height();
137   WAVEFORMATEX wave;
138   astream->GetAudioFormatInfo(&wave,0);
139   uint_t a,b;
140   astream->ReadFrames(0,0,0,a,b);
141 }
142 EOF
143
144 ac_link='g++ `avifile-config --cflags` `avifile-config --libs` conftest.$ac_ext -o conftest${ac_exeext}'
145 if {(eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
146   AC_MSG_RESULT(yes)
147   AVIFILE=true
148   export AVIFILE
149   AC_DEFINE_UNQUOTED(AVIFILE, true)
150 else
151   echo "configure: failed program was:" >&5
152   cat conftest.$ac_ext >&5
153   AC_MSG_RESULT(no)
154 fi
155 rm -f conftest*
156 ])
157
158