configure.ac 9.8 KB
Newer Older
1
m4_define([MEDIALIB_MAJOR], [0])
2
m4_define([MEDIALIB_MINOR], [4])
3
4
m4_define([MEDIALIB_MICRO], [0])

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
5
AC_COPYRIGHT([Copyright 2014-2017 Hugo Beauzée-Luyssen - VideoLabs - VideoLAN])
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

AC_INIT([medialibrary], [MEDIALIB_MAJOR.MEDIALIB_MINOR.MEDIALIB_MICRO])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE([foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [
  AM_SILENT_RULES([yes])
])
AC_CANONICAL_HOST

MEDIALIBRARY_MAJOR=MEDIALIB_MAJOR
MEDIALIBRARY_MINOR=MEDIALIB_MINOR
MEDIALIBRARY_MICRO=MEDIALIB_MICRO
AC_SUBST(MEDIALIBRARY_MAJOR)
AC_SUBST(MEDIALIBRARY_MINOR)
AC_SUBST(MEDIALIBRARY_MICRO)

23
24
AC_USE_SYSTEM_EXTENSIONS

25
LT_INIT([win32-dll shared disable-static])
26
AC_PROG_CXX
27
AC_PROG_OBJCXX
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
AX_CXX_COMPILE_STDCXX_11([noext])

AC_CONFIG_MACRO_DIR([m4])

AC_HEADER_ASSERT

dnl
dnl  Check the operating system
dnl
HAVE_WIN64="0"
HAVE_IOS="0"
HAVE_OSX="0"
HAVE_TVOS="0"

case "${host_os}" in
  "")
    SYS=unknown
    ;;
  linux*)
    SYS=linux
48
    CXXFLAGS="${CXXFLAGS} -pthread"
49
50
dnl Specify -lpthread as part of Libs.private, in case of a static build
    THREAD_LIBS="-lpthread"
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
    ;;
  bsdi*)
    SYS=bsdi
    ;;
  freebsd*)
    SYS=freebsd
    CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
    LDFLAGS="${LDFLAGS} -L/usr/local/lib"
    ;;
  openbsd*)
    SYS=openbsd
    CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/X11R6/include"
    LDFLAGS="${LDFLAGS} -L/usr/local/lib -L/usr/X11R6/lib/"
    ;;
  netbsd*)
    SYS=netbsd
    ;;
  dragonfly*)
    SYS=dragonfly
    ;;
  darwin*)

    dnl Force gcc "-arch" flag
    ARCH_flag=""
    case "${host}" in
      i?86*)
        ARCH_flag="-arch i386"
      ;;
      ppc64*)
        ARCH_flag="-arch ppc64"
      ;;
      ppc*)
        ARCH_flag="-arch ppc"
      ;;
      x86_64*)
        ARCH_flag="-arch x86_64"
      ;;
      arm*)
        ac_cv_c_bigendian="no"
        ac_cv_c_attribute_packed="no"
      ;;
    esac

    SYS=darwin
    CFLAGS="${CFLAGS} -D_INTL_REDIRECT_MACROS -std=gnu11 ${ARCH_flag}"
    CXX="${CXX} -stdlib=libc++ -std=c++11"
    CXXFLAGS="${CXXFLAGS} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"
    CPPFLAGS="${CPPFLAGS} ${ARCH_flag}"
