File: configure.ac

package info (click to toggle)
ffms2 2.20-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,532 kB
  • ctags: 2,119
  • sloc: sh: 11,511; cpp: 6,888; ansic: 3,489; makefile: 69; xml: 43
file content (250 lines) | stat: -rw-r--r-- 7,322 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
AC_PREREQ([2.58])
AC_INIT([ffms2],[esyscmd([sh version.sh])])
AC_CONFIG_SRCDIR([src/core/ffms.cpp])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 subdir-objects])
AM_SILENT_RULES([yes])
AM_MAINTAINER_MODE([disable])

VERSION_INFO="3:0:0"

AC_MSG_CHECKING([if debug build is enabled])

AC_ARG_ENABLE([debug],
        [AC_HELP_STRING([--enable-debug],
            [Enable debug build. [default=no]])],
        [enable_debug=yes],
        [enable_debug=no]
        )

AC_MSG_RESULT([$enable_debug])

if test "$enable_debug" = yes; then
    OPT_FLAGS="-O0 -g"
else
    OPT_FLAGS="-O3"
fi

if test -z "$CFLAGS"; then
    CFLAGS="$OPT_FLAGS"
fi

if test -z "$CXXFLAGS"; then
    CXXFLAGS="$OPT_FLAGS"
fi

AC_CONFIG_HEADERS([src/config/config.h])
AC_PROG_CC
AC_PROG_CXX

AC_CANONICAL_HOST
AS_CASE([$host],
        [*mingw* | *cygwin*], [
            AC_ENABLE_STATIC
            AC_DISABLE_SHARED
         ], [
            AC_ENABLE_SHARED
            AC_DISABLE_STATIC])

AC_PROG_LIBTOOL

if echo "$host" | $GREP "cygwin" >/dev/null 2>&1 && test "$enable_shared" = "yes"; then
    AC_MSG_ERROR([Shared build is broken on cygwin.
                  Please remove --enable-shared from your configure options or build with another --host.])
fi

AC_FUNC_ALLOCA
if ! test "x$ac_cv_working_alloca_h" = "xyes" && ! test "x$ac_cv_func_alloca_works" = "xyes"; then
    AC_MSG_FAILURE([ffms2 requires alloca to compile])
fi

dnl Workaround for a bug in libtool
dnl The windows libtool uses a file magic checking method that only accepts
dnl dynamic libraries. Change it for libtool's alternative checking method.
if test "$lt_cv_file_magic_cmd" = "func_win32_libid" ; then
    deplibs_check_method='file_magic file format pei*-(i386|x86-64)|(.*architecture: i386)?'
    file_magic_cmd='$OBJDUMP -f'
fi

FFMS_VERSION="$(sh $(dirname -- "$0")/version.sh)"
AC_SUBST([FFMS_VERSION])

_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"

AC_LANG_PUSH([C++])

AC_MSG_CHECKING([if -fvisibility=hidden works])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([char foo;])],
    [fvisibility_works=yes],
    [fvisibility_works=no]
    )

AC_MSG_RESULT([$fvisibility_works])

if test "$fvisibility_works" = no; then
    CXXFLAGS="$_CXXFLAGS"
fi

AC_LANG_POP([C++])

CHECK_ZLIB

AC_MSG_CHECKING([for CoUninitialize in -lole32])
_LIBS="$LIBS"
LIBS="-lole32 $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
               #include <objbase.h>
               ]],[[
                   CoUninitialize();
                   return 0;
               ]])], [AC_MSG_RESULT([yes])], [LIBS="$_LIBS"; AC_MSG_RESULT([no])])


dnl Save CFLAGS and LIBS for later, as anything else we add will be from pkg-config
dnl and thus should be separate in our .pc file.
_CFLAGS="$CFLAGS"
_LIBS="$LIBS"

PKG_PROG_PKG_CONFIG([0.22])
pkgconfigdir="\$(libdir)/pkgconfig"
AC_SUBST(pkgconfigdir)

PKG_CHECK_MODULES(LIBAV, [libavformat >= 53.20.0 libavcodec >= 53.24.0 libswscale >= 0.7.0 libavutil >= 51.21.0 ])
CPPFLAGS="$CPPFLAGS -D__STDC_CONSTANT_MACROS"

dnl As of 0eec06ed8747923faa6a98e474f224d922dc487d ffmpeg only adds -lrt to lavc's
dnl LIBS, but lavu needs it, so move it to the end if it's present
LIBAV_LIBS=$(echo $LIBAV_LIBS | sed 's/\(.*\) -lrt\(.*\)/\1\2 -lrt/')

AC_SUBST([LIBAV_CFLAGS])
AC_SUBST([LIBAV_LIBS])

