configure.ac 4.59 KB
Newer Older
1
AC_INIT([libdvbpsi], [2.0.0-git])
Christophe Massiot's avatar
Christophe Massiot committed
2

Jean-Paul Saman's avatar
Jean-Paul Saman committed
3
AC_PREREQ([2.65])
Jean-Paul Saman's avatar
Jean-Paul Saman committed
4
AC_CONFIG_AUX_DIR([.auto])
Christophe Massiot's avatar
Christophe Massiot committed
5
AC_CANONICAL_SYSTEM
Jean-Paul Saman's avatar
Jean-Paul Saman committed
6
AC_CANONICAL_HOST
Jean-Paul Saman's avatar
Jean-Paul Saman committed
7
AC_CONFIG_SRCDIR([src/dvbpsi.c])
Christophe Massiot's avatar
Christophe Massiot committed
8

Jean-Paul Saman's avatar
Jean-Paul Saman committed
9
AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
10
AC_CONFIG_HEADERS(config.h)
Jean-Paul Saman's avatar
Jean-Paul Saman committed
11
AC_CONFIG_MACRO_DIR([m4])
12 13

AC_PROG_CC
Jean-Paul Saman's avatar
Jean-Paul Saman committed
14
AC_HEADER_STDC
Gildas Bazin's avatar
Gildas Bazin committed
15
AC_C_INLINE
16

17 18
AM_PROG_CC_C_O

Jean-Paul Saman's avatar
Jean-Paul Saman committed
19
dnl AC_LIBTOOL_WIN32_DLL
20
AM_PROG_LIBTOOL
Jean-Paul Saman's avatar
Jean-Paul Saman committed
21
LT_INIT([win32-dll])
22

23 24 25 26
dnl store CFLAGS from user
CFLAGS_save="${CFLAGS}"

dnl add features to CFLAGS
27
CFLAGS_dist="-Wall -std=gnu99 -D_GNU_SOURCE"
28
CFLAGS_dist="${CFLAGS_dist} -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
29

Christophe Massiot's avatar
Christophe Massiot committed
30
dnl check the operating system
31 32
case "${target_os}" in
  darwin*)
33
    SYS=darwin
34
    CFLAGS_dist="${CFLAGS_dist} -no-cpp-precomp"
Jean-Paul Saman's avatar
Jean-Paul Saman committed
35
    ;;
36 37 38 39 40 41 42 43 44
  *mingw32*)
    SYS=mingw32
    CFLAGS_dist="${CFLAGS_dist} -Wno-cast-qual"
    AC_DEFINE([WIN32],[1],["Define to 1 if building for windows with mingw32"])
    ;;
   *)
    SYS=linux
    CFLAGS_dist="${CFLAGS_dist} -Wcast-qual"
   ;;
Christophe Massiot's avatar
Christophe Massiot committed
45 46
esac

47 48 49 50 51 52 53 54
dnl --enable-debug
AC_ARG_ENABLE(debug,
[  --enable-debug          Enable debug mode (default disabled)],
[case "${enableval}" in
  yes) debug=true ;;
  no)  debug=false ;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false])
55
if test "$debug" = "true"
56
then
57
  CFLAGS_dist="${CFLAGS_dist} -Werror -ggdb3"
58 59
fi

60 61 62 63 64 65 66 67 68 69 70 71 72 73
dnl --enable-gcc-sanitize
dnl NOTE: Only use with more then 8GB of memory in your system
AC_ARG_ENABLE(gcc-sanitize,
[  --enable-gcc-sanitize   Use gcc address sanitizer (default disabled)],
[case "${enableval}" in
  yes) sanitize=true ;;
  no)  sanitize=false;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-gcc-sanitize) ;;
esac],[sanitize=false])
if test "$sanitize" = "true"
then
  CFLAGS_dist="${CFLAG_dist} -fsanitize=address -fno-omit-frame-pointer"
fi

74 75 76 77 78 79 80 81
dnl --enable-release
AC_ARG_ENABLE(release,
[  --enable-release        Enable release mode (default disabled)],
[case "${enableval}" in
  yes) release=true ;;
  no)  release=false ;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-release) ;;
