build-sys: Move to compiling with C11 support

This is needed for building with anonymous unions. A bunch of calls to
fail() that used to mysteriously work need fixing -- fail() is a macro
that takes a printf-style message as an argument. Not passing this
somehow worked with the previous compiler flags, but breaks with
-std=c11.
This commit is contained in:
Arun Raghavan 2016-02-17 19:47:05 +05:30
parent 8949ed96c6
commit aa02e1654b
14 changed files with 98 additions and 20 deletions

View file

@ -80,7 +80,6 @@ AC_PROG_LN_S
# CC
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
# Only required if you want the WebRTC canceller -- no runtime dep on
# libstdc++ otherwise
@ -177,6 +176,11 @@ esac
#### Compiler flags ####
AX_CHECK_COMPILE_FLAG([-std=c11],
[],
[AC_MSG_ERROR([*** Compiler does not support -std=c11])],
[-pedantic -Werror])
AX_APPEND_COMPILE_FLAGS(
[-Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto],
[], [-pedantic -Werror])

View file

@ -0,0 +1,74 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

View file

@ -48,7 +48,7 @@ AM_CPPFLAGS = \
-DPA_SRCDIR=\"$(abs_srcdir)\" \
-DPA_BUILDDIR=\"$(abs_builddir)\" \
-DPULSE_LOCALEDIR=\"$(localedir)\"
AM_CFLAGS = \
AM_CFLAGS = -std=c11 \
$(PTHREAD_CFLAGS)
AM_CXXFLAGS = -std=c++11 \
$(PTHREAD_CFLAGS)

View file

@ -80,7 +80,7 @@ static void connect(const char *name, int *try) {
/* Connect the context */
if (pa_context_connect(context, NULL, 0, NULL) < 0) {
fprintf(stderr, "pa_context_connect() failed.\n");
fail();
ck_abort();
}
ret = pa_threaded_mainloop_start(mainloop);
@ -144,7 +144,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
default:
case PA_STREAM_FAILED:
fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
fail();
ck_abort();
}
}
@ -190,7 +190,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED:
default:
fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
fail();
ck_abort();
}
}

View file

@ -118,7 +118,7 @@ static void run_mix_test(
i,
samples[i], samples_ref[i],
samples0[i], samples1[i]);
fail();
ck_abort();
}
}
}

View file

@ -70,7 +70,7 @@ static void run_remap_test_float(
pa_log_debug("Correctness test failed: align=%d", align);
pa_log_debug("%d: %.24f != %.24f\n", i,
out[i], out_ref[i]);
fail();
ck_abort();
}
}
}
@ -123,7 +123,7 @@ static void run_remap_test_s16(
if (abs(out[i] - out_ref[i]) > 3) {
pa_log_debug("Correctness test failed: align=%d", align);
pa_log_debug("%d: %d != %d\n", i, out[i], out_ref[i]);
fail();
ck_abort();
}
}
}

View file

@ -65,7 +65,7 @@ static void run_conv_test_float_to_s16(
if (abs(samples[i] - samples_ref[i]) > 1) {
pa_log_debug("Correctness test failed: align=%d", align);
pa_log_debug("%d: %04hx != %04hx (%.24f)\n", i, samples[i], samples_ref[i], floats[i]);
fail();
ck_abort();
}
}
}
@ -115,7 +115,7 @@ static void run_conv_test_s16_to_float(
if (fabsf(floats[i] - floats_ref[i]) > 0.0001f) {
pa_log_debug("Correctness test failed: align=%d", align);
pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]);
fail();
ck_abort();
}
}
}

View file

@ -78,7 +78,7 @@ static void run_volume_test(
pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
pa_log_debug("%d: %04hx != %04hx (%04hx * %08x)\n", i, samples[i], samples_ref[i],
samples_orig[i], volumes[i % channels]);
fail();
ck_abort();
}
}
}

View file

@ -48,7 +48,7 @@ static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata
if ((now - start) >= 30) {
m->quit(m, 1);
fprintf(stderr, "Test failed\n");
fail();
ck_abort();
} else
raise(SIGUSR1);
}
@ -78,7 +78,7 @@ START_TEST (cpulimit_test) {
if ((now - start) >= 30) {
fprintf(stderr, "Test failed\n");
fail();
ck_abort();
break;
}
}

View file

@ -100,7 +100,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
default:
case PA_STREAM_FAILED:
fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
fail();
ck_abort();
}
}
@ -151,7 +151,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED:
default:
fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
fail();
ck_abort();
}
}

View file

@ -39,7 +39,7 @@ START_TEST (getbinaryname_test) {
if (!pa_get_binary_name(exename, allocated)) {
pa_log_error("failed to read binary name");
pa_xfree(exename);
fail();
ck_abort();
}
if (strlen(exename) < allocated - 1) {

View file

@ -144,7 +144,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED:
default:
pa_log_error("Context error: %s", pa_strerror(pa_context_errno(c)));
fail();
ck_abort();
}
}

View file

@ -65,7 +65,7 @@ START_TEST (mult_s16_test) {
if (a != b) {
pa_log_debug("%d: %d != %d", i, a, b);
fail();
ck_abort();
}
}

View file

@ -106,7 +106,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
default:
case PA_STREAM_FAILED:
fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s))));
fail();
ck_abort();
}
}
@ -148,7 +148,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED:
default:
fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
fail();
ck_abort();
}
}