99
100
    OBJCXX="${OBJCXX} -stdlib=libc++ -std=c++11"
    OBJCXXFLAGS="${OBJCXXFLAGS} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"
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
    LDFLAGS="${LDFLAGS} -Wl,-headerpad_max_install_names ${ARCH_flag}"

    AC_EGREP_CPP(yes,
            [#import <TargetConditionals.h>
             #if TARGET_OS_IPHONE
             yes
             #endif],
             [HAVE_IOS="1"],
             [HAVE_OSX="1"])

    AC_EGREP_CPP(yes,
            [#import <TargetConditionals.h>
             #if TARGET_OS_TV
             yes
             #endif],
             [HAVE_TVOS="1"
             HAVE_IOS="0"
             HAVE_OSX="0"
             ],)

    dnl Allow binaries created on Lion to run on earlier releases
    AC_EGREP_CPP(yes,
           [#import <Cocoa/Cocoa.h>
            #ifdef MAC_OS_X_VERSION_10_7
            yes
            #endif],
            [AC_MSG_RESULT([yes])
            AC_LIBOBJ([getdelim])
            AC_LIBOBJ([strndup])
            AC_LIBOBJ([strnlen])],)

    dnl
    dnl  Handle Mac OS X SDK flags
    dnl
    AC_ARG_WITH(macosx-sdk,
      [AS_HELP_STRING([--with-macosx-sdk=DIR],
        [compile using the SDK in DIR])])
    if test "${with_macosx_sdk}" != "" ; then
        test ! -d "${with_macosx_sdk}" && AC_MSG_ERROR([SDK "${with_macosx_sdk}" not found])
        CPP="${CPP} -isysroot ${with_macosx_sdk}"
        CC="${CC} -isysroot ${with_macosx_sdk}"
        CXX="${CXX} -isysroot ${with_macosx_sdk}"
        OBJC="${OBJC} -isysroot ${with_macosx_sdk}"
144
        OBJCXX="${OBJCXX} -isysroot ${with_macosx_sdk}"
145
146
147
148
149
150
151
152
153
154
        LD="${LD} -syslibroot ${with_macosx_sdk}"
    fi
    AC_ARG_WITH(macosx-version-min,
      [AS_HELP_STRING([--with-macosx-version-min=VERSION],
        [compile for Mac OS X VERSION and above])])
    if test "${with_macosx_version_min}" != "" ; then
        CPP="${CPP} -mmacosx-version-min=${with_macosx_version_min}"
        CC="${CC} -mmacosx-version-min=${with_macosx_version_min}"
        CXX="${CXX} -mmacosx-version-min=${with_macosx_version_min}"
        OBJC="${OBJC} -mmacosx-version-min=${with_macosx_version_min}"
155
        OBJCXX="${OBJCXX} -mmacosx-version-min=${with_macosx_version_min}"
156
        LD="${LD} -mmacosx_version_min=${with_macosx_version_min}"
157
        OBJCXXLD="${OBJCXXLD} -mmacosx_version_min=${with_macosx_version_min}"
158
159
160
    fi
    ;;
  *mingw32* | *cygwin* | *wince* | *mingwce*)
161
    CXXFLAGS="${CXXFLAGS} -static-libgcc -static-libstdc++"
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
    AC_DEFINE([_UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
    AC_DEFINE([UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
    AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
    AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.])

    case "${host_os}" in
      *mingw32*)
        SYS=mingw32
        ;;
      *cygwin*)
        SYS=cygwin
        ;;
    esac

    if test "${SYS}" = "mingw32"; then
        # DEP, ASLR, NO SEH
        LDFLAGS="${LDFLAGS} -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase"

        AC_CHECK_PROGS(U2D, [unix2dos todos], unix2dos)
        ac_default_prefix="`pwd`/_win32"
        DESTDIR="`pwd`/_win32/"

        dnl
        dnl NSIS/MSI Installer prefix and WIN64
        dnl
        case "${host}" in
            amd64*|x86_64*)
                HAVE_WIN64="1"
                WINDOWS_ARCH="x64"
                PROGRAMFILES="PROGRAMFILES64"
            ;;
            *)
                WINDOWS_ARCH="x86"
                PROGRAMFILES="PROGRAMFILES"
            ;;
        esac
        AC_SUBST(WINDOWS_ARCH)
        AC_SUBST(PROGRAMFILES)

    fi
    ;;
  *nto*)
    SYS=nto
    ;;
  solaris*)
    SYS=solaris
    ;;
  hpux*)
    SYS=hpux
    ;;
  *os2*)
    SYS=os2
    LDFLAGS="${LDFLAGS} -Zomf -Zbin-files -Zargs-wild -Zhigh-mem"
    AC_LIBOBJ([freeaddrinfo])
    ;;
  *)
    SYS="${host_os}"
    ;;
esac
AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
222
223
224
225
226
227
AM_CONDITIONAL(HAVE_LINUX,   test "${SYS}" = "linux")
AM_CONDITIONAL(HAVE_DARWIN,  test "${SYS}" = "darwin")
AM_CONDITIONAL(HAVE_IOS,     test "${HAVE_IOS}" = "1")
AM_CONDITIONAL(HAVE_OSX,     test "${HAVE_OSX}" = "1")
AM_CONDITIONAL(HAVE_TVOS,    test "${HAVE_TVOS}" = "1")

228
229
230
231
232
233
234
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([c++11 thread support])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <thread>
                   int main() { std::thread t; }])], [
        AC_MSG_RESULT([ok])
        AC_DEFINE(CXX11_THREADS, 1, [Defined to 1 if C++11 threads are supported])
    ],[ AC_MSG_RESULT([no])])
235
AC_LANG_POP([C++])
236

237
AC_LANG_PUSH([C++])
238
239
240
241
242
243
244
245
246
AC_MSG_CHECKING([c++11 std::mutex support])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <mutex>
                   int main() { std::mutex m; }])], [
        AC_MSG_RESULT([ok])
        AC_DEFINE(CXX11_MUTEX, 1, [Defined to 1 if C++11 std::mutex is supported])
    ],[ AC_MSG_RESULT([no])])