esac],[release=false])
82 83
if test "$release" != "true"; then
  CFLAGS_dist="${CFLAGS_dist} -DDVBPSI_DIST"
84 85
fi

86 87
dnl --enable-compat
AC_ARG_ENABLE(compat,
88
[  --enable-compat         Enable API compatibility layer (default enabled)],
89 90 91 92
[case "${enableval}" in
  yes) compat=true ;;
  no)  compat=false ;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-compat) ;;
93
esac],[compat=true])
94 95 96 97
if test "$compat" = "true"; then
  CFLAGS_dist="${CFLAGS_dist} -DDVBPSI_USE_DEPRECATED_DR_API"
fi

98 99 100
dnl compile feature tests
CFLAGS="${CFLAGS_save} ${CFLAGS_dist}"

101
dnl Check for headers
Jean-Paul Saman's avatar
Jean-Paul Saman committed
102
AC_CHECK_HEADERS([stdbool.h stdint.h inttypes.h getopt.h strings.h sys/time.h])
103
dnl AC_CHECK_FUNCS([gettimeofday])
104

Jean-Paul Saman's avatar
Jean-Paul Saman committed
105
AC_CHECK_HEADERS([sys/socket.h], [ac_have_sys_socket_h=yes])
106 107
AM_CONDITIONAL(HAVE_SYS_SOCKET_H, test "${ac_have_sys_socket_h}" = "yes")

108 109 110 111 112 113
AC_CHECK_HEADERS([net/if.h], [], [],
  [
    #include <sys/types.h>
    #include <sys/socket.h>
  ])

Gildas Bazin's avatar
Gildas Bazin committed
114 115 116 117 118 119 120 121 122 123 124 125 126
dnl Check for variadic macros
AC_CACHE_CHECK([for variadic cpp macros],
    [ac_cv_cpp_variadic_macros],
    [AC_TRY_COMPILE(
         [#include <stdio.h>
          #define a(b,c...) printf(b,##c)],
         [a("foo");a("%s","bar");a("%s%s","baz","quux");],
         ac_cv_cpp_variadic_macros=yes,
         ac_cv_cpp_variadic_macros=no)])
if test "${ac_cv_cpp_variadic_macros}" != "no"; then
    AC_DEFINE(HAVE_VARIADIC_MACROS, 1, Support for variadic macros)
fi

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
dnl Check for asprintf(). Systems with asprintf() must also have vasprintf(),
dnl so it is not checked separately.
AC_CACHE_CHECK([for asprintf()],
    [ac_cv_asprintf],
    [AC_COMPILE_IFELSE([
        AC_LANG_SOURCE([[
            #include <stdio.h>
            #include <stdlib.h>
            int main(void) {
                char *text = NULL;
                int ret = asprintf(&text, "test");
                if (ret >= 0) free(text);
                return 0;
            }
        ]])],
        ac_cv_asprintf=yes,
        ac_cv_asprintf=no)])
if test "${ac_cv_asprintf}" != "no"; then
    AC_DEFINE(HAVE_ASPRINTF, 1, [Support for asprintf() and vasprintf()])
fi

148 149 150
dnl
dnl Generate Makefiles and other output files
dnl
Jean-Paul Saman's avatar
Jean-Paul Saman committed
151
AC_CONFIG_FILES([Makefile
152 153
           src/Makefile
           examples/Makefile
154
           examples/dvbinfo/Makefile
155 156
           misc/Makefile
           doc/Makefile
157 158
           libdvbpsi.pc
           libdvbpsi.spec])
Jean-Paul Saman's avatar
Jean-Paul Saman committed
159
AC_OUTPUT
160 161 162 163 164 165
echo "
libdvbpsi configuration
-----------------------
libdvbpsi version     : ${VERSION}
debug                 : ${debug}
release               : ${release}
166
compatibility old api : ${compat}
167
compile flags         : ${CFLAGS}
168
build for             : ${SYS}
169
"