configure.ac 10.4 KB
Newer Older
1
dnl library version number
Petri Hintukainen's avatar
Petri Hintukainen committed
2 3
m4_define([bluray_major], 1)
m4_define([bluray_minor], 0)
Petri Hintukainen's avatar
Petri Hintukainen committed
4
m4_define([bluray_micro], 2)
5 6
m4_define([bluray_version],[bluray_major.bluray_minor.bluray_micro])

7 8 9 10 11 12 13 14
dnl shared library version (.so version)
dnl
dnl - If there are no interface changes, increase revision.
dnl - If interfaces have been added, increase current and age. Set revision to 0.
dnl - If interfaces have been changed or removed, increase current and set age and revision to 0.
dnl
dnl Library file name will be libbluray.so.(current-age).age.revision
dnl
Petri Hintukainen's avatar
Petri Hintukainen committed
15
m4_define([lt_current],  2)
Petri Hintukainen's avatar
Petri Hintukainen committed
16
m4_define([lt_revision], 2)
Petri Hintukainen's avatar
Petri Hintukainen committed
17
m4_define([lt_age],      0)
18

19
dnl initilization
20
AC_INIT([libbluray], bluray_version, [http://www.videolan.org/developers/libbluray.html])
21
AC_CONFIG_AUX_DIR([build-aux])
22
AC_CONFIG_MACRO_DIR([m4])
23
AC_CANONICAL_HOST
24
AM_INIT_AUTOMAKE([foreign tar-ustar dist-bzip2 no-dist-gzip subdir-objects -Wall])
25
AC_CONFIG_HEADERS(config.h)
26

27 28 29
dnl Enable silent rules only when available (automake 1.11 or later).
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

30 31 32 33 34 35 36 37 38 39 40
case "${host_os}" in
  "")
    SYS=unknown
    ;;
  *mingw32* | *cygwin* | *wince* | *mingwce*)
    case "${host_os}" in
      *wince* | *mingwce* | *mingw32ce*)
        SYS=mingwce
        ;;
      *mingw32*)
        SYS=mingw32
41
        AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows XP SP2 APIs.])
42
        AC_DEFINE([_WIN32_IE], 0x0501, [Define to '0x0501' for IE 5.01.])
43
        CPPFLAGS="${CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=1"
44 45 46
        ;;
    esac
    ;;
47 48 49
  *darwin*)
    SYS=darwin
    ;;
50 51 52 53
  netbsd*)
    SYS=netbsd
    CFLAGS="${CFLAGS} -D_NETBSD_SOURCE"
    ;;
54 55 56 57
  freebsd*)
    SYS=freebsd
    CFLAGS="${CFLAGS} -D_XOPEN_SOURCE=700"
    ;;
58 59 60 61 62
  *)
    SYS="${host_os}"
    ;;
esac

63 64 65
AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
AM_CONDITIONAL(HAVE_DARWIN,  test "${SYS}" = "darwin")

66
dnl messages
67
library_not_found="Could not find required library!"
68
function_not_found="Could not find required function!"
69

70
dnl configure options
71
AC_ARG_VAR([JDK_HOME], [Path to the JDK])
72

73
AC_ARG_ENABLE([werror],
74
  [AS_HELP_STRING([--enable-werror], [set warnings as errors via -Werror @<:@default=disabled@:>@])])
gates's avatar
gates committed
75

76
AC_ARG_ENABLE([extra-warnings],
77
  [AS_HELP_STRING([--disable-extra-warnings], [set extra warnings @<:@default=enabled@:>@])])
78

79
AC_ARG_ENABLE([optimizations],
80
  [AS_HELP_STRING([--disable-optimizations], [disable optimizations @<:@default=enabled@:>@])])
81

82 83 84 85 86 87
AC_ARG_ENABLE([examples],
  [AS_HELP_STRING([--enable-examples],
  [build examples (default is yes)])],
  [use_examples=$enableval],
  [use_examples=yes])

88
AC_ARG_ENABLE([bdjava-jar],
89 90
  [AS_HELP_STRING([--disable-bdjava-jar],
  [disable building of BD-Java JAR file @<:@default=enabled@:>@])],
91
  [use_bdjava_jar=$enableval],
92
  [use_bdjava_jar=yes])