AC_LANG_POP([C++])

AC_LANG_PUSH([C++])
247
248
249
250
251
252
253
254
AC_MSG_CHECKING([c++11 thread_local support])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([thread_local int seaOtter = 0;
                   int main() {}])], [
        AC_MSG_RESULT([ok])
        AC_DEFINE(CXX11_THREAD_LOCAL, 1, [Defined to 1 if C++11 thread_local storage qualifier is supported])
    ],[ AC_MSG_RESULT([no])])
AC_LANG_POP([C++])

255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
dnl Android is linux, but a bit different
AS_IF([test "$SYS" = linux],[
    AC_MSG_CHECKING([for an Android system])
    AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
                      [[#ifndef __ANDROID__
                       # error Not Android
                       #endif
                       ]],[[;]])
        ],[
            HAVE_ANDROID="1"
            AC_MSG_RESULT([yes])
        ],[AC_MSG_RESULT([no])
    ])
])
AM_CONDITIONAL(HAVE_ANDROID, test "${HAVE_ANDROID}" = "1")
270

271
AS_IF([test "$SYS" = mingw32],[
272
273
274
    AH_TOP([#if defined(_WIN32) && !defined(_WIN32_WINNT)])
    AH_TOP([# define _WIN32_WINNT 0x0600 ])
    AH_TOP([#endif])
275
276
])

277
AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug], [build with debug code and run-time assertions (default enabled)])])
278
AH_TEMPLATE(NDEBUG, [Define to 1 if debug code should NOT be compiled])
279
AS_IF([test "${enable_debug}" = "no"],[
280
281
282
  AC_DEFINE(NDEBUG)
])

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
AC_ARG_WITH(libvlc, [AC_HELP_STRING([--with-libvlc], [build with libvlc integration (default enabled)])],, [with_libvlc=yes])
AH_TEMPLATE(HAVE_LIBVLC, [Define to 1 if libvlc integration is enabled])
AS_IF([test "${with_libvlc}" != "no"], [
    AC_DEFINE(HAVE_LIBVLC)
    PKG_CHECK_MODULES(VLC, libvlc >= 3.0)
    PKG_CHECK_MODULES(VLCPP, libvlcpp,
        [AC_MSG_RESULT([Found libvlcpp.pc])],
        [
            # Checking for files doesn't work when cross compiling. Simply assume
            # The file is there
            AC_MSG_RESULT([Falling back to submodule])
            AC_SUBST([VLCPP_CFLAGS],[-I${srcdir}/libvlcpp])
        ]
    )
])
AM_CONDITIONAL(HAVE_LIBVLC, [test "${with_libvlc}" != "no"])

300
301
302
303
304
PKG_CHECK_MODULES(SQLITE, sqlite3)

PKG_CHECK_MODULES(LIBJPEG, libjpeg, [
     have_libjpeg="yes"
     AC_DEFINE(HAVE_JPEG, 1, [Define to 1 if libjpeg is available])
305
306
307
308
309
310
 ], [
dnl Falling back to libjpeg.h based detection
    AC_CHECK_HEADERS(jpeglib.h, [
        have_libjpeg="yes"
        AC_SUBST(LIBJPEG_LIBS, "-ljpeg")
    ])
311
312
313
 ])
AM_CONDITIONAL([HAVE_LIBJPEG], [test "${have_libjpeg}" = "yes"])

314
AC_ARG_ENABLE(tests,AC_HELP_STRING([--disable-tests], [Disable build of automated tests suites]))
315
316
AM_CONDITIONAL([HAVE_TESTS], [test "${enable_tests}" = "yes"])
AS_IF([test "${enable_tests}" = "yes"], [
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
317
318
319
320
321
322
323
324
325
    PKG_CHECK_MODULES(RAPIDJSON, RapidJSON, [], [
        # We need the .pc for cross compilation, but we don't consider it a failure
        # when building natively, mostly because debian doesn't package the .pc
        if test "$host" != "$build" ; then
            AC_MSG_ERROR(["Failed to find rapidjson"])
        else
            AC_MSG_WARN("Failed to find rapidjson using pkg-config. Using default location")
        fi
    ])
326
327
])

328
329
AH_BOTTOM([#include "Fixup.h"])

330
331
332
333
PKG_INSTALLDIR

AC_CONFIG_FILES([
Makefile
334
medialibrary.pc
335
336
])

337
338
AC_SUBST(THREAD_LIBS)

339
AC_OUTPUT