ref: 73cb39b4e716b4adf974cafc824c601d3e1e963a
parent: 5e56ae8b017a1475f736a6fa111ea4b960e76aab
author: Boris-Chengbiao Zhou <bobo1239@web.de>
date: Tue Jan 23 23:39:23 EST 2018
Add CMake build system and setup CI on Travis and AppVeyor This commit adds a new CMake-based build system. The build time configuration should match the one by autoconf. Then this build system gets tested on Travis (Linux) and AppVeyor (Windows; MSVC and MinGW). Additionally on AppVeyor, a build artifact is produced for easier distribution to Windows. Some minor changes are introduced to fix compilation on Windows. This commit is based on previous attempts at a CMake-based build by Jean-Michaël Celerier (jcelerier) and Matthew Sitton (mdsitton).
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-*.cm*
+# *.cm* # This line is broken it matches all files.
*.dat
*.gz
*.la
@@ -29,6 +29,7 @@
libsamplerate-*.tar.bz2
compile
config.*
+!/config.h.in
configure
depcomp
doc/ChangeLog
@@ -53,3 +54,4 @@
tests/src-evaluate
*.log
*.trs
+build/
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,15 @@
- sudo apt-get update
- sudo apt-get install -y autoconf automake-1.15 pkg-config m4 libsndfile-dev libfftw3-dev libasound2-dev
+env:
+ - AUTOGEN=true CMAKE_SHARED=OFF
+ - AUTOGEN=false CMAKE_SHARED=ON
+
script:
- - ./autogen.sh
- - ./configure
- - make distcheck
+ - if $AUTOGEN; then ./autogen.sh && ./configure && make distcheck; fi
+ - mkdir build
+ - cd build
+ - cmake -DBUILD_SHARED_LIBS=$CMAKE_SHARED ..
+ - cat config.h
+ - make
+ - make test
--- /dev/null
+++ b/CMakeLists.txt
@@ -1,0 +1,141 @@
+cmake_minimum_required(VERSION 3.1)
+project(libsamplerate VERSION 0.1.9 LANGUAGES C)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
+
+include(TestBigEndian)
+include(CheckFunctionExists)
+include(CheckIncludeFiles)
+include(CheckSymbolExists)
+include(CheckTypeSize)
+include(ClipMode)
+
+set(SAMPLERATE_SRC
+ ${PROJECT_SOURCE_DIR}/src/samplerate.c
+ ${PROJECT_SOURCE_DIR}/src/src_linear.c
+ ${PROJECT_SOURCE_DIR}/src/src_sinc.c
+ ${PROJECT_SOURCE_DIR}/src/src_zoh.c)
+
+if(WIN32)
+ set(OS_IS_WIN32 TRUE)
+ set(SAMPLERATE_SRC
+ ${SAMPLERATE_SRC}
+ ${PROJECT_SOURCE_DIR}/Win32/libsamplerate-0.def)
+ include_directories(Win32)
+endif()
+
+test_big_endian(CPU_IS_BIG_ENDIAN)
+if(CPU_IS_BIG_ENDIAN)
+ set(CPU_IS_LITTLE_ENDIAN 0)
+else()
+ set(CPU_IS_LITTLE_ENDIAN 1)
+endif()
+
+check_function_exists(pow RESULT)
+if(NOT RESULT)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES m)
+ set(NEED_MATH)
+endif()
+check_function_exists(alarm HAVE_ALARM)
+check_function_exists(lrint HAVE_LRINT)
+check_function_exists(lrintf HAVE_LRINTF)
+check_function_exists(signal HAVE_SIGNAL)
+
+check_include_files(stdint.h HAVE_STDINT)
+check_include_files(sys/times.h HAVE_SYS_TIMES_H)
+
+check_symbol_exists(SIGALRM signal.h HAVE_SIGALRM)
+
+check_type_size(int SIZEOF_INT)
+check_type_size(long SIZEOF_LONG)
+
+# This will set CPU_CLIPS_NEGATIVE and CPU_CLIPS_POSITIVE
+clip_mode()
+
+find_package(ALSA)
+set(HAVE_ALSA ${ALSA_FOUND})
+if(ALSA_FOUND)
+ include_directories("${ALSA_INCLUDE_DIR}")
+endif()
+
+find_package(Sndfile)
+set(HAVE_SNDFILE ${SNDFILE_FOUND})
+if(SNDFILE_FOUND)
+ include_directories("${SNDFILE_INCLUDE_DIR}")
+endif()
+
+find_package(FFTW)
+set(HAVE_FFTW3 ${FFTW_FOUND})
+if(FFTW_FOUND)
+ include_directories("${FFTW_INCLUDE_DIR}")
+endif()
+
+configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+add_library(samplerate ${SAMPLERATE_SRC})
+
+if(BUILD_SHARED_LIBS AND WIN32)
+ if (MSVC)
+ set_target_properties(samplerate PROPERTIES OUTPUT_NAME "libsamplerate-0")
+ else()
+ set_target_properties(samplerate PROPERTIES OUTPUT_NAME "samplerate-0")
+ endif()
+endif()
+
+target_include_directories(samplerate PUBLIC
+ ${PROJECT_SOURCE_DIR}/src
+ ${CMAKE_CURRENT_BINARY_DIR})
+
+enable_testing()
+
+file(GLOB TEST_SRCS ${PROJECT_SOURCE_DIR}/tests/*_test.c)
+
+foreach(testSrc ${TEST_SRCS})
+ get_filename_component(testName ${testSrc} NAME_WE)
+ add_executable(${testName}
+ ${testSrc}
+ ${PROJECT_SOURCE_DIR}/tests/util.c
+ ${PROJECT_SOURCE_DIR}/tests/calc_snr.c)
+ target_link_libraries(${testName} PUBLIC samplerate ${CMAKE_REQUIRED_LIBRARIES})
+ if(FFTW_FOUND)
+ target_link_libraries(${testName} PUBLIC ${FFTW_LIBRARY})
+ endif()
+ add_test(NAME ${testName} COMMAND ${testName})
+endforeach(testSrc)
+
+set(EXAMPLE_SRCS
+ ${PROJECT_SOURCE_DIR}/examples/sndfile-resample.c
+ ${PROJECT_SOURCE_DIR}/examples/timewarp-file.c
+ ${PROJECT_SOURCE_DIR}/examples/varispeed-play.c)
+
+foreach(exampleSrc ${EXAMPLE_SRCS})
+ get_filename_component(exampleName ${exampleSrc} NAME_WE)
+ add_executable(${exampleName}
+ ${exampleSrc}
+ ${PROJECT_SOURCE_DIR}/examples/audio_out.c)
+ target_link_libraries(${exampleName} PUBLIC samplerate ${CMAKE_REQUIRED_LIBRARIES})
+ if(ALSA_FOUND)
+ target_link_libraries(${exampleName} PUBLIC ${ALSA_LIBRARY})
+ endif()
+ if(SNDFILE_FOUND)
+ target_link_libraries(${exampleName} PUBLIC ${SNDFILE_LIBRARY})
+ endif()
+ if(WIN32)
+ target_link_libraries(${exampleName} PUBLIC winmm)
+ endif()
+endforeach(exampleSrc)
+
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(exec_prefix "\${prefix}")
+set(includedir "\${prefix}/include")
+set(libdir "\${exec_prefix}/lib")
+set(VERSION "${PROJECT_VERSION}")
+if(NEED_MATH)
+ set(LIBS "-lm")
+endif()
+configure_file(samplerate.pc.in samplerate.pc @ONLY)
+
+install(TARGETS samplerate DESTINATION lib)
+install(FILES src/samplerate.h DESTINATION include)
+install(DIRECTORY doc/ DESTINATION share/doc/libsamplerate)
+install(FILES ${CMAKE_BINARY_DIR}/samplerate.pc DESTINATION lib/pkgconfig)
--- a/README
+++ b/README
@@ -40,6 +40,17 @@
make
make install
+CMake
+-----
+There is a new CMake-based build system available:
+ mkdir build
+ cd build
+ cmake ..
+ make
+
+Use `cmake -DCMAKE_BUILD_TYPE=Release ..` to make a release build.
+Use `cmake -DBUILD_SHARED_LIBS=ON ..` to build a shared library.
+
CONTACTS
--------
--- a/Win32/config.h
+++ /dev/null
@@ -1,197 +1,0 @@
-/*
-** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
-** All rights reserved.
-**
-** This code is released under 2-clause BSD license. Please see the
-** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
-*/
-
-/*
-** This is the Win32 specific config.h header file.
-**
-** On Unix (including MacOSX), this header file is automatically generated
-** during the configure process while on Win32 this has to be hand edited
-** to keep it up to date.
-**
-** This is also a good file to add Win32 specific things.
-*/
-
-/*
-** MSVC++ assumes that all floating point constants without a trailing
-** letter 'f' are double precision.
-**
-** If this assumption is incorrect and one of these floating point constants
-** is assigned to a float variable MSVC++ generates a warning.
-**
-** Since there are currently about 25000 of these warnings generated in
-** src/src_sinc.c this slows down compile times considerably. The
-** following #pragma disables the warning.
-*/
-
-#pragma warning(disable: 4305)
-
-/*----------------------------------------------------------------------------
-** Normal #defines follow.
-*/
-
-/* Set to 1 if the compile is GNU GCC. */
-#define COMPILER_IS_GCC 0
-
-/* Target processor clips on negative float to int conversion. */
-#define CPU_CLIPS_NEGATIVE 0
-
-/* Target processor clips on positive float to int conversion. */
-#define CPU_CLIPS_POSITIVE 0
-
-/* Host processor is big endian. */
-#define CPU_IS_BIG_ENDIAN 0
-
-/* Host processor is little endian. */
-#define CPU_IS_LITTLE_ENDIAN 1
-
-/* Set to 1 to enable debugging. */
-#define ENABLE_DEBUG 0
-
-/* Major version of GCC or 3 otherwise. */
-/* #undef GCC_MAJOR_VERSION */
-
-/* Define to 1 if you have the `alarm' function. */
-/* #undef HAVE_ALARM */
-
-/* Define to 1 if you have the `calloc' function. */
-#define HAVE_CALLOC 1
-
-/* Define to 1 if you have the `ceil' function. */
-#define HAVE_CEIL 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-/* #undef HAVE_DLFCN_H */
-
-/* Set to 1 if you have libfftw3. */
-/* #undef HAVE_FFTW3 */
-
-/* Define to 1 if you have the `floor' function. */
-#define HAVE_FLOOR 1
-
-/* Define to 1 if you have the `fmod' function. */
-#define HAVE_FMOD 1
-
-/* Define to 1 if you have the `free' function. */
-#define HAVE_FREE 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-/* #undef HAVE_INTTYPES_H */
-
-/* Define to 1 if you have the `m' library (-lm). */
-/* #undef HAVE_LIBM */
-
-/* Define if you have C99's lrint function. */
-/* #undef HAVE_LRINT */
-
-/* Define if you have C99's lrintf function. */
-/* #undef HAVE_LRINTF */
-
-/* Define to 1 if you have the `malloc' function. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have signal SIGALRM. */
-/* #undef HAVE_SIGALRM */
-
-/* Define to 1 if you have the `signal' function. */
-/* #undef HAVE_SIGNAL */
-
-/* Set to 1 if you have libsndfile. */
-#define HAVE_SNDFILE 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-/* #undef HAVE_STDINT_H */
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/times.h> header file. */
-/* #undef HAVE_SYS_TIMES_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
-/* Set to 1 if compiling for Win32 */
-#define OS_IS_WIN32 1
-
-/* Name of package */
-#define PACKAGE "libsamplerate"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "erikd@mega-nerd.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libsamplerate"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libsamplerate 0.1.8"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libsamplerate"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL "http://www.mega-nerd.com/libsamplerate/"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.1.8"
-
-/* The size of `double', as computed by sizeof. */
-#define SIZEOF_DOUBLE 8
-
-/* The size of `float', as computed by sizeof. */
-#define SIZEOF_FLOAT 4
-
-/* The size of `int', as computed by sizeof. */
-#define SIZEOF_INT 4
-
-/* The size of `long', as computed by sizeof. */
-#define SIZEOF_LONG 4
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "0.1.8"
-
-
-
-/* Extra Win32 hacks. */
-
-/*
-** Microsoft's compiler still does not support the 1999 ISO C Standard
-** which includes 'inline'.
-*/
-
-#define inline __inline
--- /dev/null
+++ b/appveyor.yml
@@ -1,0 +1,47 @@
+image:
+- Visual Studio 2017
+
+environment:
+ matrix:
+ - generator: "Visual Studio 15 2017"
+ artifact: "ON"
+ - generator: "MSYS Makefiles"
+ artifact: "ON"
+ - generator: "Visual Studio 15 2017"
+ shared: "OFF"
+ artifact: "OFF"
+ - generator: "Visual Studio 15 2017"
+ shared: "ON"
+ artifact: "OFF"
+ - generator: "MSYS Makefiles"
+ shared: "OFF"
+ artifact: "OFF"
+ - generator: "MSYS Makefiles"
+ shared: "ON"
+ artifact: "OFF"
+
+matrix:
+ fast_finish: true
+
+build_script:
+ - ps: |
+ $env:Path = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;" + $env:Path
+ bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-fftw mingw-w64-x86_64-libsndfile"
+ mkdir build
+ cd build
+ if ($env:artifact -eq 'OFF')
+ {
+ cmake -G "$env:generator" -DBUILD_SHARED_LIBS=$env:shared ..
+ cat config.h
+ cmake --build .
+ ctest -C "Debug"
+ }
+ else
+ {
+ cmake .. -G "$env:generator" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=artifact
+ cmake --build . --config Release --target install
+ cmake .. -G "$env:generator" -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=artifact
+ cmake --build . --config Release --target install
+ Compress-Archive -Path artifact\* -Destination artifact
+ Push-AppveyorArtifact artifact.zip
+ }
--- /dev/null
+++ b/cmake/ClipMode.cmake
@@ -1,0 +1,92 @@
+include (CheckCSourceRuns)
+include (CMakePushCheckState)
+
+macro (CLIP_MODE)
+
+ set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion")
+ set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion")
+
+ message (STATUS "Checking processor clipping capabilities...")
+
+ if (CMAKE_CROSSCOMPILING)
+
+ set (CLIP_MSG "disabled")
+ set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE})
+ set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE})
+
+ else (NOT CMAKE_CROSSCOMPILING)
+
+ cmake_push_check_state ()
+
+ set (CMAKE_REQUIRED_QUIET TRUE)
+ if (LIBM_REQUIRED)
+ set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
+ endif ()
+
+ check_c_source_runs (
+ "
+ #define _ISOC9X_SOURCE 1
+ #define _ISOC99_SOURCE 1
+ #define __USE_ISOC99 1
+ #define __USE_ISOC9X 1
+ #include <math.h>
+ int main (void)
+ { double fval ;
+ int k, ival ;
+
+ fval = 1.0 * 0x7FFFFFFF ;
+ for (k = 0 ; k < 100 ; k++)
+ { ival = (lrint (fval)) >> 24 ;
+ if (ival != 127)
+ return 1 ;
+
+ fval *= 1.2499999 ;
+ } ;
+
+ return 0 ;
+ }
+ "
+ CPU_CLIPS_POSITIVE)
+
+ check_c_source_runs (
+ "
+ #define _ISOC9X_SOURCE 1
+ #define _ISOC99_SOURCE 1
+ #define __USE_ISOC99 1
+ #define __USE_ISOC9X 1
+ #include <math.h>
+ int main (void)
+ { double fval ;
+ int k, ival ;
+
+ fval = -8.0 * 0x10000000 ;
+ for (k = 0 ; k < 100 ; k++)
+ { ival = (lrint (fval)) >> 24 ;
+ if (ival != -128)
+ return 1 ;
+
+ fval *= 1.2499999 ;
+ } ;
+
+ return 0 ;
+ }
+ "
+ CPU_CLIPS_NEGATIVE)
+
+ cmake_pop_check_state ()
+
+ if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE))
+ set (CLIP_MSG "positive")
+ elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE))
+ set (CLIP_MSG "negative")
+ elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE)
+ set (CLIP_MSG "both")
+ else ()
+ set (CLIP_MSG "none")
+ endif ()
+
+ endif (CMAKE_CROSSCOMPILING)
+
+ message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}")
+
+endmacro (CLIP_MODE)
--- /dev/null
+++ b/cmake/FindFFTW.cmake
@@ -1,0 +1,48 @@
+# Adapted from: https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake
+
+# Copyright (c) 2015, Wenzel Jakob
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# - Find FFTW
+# Find the native FFTW includes and library
+#
+# FFTW_INCLUDE_DIR - where to find fftw3.h
+# FFTW_LIBRARY - List of libraries when using FFTW.
+# FFTW_FOUND - True if FFTW found.
+
+if (FFTW_INCLUDE_DIR)
+ # Already in cache, be silent
+ set (FFTW_FIND_QUIETLY TRUE)
+endif (FFTW_INCLUDE_DIR)
+
+find_path (FFTW_INCLUDE_DIR fftw3.h)
+
+find_library (FFTW_LIBRARY NAMES fftw3)
+
+# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
+# all listed variables are TRUE
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARY FFTW_INCLUDE_DIR)
+
+mark_as_advanced (FFTW_LIBRARY FFTW_INCLUDE_DIR)
--- /dev/null
+++ b/cmake/FindSndfile.cmake
@@ -1,0 +1,18 @@
+# Variables defined:
+# SNDFILE_FOUND
+# SNDFILE_INCLUDE_DIR
+# SNDFILE_LIBRARY
+#
+# Environment variables used:
+# SNDFILE_ROOT
+
+find_path(SNDFILE_INCLUDE_DIR sndfile.h
+ HINTS $ENV{SNDFILE_ROOT}/include)
+
+find_library(SNDFILE_LIBRARY NAMES sndfile
+ HINTS $ENV{SNDFILE_ROOT}/lib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SNDFILE DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
+
+mark_as_advanced(SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
--- /dev/null
+++ b/config.h.in
@@ -1,0 +1,64 @@
+/*
+** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
+** All rights reserved.
+**
+** This code is released under 2-clause BSD license. Please see the
+** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
+*/
+
+/* Name of package */
+#define PACKAGE "${PROJECT_NAME}"
+
+/* Version number of package */
+#define VERSION "${PROJECT_VERSION}"
+
+/* Target processor clips on negative float to int conversion. */
+#cmakedefine01 CPU_CLIPS_NEGATIVE
+
+/* Target processor clips on positive float to int conversion. */
+#cmakedefine01 CPU_CLIPS_POSITIVE
+
+/* Target processor is big endian. */
+#cmakedefine01 CPU_IS_BIG_ENDIAN
+
+/* Target processor is little endian. */
+#cmakedefine01 CPU_IS_LITTLE_ENDIAN
+
+/* Define to 1 if you have the `alarm' function. */
+#cmakedefine01 HAVE_ALARM
+
+/* Define to 1 if you have the <alsa/asoundlib.h> header file. */
+#cmakedefine01 HAVE_ALSA
+
+/* Set to 1 if you have libfftw3. */
+#cmakedefine01 HAVE_FFTW3
+
+/* Define if you have C99's lrint function. */
+#cmakedefine01 HAVE_LRINT
+
+/* Define if you have C99's lrintf function. */
+#cmakedefine01 HAVE_LRINTF
+
+/* Define if you have signal SIGALRM. */
+#cmakedefine01 HAVE_SIGALRM
+
+/* Define to 1 if you have the `signal' function. */
+#cmakedefine01 HAVE_SIGNAL
+
+/* Set to 1 if you have libsndfile. */
+#cmakedefine01 HAVE_SNDFILE
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine01 HAVE_STDINT_H
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+#cmakedefine01 HAVE_SYS_TIMES_H
+
+/* Set to 1 if compiling for Win32 */
+#cmakedefine01 OS_IS_WIN32
+
+/* The size of `int', as computed by sizeof. */
+#define SIZEOF_INT ${SIZEOF_INT}
+
+/* The size of `long', as computed by sizeof. */
+#define SIZEOF_LONG ${SIZEOF_LONG}
--- a/src/common.h
+++ b/src/common.h
@@ -48,7 +48,6 @@
# define WARN_UNUSED
#endif
-
#include "samplerate.h"
enum
--- a/tests/streaming_test.c
+++ b/tests/streaming_test.c
@@ -6,10 +6,13 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
+#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <samplerate.h>
+
+#include "util.h"
#define BUFFER_LEN (1<<15)
--- a/tests/termination_test.c
+++ b/tests/termination_test.c
@@ -66,7 +66,10 @@
static void
simple_test (int converter)
{
- int ilen = 199030, olen = 1000, error ;
+ // MSVC doesn't support variable-length arrays
+ #define ilen 199030
+ #define olen 1000
+ int error ;
{
float in [ilen] ;
--- a/tests/util.c
+++ b/tests/util.c
@@ -176,12 +176,10 @@
search = "hw.model" ;
is_pipe = 1 ;
#else
- file = NULL ;
+ return name;
#endif
- if (file == NULL)
- return name ;
-
+#if defined (__linux__) || defined (__APPLE__) || defined (__FreeBSD__)
if (search == NULL)
{ printf ("Error : search is NULL in function %s.\n", __func__) ;
return name ;
@@ -216,5 +214,6 @@
fclose (file) ;
return name ;
+#endif
} /* get_cpu_name */
--- a/tests/util.h
+++ b/tests/util.h
@@ -6,6 +6,8 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
+#include "config.h"
+
#define ABS(a) (((a) < 0) ? - (a) : (a))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) >= (b)) ? (a) : (b))