93

94 95
AC_ARG_WITH([libxml2],
  [AS_HELP_STRING([--without-libxml2], [build without libxml2 support @<:@default=with@:>@])])
96

97 98
AC_ARG_WITH([freetype],
  [AS_HELP_STRING([--without-freetype], [build without freetype support @<:@default=with@:>@])])
99

100 101 102
AC_ARG_WITH([fontconfig],
  [AS_HELP_STRING([--without-fontconfig], [build without fontconfig support @<:@default=with@:>@])])

103 104 105 106 107 108
AC_ARG_WITH([bdj-type],
  [AS_HELP_STRING([--with-bdj-type=TYPE],
  [Specify the type of BD-J implementation (j2se, j2me). Default is j2se.])],
  [BDJ_TYPE=$withval],
  [BDJ_TYPE=j2se])

109 110 111 112 113 114
AC_ARG_WITH([bdj-bootclasspath],
  [AS_HELP_STRING([--with-bdj-bootclasspath=PATH],
  [Specify BD-J build-time bootclass path (example /opt/PhoneME/lib/btclasses.zip;/opt/PhoneME/lib/xmlparer.jar). Default is empty.])],
  [BDJ_BOOTCLASSPATH=$withval],
  [BDJ_BOOTCLASSPATH=])

115 116 117
AC_ARG_WITH([java9],
  [AS_HELP_STRING([--with-java9], [build with Java 9+ (drop support for Java <1.6) @<:@default=without@:>@])])

118
dnl required programs
119
AC_PROG_CC
120
AM_PROG_CC_C_O
121
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
gates's avatar
gates committed
122
AC_PROG_LIBTOOL
123

124
dnl required types
125
AC_TYPE_SIGNAL
126

127
dnl required headers
gates's avatar
gates committed
128
AC_CHECK_HEADERS([stdarg.h sys/types.h dirent.h errno.h libgen.h malloc.h])
129
AC_CHECK_HEADERS([stdlib.h mntent.h linux/cdrom.h inttypes.h strings.h])
130
AC_CHECK_HEADERS([sys/time.h time.h mntent.h])
131

132
dnl required structures
133 134
AC_STRUCT_DIRENT_D_TYPE

135
dnl required system services
136 137
AC_SYS_LARGEFILE

138
dnl required functions
139
AC_CHECK_FUNC([snprintf],, [AC_MSG_ERROR($function_not_found)])
140

141 142
dnl required libraries
dnl pthreads (not on win32)
143 144 145 146 147 148
AS_IF([test "${SYS}" != "mingw32"], [
  AC_CHECK_HEADERS([pthread.h], ,
    [AC_MSG_ERROR([pthread required])])
  AC_SEARCH_LIBS([pthread_create], [pthread], ,
    [AC_MSG_ERROR([pthread required])])
  AC_SEARCH_LIBS([dlopen], [dl])
149 150 151 152
  DLOPEN_LIBS="$ac_cv_search_dlopen"
  AS_CASE([$DLOPEN_LIBS],
    [no|none\ required], [DLOPEN_LIBS=""])
  AC_SUBST([DLOPEN_LIBS])
153
])
154

155
dnl libxml2 for metadata parser
156 157
AS_IF([test "x$with_libxml2" != "xno"], [
  PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6],
158
    [with_libxml2=yes; AC_DEFINE([HAVE_LIBXML2], [1],
159
        [Define to 1 if libxml2 is to be used for metadata parsing])])
160
  PACKAGES="$PACKAGES libxml-2.0"
161
])
162

163
dnl FreeType2
164
AS_IF([test "x$with_freetype" != "xno"], [
165
  PKG_CHECK_MODULES([FT2], [freetype2],
166
    [with_freetype=yes; AC_DEFINE([HAVE_FT2], 1, [Define this if you have FreeType2 library])])
167
  PACKAGES="$PACKAGES freetype2"
168 169 170 171 172 173

  dnl fontconfig support
  AS_IF([test "${SYS}" != "mingw32"], [
    AS_IF([test "x$with_fontconfig" != "xno"], [
      PKG_CHECK_MODULES([FONTCONFIG], [fontconfig],
        [with_fontconfig=yes; AC_DEFINE([HAVE_FONTCONFIG], 1, [Define this if you have fontconfig library])])
174
      PACKAGES="$PACKAGES fontconfig"
175
    ])
176 177 178
  ],[
    FONTCONFIG_LIBS="-lgdi32"
    AC_SUBST([FONTCONFIG_LIBS])
179
  ])
180
])
181

