Update and improve autotools build

- INCLUDES is deprecated, and CPPFLAGS is an user-defined
  variable, use the proper AM_CPPFLAGS instead

- Remove FLAC__INLINE definition, providing proper
  replacement for MSVC compilers.

- Detect if we have C99 's lround and provide a replacement
  for windows...
This commit is contained in:
Cristian Rodríguez 2012-04-07 19:24:21 -03:00 committed by Erik de Castro Lopo
parent 8340ab3bc8
commit 9b7cb22f84
30 changed files with 68 additions and 86 deletions

View File

@ -18,27 +18,18 @@
# NOTE that for many of the AM_CONDITIONALs we use the prefix FLaC__
# instead of FLAC__ since autoconf triggers off 'AC_' in strings
AC_INIT(src/flac/main.c)
AM_INIT_AUTOMAKE(flac, 1.2.1)
AC_PREREQ(2.60)
AC_INIT([flac], [1.2.1])
AC_CONFIG_SRCDIR([src/flac/main.c])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign -Wall tar-pax no-dist-gzip dist-xz subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
#Prefer whatever the current ISO standard is.
AC_PROG_CC_STDC
AC_USE_SYSTEM_EXTENSIONS
# Enable the generation of shared libraries under Win32
AC_LIBTOOL_WIN32_DLL
# We need two libtools, one that builds both shared and static, and
# one that builds only static. This is because the resulting libtool
# does not allow us to choose which to build at runtime.
AM_PROG_LIBTOOL
sed -e 's/^build_old_libs=yes/build_old_libs=no/' libtool > libtool-disable-static
chmod +x libtool-disable-static
AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
AC_CONFIG_MACRO_DIR([m4])
LT_INIT([win32-dll disable-static pic-only])
AM_PROG_AS
AC_PROG_CXX
AC_PROG_MAKE_SET
@ -47,7 +38,7 @@ AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
AC_CHECK_SIZEOF(void*,0)
AC_SEARCH_LIBS([lround],[m], [AC_DEFINE(HAVE_LROUND,1,lround support)])
#@@@ new name is AC_CONFIG_HEADERS
AM_CONFIG_HEADER(config.h)
@ -348,18 +339,13 @@ AC_DEFINE(FLAC__HAS_GAS)
AH_TEMPLATE(FLAC__HAS_GAS, [define if you are compiling for PowerPC and have the 'gas' assembler])
fi
CPPFLAGS='-I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include'" $CPPFLAGS"
if test "x$debug" = xtrue; then
CPPFLAGS="-DDEBUG -DFLaC__INLINE= $CPPFLAGS"
CPPFLAGS="-DDEBUG $CPPFLAGS"
CFLAGS="-g $CFLAGS"
else
CPPFLAGS="-DNDEBUG $CPPFLAGS"
# $ac_cv_c_inline from AC_C_INLINE
if test "x$ac_cv_c_inline" != xno ; then
CPPFLAGS="-DFLaC__INLINE=$ac_cv_c_inline $CPPFLAGS"
fi
if test "x$GCC" = xyes; then
CFLAGS="-O3 -funroll-loops -finline-functions -Wall -W -Winline $CFLAGS"
CFLAGS="-O3 -funroll-loops -Wall -W -Winline $CFLAGS"
fi
fi

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
example_c_decode_file.dsp \
example_c_decode_file.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = example_c_decode_file
example_c_decode_file_LDADD = \
$(top_builddir)/src/libFLAC/libFLAC.la \

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
example_c_encode_file.dsp \
example_c_encode_file.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = example_c_encode_file
example_c_encode_file_LDADD = \
$(top_builddir)/src/libFLAC/libFLAC.la \

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
example_cpp_decode_file.dsp \
example_cpp_decode_file.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = example_cpp_decode_file
example_cpp_decode_file_LDADD = \
$(top_builddir)/src/libFLAC++/libFLAC++.la \

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
example_cpp_encode_file.dsp \
example_cpp_encode_file.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = example_cpp_encode_file
example_cpp_encode_file_LDADD = \
$(top_builddir)/src/libFLAC++/libFLAC++.la \

View File

@ -29,7 +29,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
flaccppincludedir = $(includedir)/FLAC++
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
flaccppinclude_HEADERS = \
all.h \
decoder.h \

View File

@ -18,7 +18,7 @@
bin_PROGRAMS = flac
AM_CFLAGS = @OGG_CFLAGS@
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
Makefile.lite.iffscan \

