Drop the x's from shell tests
[opusfile.git] / configure.ac
1 # autoconf source script for generating configure
2
3 dnl The package_version file will be automatically synced to the git revision
4 dnl by the update_version script when configured in the repository, but will
5 dnl remain constant in tarball releases unless it is manually edited.
6 m4_define([CURRENT_VERSION],
7           m4_esyscmd_s([ if test -e package_version || ./update_version; then
8                              . ./package_version
9                              printf "$PACKAGE_VERSION"
10                          else
11                              printf "unknown"
12                          fi ]))
13
14 AC_INIT([opusfile],[CURRENT_VERSION],[opus@xiph.org])
15 AC_CONFIG_SRCDIR([src/opusfile.c])
16
17 AC_USE_SYSTEM_EXTENSIONS
18 AC_SYS_LARGEFILE
19
20 AM_INIT_AUTOMAKE([1.11 foreign no-define])
21 AM_MAINTAINER_MODE([enable])
22 LT_INIT
23
24 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25
26 AC_CONFIG_MACRO_DIR([m4])
27
28 dnl Library versioning for libtool.
29 dnl Please update these for releases.
30 dnl CURRENT, REVISION, AGE
31 dnl - library source changed -> increment REVISION
32 dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
33 dnl - interfaces added -> increment AGE
34 dnl - interfaces removed -> AGE = 0
35
36 OP_LT_CURRENT=0
37 OP_LT_REVISION=1
38 OP_LT_AGE=0
39
40 AC_SUBST(OP_LT_CURRENT)
41 AC_SUBST(OP_LT_REVISION)
42 AC_SUBST(OP_LT_AGE)
43
44 CC_CHECK_CFLAGS_APPEND(
45   [-std=c89 -pedantic -Wall -Wextra -Wno-parentheses -Wno-long-long])
46
47 # Platform-specific tweaks
48 case $host in
49   *-mingw*)
50     # -std=c89 causes some warnings under mingw.
51     CC_CHECK_CFLAGS_APPEND([-U__STRICT_ANSI__])
52     # We need WINNT>=0x501 (WindowsXP) for getaddrinfo/freeaddrinfo.
53     # It's okay to define this even when HTTP support is disabled, as it only
54     #  affects header declarations, not linking (unless we actually use some
55     #  XP-only functions).
56     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x501,
57      [We need at least WindowsXP for getaddrinfo/freaddrinfo])
58     host_mingw=true
59     ;;
60 esac
61 AM_CONDITIONAL(OP_WIN32, test "$host_mingw" = "true")
62
63 AC_ARG_ENABLE([assertions],
64   AS_HELP_STRING([--enable-assertions], [Enable assertions in code]),,
65   enable_assertions=no)
66
67 AS_IF([test "$enable_assertions" = "yes"], [
68   AC_DEFINE([OP_ENABLE_ASSERTIONS], [1], [Enable assertions in code])
69 ])
70
71 AC_ARG_ENABLE([http],
72   AS_HELP_STRING([--disable-http], [Disable HTTP support]),,
73   enable_http=yes)
74
75 AM_COND_IF(OP_WIN32,
76   AS_IF([test "$enable_http" != "no"],
77     AC_CHECK_HEADER([winsock2.h],,
78       AC_MSG_WARN([HTTP support requires a Winsock socket library.])
79       enable_http=no
80     )
81   ),
82   AS_IF([test "$enable_http" != "no"],
83     AC_CHECK_HEADER([sys/socket.h],,
84       AC_MSG_WARN([HTTP support requires a POSIX socket library.])
85       enable_http=no
86     )
87   )
88 )
89
90 AS_IF([test "$enable_http" != "no"], [
91    openssl="openssl"
92    AC_DEFINE([OP_ENABLE_HTTP], [1], [Enable HTTP support])
93    PKG_CHECK_MODULES([URL_DEPS], [openssl])
94 ])
95 AM_CONDITIONAL(OP_ENABLE_HTTP, [test "$enable_http" != "no"])
96 AC_SUBST([openssl])
97
98 PKG_CHECK_MODULES([DEPS], [ogg >= 1.3 opus >= 1.0.1])
99
100 AC_ARG_ENABLE([fixed-point],
101   AS_HELP_STRING([--enable-fixed-point], [Enable fixed-point calculation]),,
102   enable_fixed_point=no)
103 AC_ARG_ENABLE([float],
104   AS_HELP_STRING([--disable-float], [Disable floating-point API]),,
105   enable_float=yes)
106
107 AS_IF([test "$enable_float" = "no"],
108   [enable_fixed_point=yes
109    AC_DEFINE([OP_DISABLE_FLOAT_API], [1], [Disable floating-point API])
110   ]
111 )
112
113 AS_IF([test "$enable_fixed_point" = "yes"],
114   [AC_DEFINE([OP_FIXED_POINT], [1], [Enable fixed-point calculation])],
115   [dnl This only has to be tested for if float->fixed conversions are required
116    AC_SEARCH_LIBS([lrintf], [m], [
117       AC_DEFINE([OP_HAVE_LRINTF], [1], [Enable use of lrintf function])
118       lrintf_notice="
119     Library for lrintf() ......... ${ac_cv_search_lrintf}"
120    ])
121   ]
122 )
123 lrintf_lib="$ac_cv_search_lrintf"
124 AS_IF([test "$ac_cv_search_lrintf" = "none required"],
125   [lrintf_lib=""]
126 )
127 AC_SUBST(lrintf_lib)
128
129 CC_ATTRIBUTE_VISIBILITY([default], [
130   CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
131 ])
132
133 dnl Check for doxygen
134 AC_ARG_ENABLE([doc],
135   AS_HELP_STRING([--disable-doc], [Do not build API documentation]),,
136   [enable_doc=yes]
137 )
138 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, yes, no)
139 if test "$HAVE_DOXYGEN" != "yes" -o "$enable_doc" != "yes" ; then
140   HAVE_DOXYGEN="no"
141   enable_doc="no"
142 fi
143 AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
144
145 AC_CONFIG_FILES([
146   Makefile
147   opusfile.pc
148   opusurl.pc
149   opusfile-uninstalled.pc
150   opusurl-uninstalled.pc
151   doc/Doxyfile
152 ])
153 AC_OUTPUT
154
155 AC_MSG_NOTICE([
156 ------------------------------------------------------------------------
157   $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
158
159     Assertions ................... ${enable_assertions}
160
161     HTTP support ................. ${enable_http}
162     Fixed-point .................. ${enable_fixed_point}
163     Floating-point API ........... ${enable_float}${lrintf_notice}
164
165     Hidden visibility ............ ${cc_cv_flag_visibility}
166
167     API documentation ............ ${enable_doc}
168 ------------------------------------------------------------------------
169 ])