182 183 184
CC_CHECK_CFLAGS_APPEND([-Wall -Wdisabled-optimization -Wpointer-arith ]dnl
[-Wredundant-decls -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef ]dnl
[-Wmissing-prototypes -Wshadow])
185

186 187 188
CC_CHECK_CFLAGS_APPEND([-Werror=implicit-function-declaration ]dnl
                       [-Werror-implicit-function-declaration],
                       [break;])
189

190 191 192 193
CC_CHECK_WERROR
AS_IF([test "x$enable_werror" = "xyes"], [
  CFLAGS="${CFLAGS} $cc_cv_werror"
])
194

195 196 197 198 199 200 201
AS_IF([test "x$enable_extra_warnings" != "xno"], [
  CC_CHECK_CFLAGS_APPEND([-Wextra -Winline])
])

AS_IF([test "x$enable_optimizations" != "xno"], [
  CC_CHECK_CFLAGS_APPEND([-O3 -fomit-frame-pointer])
])
202

203
dnl use examples
204 205
AM_CONDITIONAL([USING_EXAMPLES], [ test $use_examples = "yes" ])

206
dnl use bdjava
Petri Hintukainen's avatar
Petri Hintukainen committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
case $host_cpu in
     x86_64) java_arch=amd64 ;;
     i?86)   java_arch=i386 ;;
     arm*)   java_arch=arm ;;
     *)      java_arch=$host_cpu ;;
esac
case $host_os in
     linux*)   java_os=linux ;;
     win*)     java_os=win32 ;;
     mingw*)   java_os=win32 ;;
     freebsd*) java_os=freebsd ;;
     solaris*) java_os=solaris ;;
     darwin*)  java_os=darwin ;;
     *)        java_os=$host_os ;;
esac

AS_IF([test "x${JDK_HOME}" != "x"], [
224 225 226 227 228 229
    BDJAVA_CFLAGS="-I${JDK_HOME}/include -I${JDK_HOME}/include/$java_os"

    temp_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$BDJAVA_CFLAGS $CPPFLAGS"
    AC_CHECK_HEADERS([jni.h], [], [AC_MSG_ERROR(could not find jni.h)])
    CPPFLAGS="$temp_CPPFLAGS"
Petri Hintukainen's avatar
Petri Hintukainen committed
230
], [
231
    BDJAVA_CFLAGS='-I${abs_top_srcdir}/jni -I${abs_top_srcdir}/jni/'"${java_os}"
Petri Hintukainen's avatar
Petri Hintukainen committed
232
])
233

234
AS_IF([test "x$use_bdjava_jar" = "xyes"], [
235

236 237 238 239 240
    dnl check for ant
    AC_CHECK_PROG(HAVE_ANT, [ant], yes, no)
    AS_IF([test "x$HAVE_ANT" = "xno"], [
        AC_MSG_ERROR([BD-J requires ANT, but ant was not found. Install ant or disable jar file building (--disable-bdjava-jar)])
    ])
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256

    AS_IF([test "x$with_java9" = "x" -a "$BDJ_TYPE" != "j2me"], [

        dnl check for javac
        AS_IF([test "x${JAVA_HOME}" != "x"],
              [AC_PATH_PROG(JAVAC, javac, none, ["${JAVA_HOME}/bin"])],
              [AC_PATH_PROG(JAVAC, javac, none)])
        AS_IF([test x"$JAVAC" = x"none"],
            [AC_MSG_WARN([javac not found. Disable jar file building (--disable-bdjava-jar), set JAVA_HOME or javac type with --with[out]-java9 option.])])

        dnl check for Java 9+
        javac_version=`"$JAVAC" -version 2>&1 | head -n 1`
        [with_java9=`echo "$javac_version" | grep -E -q '^javac\ (9|1[0-9])' && echo yes`]
    ])

    AS_IF([test "x$with_java9" = "xyes" -a "$BDJ_TYPE" != "j2me"], [java_code_version=1.6], [java_code_version=1.4])
257
])
258