AC_DEFUN([TEST_IS_FFMPEG],
         [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
            #include <libavcodec/avcodec.h>
            #include <libswscale/swscale.h>
            ]],[[
                #if LIBAVCODEC_VERSION_MICRO >= 100
                /* is ffmpeg */
                #elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 47, 100)
                /* hopefully libav doesn''t add G2M before 53.47.... */
                (void)CODEC_ID_G2M;
                #else
                #error is libav or old enough that the distinction doesn't matter
                #endif
            ]])], [eval $1=yes], [eval $1=no])
        ])

AC_MSG_CHECKING([whether linking with FFmpeg or Libav])
CFLAGS="$_CFLAGS $LIBAV_CFLAGS"
TEST_IS_FFMPEG([FFMS_USE_FFMPEG_COMPAT])

if test "$FFMS_USE_FFMPEG_COMPAT" = yes; then
   AC_DEFINE([FFMS_USE_FFMPEG_COMPAT], [1], [Building with FFmpeg?])
   _lav_name=FFmpeg
else
   _lav_name=Libav
fi
AC_MSG_RESULT([$_lav_name])

AC_DEFUN([TEST_LIBAV],
         [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
            #include <libavcodec/avcodec.h>
            #include <libswscale/swscale.h>
            ]],[[
                avcodec_register_all();
                swscale_version();
                #ifdef FFMS_USE_FFMPEG_COMPAT
                int bogus = CODEC_ID_G2M;
                (void) bogus;
                #endif
            ]])], [eval $1=yes], [eval $1=no])
        ])

AC_MSG_CHECKING([whether $_lav_name works])
LIBS="$_LIBS $LIBAV_LIBS"
TEST_LIBAV([LIBAV_WORKS])
AC_MSG_RESULT([$LIBAV_WORKS])
if test "$LIBAV_WORKS" = no; then
AC_MSG_FAILURE([cannot link with $_lav_name])
fi

AC_MSG_CHECKING([whether avformat_get_riff_video_tags is available])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
              #include <libavformat/avformat.h>
            ]],
            [[
              #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54, 1, 0)
              const struct AVCodecTag *tags = avformat_get_riff_video_tags();
              (void)tags;
              #endif
            ]])],
            [
              AC_DEFINE([RETARDED_LIBAV_RELEASE_BRANCH_WHICH_INTRODUCED_AVFORMAT_GET_RIFF_VIDEO_TAGS_AT_A_VERSION_NUMBER_WHICH_HAD_ALREADY_BEEN_USED], [1], [ ])
              AC_MSG_RESULT([yes])
            ],
            [
              AC_MSG_RESULT([no])
            ])

AC_ARG_ENABLE(avresample,
              AS_HELP_STRING([--enable-avresample],
                             [use libavresample for audio resampling]))
AS_IF([test x$enable_avresample != xno], [
  PKG_CHECK_MODULES(AVRESAMPLE, [libavresample >= 1.0.0], [enable_avresample=yes], [
    AS_IF([test x$enable_avresample = xyes],
          [AC_MSG_ERROR([--enable-avresample was specified, but avresample 1.0.0+ could not be found.])])
    enable_avresample=no
  ])
])

AS_IF([test x$enable_avresample != xno],
      [libavresample="libavresample"
       AC_DEFINE([WITH_AVRESAMPLE], [1], [Use avresample])])

dnl See similar thing for LIBAV_LIBS
AVRESAMPLE_LIBS=$(echo $AVRESAMPLE_LIBS | sed 's/\(.*\) -lrt\(.*\)/\1\2 -lrt/')

AC_SUBST([AVRESAMPLE_CFLAGS])
AC_SUBST([AVRESAMPLE_LIBS])
AC_SUBST([libavresample])

AC_MSG_CHECKING([whether -Wl,-Bsymbolic is needed])
if test "$enable_shared" = yes; then
    _LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS -shared $lt_prog_compiler_pic"
    TEST_LIBAV([no_bsymbolic])
    if test "$no_bsymbolic" = "no"; then
        LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
        TEST_LIBAV([bsymbolic])
        if test "$bsymbolic" = "yes"; then
            LDFLAGS="$_LDFLAGS -Wl,-Bsymbolic"
        else
            AC_MSG_RESULT($bsymbolic)
            AC_MSG_FAILURE([cannot build ffms2 as a shared library])
        fi
    else
        bsymbolic=no
        LDFLAGS="$_LDFLAGS"
    fi
    LDFLAGS="$LDFLAGS -version-info $VERSION_INFO"
else
    bsymbolic=no
fi
CFLAGS="$_CFLAGS -std=c99"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFFMS_EXPORTS"
LIBS="$_LIBS"
AC_MSG_RESULT($bsymbolic)

if echo "$host" | $GREP "mingw" >/dev/null 2>&1; then
    LTUNDEF="-no-undefined"
fi
AC_SUBST([LTUNDEF])

AC_CONFIG_FILES([
Makefile
ffms2.pc
])
AC_OUTPUT