configure.ac 4.13 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 4
AC_PREREQ([2.50])
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_CONFIG_SRCDIR([src/dvbpsi.c])
Christophe Massiot's avatar
Christophe Massiot committed
7

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

12
dnl AC_CANONICAL_HOST
13 14
AC_PROG_CC
AC_STDC_HEADERS
Gildas Bazin's avatar
Gildas Bazin committed
15
AC_C_INLINE
16

17 18
AM_PROG_CC_C_O

19
AC_LIBTOOL_WIN32_DLL
20 21
AM_PROG_LIBTOOL

Jean-Paul Saman's avatar
Jean-Paul Saman committed
22 23 24 25
dnl store CFLAGS from user
CFLAGS_save="${CFLAGS}"

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

Christophe Massiot's avatar
Christophe Massiot committed
29
dnl check the operating system
30 31
case "${target_os}" in
  darwin*)
32
    SYS=darwin
Jean-Paul Saman's avatar
Jean-Paul Saman committed
33
    CFLAGS_dist="${CFLAGS_dist} -no-cpp-precomp"
Jean-Paul Saman's avatar
Jean-Paul Saman committed
34
    ;;
35 36 37 38 39 40 41 42 43
  *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
44 45
esac

46 47 48 49 50 51 52 53
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])
54
if test "$debug" = "true"
55
then
56
  CFLAGS_dist="${CFLAGS_dist} -Werror -ggdb3"
57 58
fi

59 60 61 62 63 64 65 66 67 68 69 70 71 72
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

73 74 75 76 77 78 79 80
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])
Jean-Paul Saman's avatar
Jean-Paul Saman committed
81 82
if test "$release" != "true"; then
  CFLAGS_dist="${CFLAGS_dist} -DDVBPSI_DIST"
83 84
fi

Jean-Paul Saman's avatar
Jean-Paul Saman committed
85 86 87
dnl compile feature tests
CFLAGS="${CFLAGS_save} ${CFLAGS_dist}"

88
dnl Check for headers
Jean-Paul Saman's avatar
Jean-Paul Saman committed
89
AC_CHECK_HEADERS([stdbool.h stdint.h inttypes.h getopt.h strings.h sys/time.h])
90
dnl AC_CHECK_FUNCS([gettimeofday])
91

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

95 96 97 98 99 100
AC_CHECK_HEADERS([net/if.h], [], [],
  [
    #include <sys/types.h>
    #include <sys/socket.h>
  ])

Gildas Bazin's avatar
Gildas Bazin committed
101 102 103 104 105 106 107 108 109 110 111 112 113
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

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
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

Jean-Paul Saman's avatar
Jean-Paul Saman committed
135 136 137
dnl
dnl Generate Makefiles and other output files
dnl
138 139 140
AC_OUTPUT([Makefile
           src/Makefile
           examples/Makefile
141
           examples/dvbinfo/Makefile
142 143
           misc/Makefile
           doc/Makefile
144 145
           libdvbpsi.pc
           libdvbpsi.spec])
146 147 148 149 150 151 152

echo "
libdvbpsi configuration
-----------------------
libdvbpsi version     : ${VERSION}
debug                 : ${debug}
release               : ${release}
Jean-Paul Saman's avatar
Jean-Paul Saman committed
153
compile flags         : ${CFLAGS}
154
build for             : ${SYS}
155
"