Petri Hintukainen's avatar
Petri Hintukainen committed
259 260
AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$java_arch"], ["Defines the architecture of the java vm."])
AC_DEFINE_UNQUOTED([JDK_HOME], ["$JDK_HOME"], [""])
261
AM_CONDITIONAL([USING_BDJAVA_BUILD_JAR], [ test $use_bdjava_jar = "yes" ])
262
AM_CONDITIONAL([USING_JAVAC_9], [ test x"$with_java9" = x"yes" ])
263

264
dnl BD-J type
265 266 267 268 269 270
if test "$BDJ_TYPE" = "j2me"; then
  AC_DEFINE([HAVE_BDJ_J2ME], [1], [Define to 1 if using libbluray J2ME stack])
else
  BDJ_TYPE=j2se
fi
AC_SUBST(BDJ_TYPE)
271
AM_CONDITIONAL([BDJ_J2SE], [ test x"$BDJ_TYPE" != x"j2me" ])
272
dnl bootclasspath
273
AC_SUBST(BDJ_BOOTCLASSPATH)
274

275
dnl udf support (using git submodule)
Petri Hintukainen's avatar
Petri Hintukainen committed
276 277 278 279 280 281 282
if test ! -f "${srcdir}/contrib/libudfread/src/udfread.h"; then
    AC_MSG_ERROR("libudfread source tree not found")
fi
AC_CHECK_HEADERS([unistd.h fcntl.h])
AS_IF([test "${SYS}" != "mingw32"], [
    AC_CHECK_FUNC([pread],, [AC_DEFINE([NEED_PREAD_IMPL], [1], [Define to 1 to use inefficient pread() replacement])])
])
283

284
dnl generate documentation
285 286
DX_INIT_DOXYGEN(libbluray, doc/doxygen-config, [doc/doxygen])

287
dnl export library version number
288 289 290 291 292 293 294
BLURAY_VERSION_MAJOR=bluray_major()
AC_SUBST(BLURAY_VERSION_MAJOR)
BLURAY_VERSION_MINOR=bluray_minor()
AC_SUBST(BLURAY_VERSION_MINOR)
BLURAY_VERSION_MICRO=bluray_micro()
AC_SUBST(BLURAY_VERSION_MICRO)

295
dnl export library (.so) version
296 297 298
LT_VERSION_INFO="lt_current():lt_revision():lt_age()"
AC_SUBST(LT_VERSION_INFO)

299
dnl generate output files
300
AC_SUBST(BDJAVA_CFLAGS)
Petri Hintukainen's avatar
Petri Hintukainen committed
301
AC_CONFIG_FILES([Makefile src/libbluray.pc src/libbluray/bluray-version.h])
302
AC_OUTPUT
303

304
AC_SUBST([PACKAGES])
305 306 307 308 309 310 311

dnl ---------------------------------------------
dnl Some infos:
dnl ---------------------------------------------

echo "  Summary:"
echo "  --------"
312
echo "  BD-J type:                     $BDJ_TYPE"
313
echo "  build JAR:                     $use_bdjava_jar"
314 315 316 317 318 319
if test "x$use_bdjava_jar" = "xyes"; then
if test "x$javac_version" != "x"; then
echo "      javac version:             $javac_version"
fi
echo "      Java binary version:       $java_code_version"
fi
320 321 322
if test x"$BDJ_BOOTCLASSPATH" != x""; then
echo "  BD-J bootclasspath:            $BDJ_BOOTCLASSPATH"
fi
323
echo "  Font support (freetype2):      $with_freetype"
324 325 326 327
if [[ $with_freetype = "yes" ]]; then
if test "${SYS}" != "mingw32"; then
echo "  Use system fonts (fontconfig): $with_fontconfig"
else
328
echo "  Use system fonts:              yes"
329 330
fi
fi
331
echo "  Metadata support (libxml2):    $with_libxml2"
332
echo "  Build examples:                $use_examples"
333