View File

@ -35,7 +35,7 @@ m4data_DATA = libFLAC++.m4
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = flac++.pc
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
flac++.pc.in \

View File

@ -28,6 +28,7 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
lib_LTLIBRARIES = libFLAC.la
if DEBUG
DEBUGCFLAGS = -DFLAC__OVERFLOW_DETECT
@ -77,7 +78,7 @@ endif
endif
endif
libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@
libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ -lm
SUBDIRS = $(ARCH_SUBDIRS) include .
@ -104,7 +105,7 @@ extra_ogg_sources = \
ogg_mapping.c
endif
# see 'http://www.gnu.org/software/libtool/manual.html#Libtool-versioning' for numbering convention
libFLAC_la_LDFLAGS = -version-info 10:0:2 -lm $(LOCAL_EXTRA_LDFLAGS) @LT_NO_UNDEFINED@
libFLAC_la_LDFLAGS = -version-info 10:0:2 $(LOCAL_EXTRA_LDFLAGS) @LT_NO_UNDEFINED@
libFLAC_la_SOURCES = \
bitmath.c \
bitreader.c \

View File

@ -117,10 +117,6 @@ static const unsigned char byte_to_unary_table[] = {
#define FLAC__U64L(x) x##LLU
#endif
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
/* WATCHOUT: assembly routines rely on the order in which these fields are declared */
struct FLAC__BitReader {
/* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */
@ -138,7 +134,7 @@ struct FLAC__BitReader {
FLAC__CPUInfo cpu_info;
};
static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, uint32_t word)
static inline void crc16_update_word_(FLAC__BitReader *br, uint32_t word)
{
register unsigned crc = br->read_crc16;
#if FLAC__BYTES_PER_WORD == 4
@ -373,17 +369,17 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br)
return br->read_crc16;
}
FLaC__INLINE FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br)
inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br)
{
return ((br->consumed_bits & 7) == 0);
}
FLaC__INLINE unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
inline unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
{
return 8 - (br->consumed_bits & 7);
}
FLaC__INLINE unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br)
inline unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br)
{
return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits;
}
@ -499,7 +495,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *va
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val)
inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val)
{
FLAC__uint32 x8, x32 = 0;

View File

@ -75,10 +75,6 @@ static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(uint32_
#define FLAC__U64L(x) x##LLU
#endif
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
struct FLAC__BitWriter {
uint32_t *buffer;
uint32_t accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */
@ -270,7 +266,7 @@ void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw)
(void)bw;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits)
{
unsigned n;
@ -308,7 +304,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsign
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits)
{
register unsigned left;
@ -347,7 +343,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FL
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits)
{
/* zero-out unused bits */
if(bits < 32)
@ -356,7 +352,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLA
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits)
{
/* this could be a little faster but it's not used for much */
if(bits > 32) {
@ -368,7 +364,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FL
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val)
inline FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val)
{
/* this doesn't need to be that fast as currently it is only used for vorbis comments */
@ -384,7 +380,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__Bit
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals)
inline FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals)
{
unsigned i;

View File

@ -31,7 +31,7 @@
SUFFIXES = .nasm .lo
STRIP_NON_ASM = sh $(top_srcdir)/strip_non_asm_libtool_args.sh
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
.nasm.lo:
$(LIBTOOL) --tag=CC --mode=compile $(STRIP_NON_ASM) $(NASM) -f $(OBJ_FORMAT) -d OBJ_FORMAT_$(OBJ_FORMAT) -i$(srcdir)/ $< -o $@

View File

@ -57,4 +57,10 @@
#define flac_min(a,b) __min(a,b)
#endif
#if !defined(__cplusplus) && defined(_MSC_VER)
#ifndef inline
#define inline __inline
#endif
#endif
#endif

View File

@ -38,6 +38,7 @@
#include "FLAC/format.h"
#include "private/bitmath.h"
#include "private/lpc.h"
#include "private/macros.h"
#if defined DEBUG || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE
#include <stdio.h>
#endif
@ -52,6 +53,18 @@
#define M_LN2 0.69314718055994530942
#endif
#if !defined(HAVE_LROUND)
#if defined(_MSC_VER)
#include <float.h>
#define copysign _copysign
#elif defined(__GNUC__)
#define copysign __builtin_copysign
#endif
static inline long int lround(double x) {
return (long)(x + copysign (0.5, x));
}
//If this fails, we are in the precence of a mid 90's compiler..move along...
#endif
void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len)
{
@ -199,14 +212,8 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
FLAC__int32 q;
for(i = 0; i < order; i++) {
error += lp_coeff[i] * (1 << *shift);
#if 1 /* unfortunately lround() is C99 */
if(error >= 0.0)
q = (FLAC__int32)(error + 0.5);
else
q = (FLAC__int32)(error - 0.5);
#else
q = lround(error);
#endif
#ifdef FLAC__OVERFLOW_DETECT
if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);
@ -234,14 +241,7 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
#endif
for(i = 0; i < order; i++) {
error += lp_coeff[i] / (1 << nshift);
#if 1 /* unfortunately lround() is C99 */
if(error >= 0.0)
q = (FLAC__int32)(error + 0.5);
else
q = (FLAC__int32)(error - 0.5);
#else
q = lround(error);
#endif
#ifdef FLAC__OVERFLOW_DETECT
if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);

View File

@ -68,9 +68,6 @@
#include "private/stream_encoder_framing.h"
#include "private/window.h"
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
/* Exact Rice codeword length calculation is off by default. The simple
* (and fast) estimation (of how many bits a residual value will be
@ -3886,7 +3883,7 @@ void precompute_partition_info_escapes_(
}
#ifdef EXACT_RICE_BITS_CALCULATION
static FLaC__INLINE unsigned count_rice_bits_in_partition_(
static inline unsigned count_rice_bits_in_partition_(
const unsigned rice_parameter,
const unsigned partition_samples,
const FLAC__int32 *residual
@ -3901,7 +3898,7 @@ static FLaC__INLINE unsigned count_rice_bits_in_partition_(
return partition_bits;
}
#else
static FLaC__INLINE unsigned count_rice_bits_in_partition_(
static inline unsigned count_rice_bits_in_partition_(
const unsigned rice_parameter,
const unsigned partition_samples,
const FLAC__uint64 abs_residual_partition_sum

View File

@ -18,7 +18,7 @@
bin_PROGRAMS = metaflac
AM_CFLAGS = @OGG_CFLAGS@
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
metaflac.dsp \

View File

@ -17,7 +17,7 @@
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_LTLIBRARIES = libplugin_common.la

View File

@ -31,8 +31,7 @@ noinst_HEADERS = \
tag.h
AM_CFLAGS = @OGG_CFLAGS@ @XMMS_CFLAGS@
INCLUDES = -I$(top_srcdir)/src
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src
if FLaC__INSTALL_XMMS_PLUGIN_LOCALLY
xmmsinputplugindir = $(HOME)/.xmms/Plugins
else

View File

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include/share
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/include/share
noinst_LIBRARIES = libgetopt.a

View File

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_LTLIBRARIES = libgrabbag.la

View File

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include/share
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/include/share
noinst_LTLIBRARIES = libreplaygain_analysis.la

View File

@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = foreign
SUBDIRS = include .
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/include/share
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/include/share
noinst_LTLIBRARIES = libreplaygain_synthesis.la

View File

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include/share
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/include/share
noinst_LTLIBRARIES = libutf8.la

View File

@ -20,6 +20,7 @@ EXTRA_DIST = \
test_cuesheet.dsp \
test_cuesheet.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = test_cuesheet
test_cuesheet_SOURCES = \
main.c

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
test_picture.dsp \
test_picture.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = test_picture
test_picture_SOURCES = \
main.c

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
test_libFLAC++.dsp \
test_libFLAC++.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = test_libFLAC++
test_libFLAC___LDADD = \
$(top_builddir)/src/share/grabbag/libgrabbag.la \

View File

@ -20,7 +20,7 @@ EXTRA_DIST = \
test_libFLAC.dsp \
test_libFLAC.vcproj
INCLUDES = -I$(top_srcdir)/src/libFLAC/include
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src/libFLAC/include
noinst_PROGRAMS = test_libFLAC
test_libFLAC_LDADD = \

View File

@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INCLUDES = -I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_LTLIBRARIES = libtest_libs_common.la

View File

@ -22,7 +22,7 @@ EXTRA_DIST = \
AM_CFLAGS = @OGG_CFLAGS@
INCLUDES =
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = test_seeking
test_seeking_LDADD = \

View File

@ -19,7 +19,7 @@ EXTRA_DIST = \
Makefile.lite \
test_streams.dsp \
test_streams.vcproj
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = test_streams
test_streams_SOURCES = \
main.c