diff --git a/.gitignore b/.gitignore index 856aa663..3454ab1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,25 @@ *.8svx +*.a *.aif *.aifc *.aiff *.au *.bin *.caf -*.cm* +/*.cmake +/src/*.cmake +/src/ALAC/*.cmake +/src/G72x/*.cmake +/src/GSM610/*.cmake +/tests/*.cmake +/programs/*.cmake +!src/config.h.cmake +!*.in.cmake +*.dll *.exe *.flac *.la +*.lib *.lo *.loT *.o @@ -21,6 +32,7 @@ *.sd2 *.sds *.svx +/*.so* *.w64 *.wav *.wavex @@ -90,6 +102,7 @@ src/Symbols.os2 src/Symbols.static src/config.h src/config.h.in +src/config.h.in~ src/libsndfile.so* src/libsndfile-1.def src/sndfile.h diff --git a/.travis.yml b/.travis.yml index c9cf4315..47205c3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,43 @@ +sudo: false language: c -sudo: required -dist: trusty +matrix: + include: + - os: linux + dist: trusty + compiler: clang + addons: + apt: + packages: + - libogg-dev + - libvorbis-dev + - libflac-dev + - libasound2-dev + - os: linux + dist: trusty + compiler: gcc + addons: + apt: + packages: + - libogg-dev + - libvorbis-dev + - libflac-dev + - libasound2-dev + + - os: osx + compiler: clang before_install: - - sudo apt-get update - - sudo apt-get install -y libogg-dev libflac-dev libvorbis-dev + - | + if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + brew install autogen flac libogg libvorbis + fi + +install: + - true script: - - ./autogen.sh - - ./configure - - make distcheck + - mkdir cmake-build && (cd cmake-build && cmake .. -DCMAKE_BUILD_TYPE=Release && make VERBOSE=1 && ctest -V) + - pwd + - ./autogen.sh + - ./configure --enable-werror && make clean all check diff --git a/CMake/autogen.cmake b/CMake/autogen.cmake deleted file mode 100644 index 9d06f92c..00000000 --- a/CMake/autogen.cmake +++ /dev/null @@ -1,17 +0,0 @@ - -function (lsf_autogen dir basefilename) - # Only generate the file if it does not already exist. - if (NOT (EXISTS "${CMAKE_SOURCE_DIR}/${dir}/${basefilename}.c")) - - # If it doesn't exist, but we don't have autogen its an error. - if (NOT AUTOGEN) - message (FATAL_ERROR "Need GNU autogen to generate '${dir}/${basefilename}.c'.") - endif () - - execute_process ( - COMMAND ${AUTOGEN} --writable ${basefilename}.def - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${dir} - ) - endif () - - endfunction () diff --git a/CMake/build.cmake b/CMake/build.cmake deleted file mode 100644 index ae1d663f..00000000 --- a/CMake/build.cmake +++ /dev/null @@ -1,73 +0,0 @@ -# Build recipe for building programs in the programs/ directory. -function (lsf_build_program prog_name) - add_executable (${prog_name} - programs/common.c - programs/${prog_name}.c - ) - target_link_libraries (${prog_name} sndfile) - set_target_properties (${prog_name} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY programs - ) - endfunction () - -function (lsf_build_program_extra prog_name extra_libs) - add_executable (${prog_name} - programs/common.c - programs/${prog_name}.c - ) - target_link_libraries (${prog_name} sndfile ${extra_libs}) - set_target_properties (${prog_name} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY programs - ) - endfunction () - -# Build recipe for building C tests in the src/ directory. -function (lsf_build_src_test_c test_name extra_files) - add_executable (${test_name} - src/${test_name}.c - ${extra_files} - ) - target_link_libraries (${test_name} m) - set_target_properties (${test_name} - PROPERTIES - EXCLUDE_FROM_DEFAULT_BUILD TRUE - EXCLUDE_FROM_ALL TRUE - RUNTIME_OUTPUT_DIRECTORY src - ) - add_dependencies (check ${test_name}) - endfunction () - -# Build recipe for building C tests in the tests/ directory. -function (lsf_build_test_c test_name extra_files) - add_executable (${test_name} - tests/${test_name}.c - tests/utils.c - ${extra_files} - ) - target_link_libraries (${test_name} sndfile) - set_target_properties (${test_name} - PROPERTIES - EXCLUDE_FROM_DEFAULT_BUILD TRUE - EXCLUDE_FROM_ALL TRUE - RUNTIME_OUTPUT_DIRECTORY tests - ) - add_dependencies (check ${test_name}) - endfunction () - -# Build recipe for building C++ tests in the tests/ directory. -function (lsf_build_test_cc test_name) - add_executable (${test_name} - tests/utils.c - tests/${test_name}.cc - ) - target_link_libraries (${test_name} sndfile) - set_target_properties (${test_name} - PROPERTIES - EXCLUDE_FROM_DEFAULT_BUILD TRUE - EXCLUDE_FROM_ALL TRUE - RUNTIME_OUTPUT_DIRECTORY tests - ) - add_dependencies (check ${test_name}) - endfunction () diff --git a/CMake/check.cmake b/CMake/check.cmake deleted file mode 100644 index ba5d1abb..00000000 --- a/CMake/check.cmake +++ /dev/null @@ -1,92 +0,0 @@ -include (CheckFunctionExists) -include (CheckIncludeFile) -include (CheckLibraryExists) -include (CheckTypeSize) -include (TestBigEndian) - -function (lsf_try_compile_c_result c_file result_name result_pass result_fail) - try_compile (compile_result - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/${c_file} - OUTPUT_VARIABLE LOG2 - ) - - if (${compile_result}) - set (${result_name} ${result_pass} PARENT_SCOPE) - else (${compile_result}) - set (${result_name} ${result_fail} PARENT_SCOPE) - endif (${compile_result}) - - endfunction () - -function (lsf_check_include_file header_name result_name) - check_include_file (${header_name} header_${result_name}) - - if (header_${result_name}) - set (${result_name} 1 PARENT_SCOPE) - else (header_${result_name}) - set (${result_name} 0 PARENT_SCOPE) - endif (header_${result_name}) - - unset (header_${result_name}) - endfunction () - -function (lsf_check_type_size type_name result_size) - string (REPLACE "*" "_P" tmp1 ${type_name}) - string (REPLACE " " "_" tmp2 ${tmp1}) - - check_type_size (${type_name} size_${tmp2}) - - if (size_${type_name}) - set (${result_size} ${size_${type_name}} PARENT_SCOPE) - else (size_${type_name}) - set (${result_size} 0 PARENT_SCOPE) - endif (size_${type_name}) - - unset (tmp1) - unset (tmp2) - unset (size_${tmp2}) - endfunction () - -function (lsf_check_function_exists func_name result_name) - check_function_exists (${func_name} func_${result_name}) - - if (func_${result_name}) - set (${result_name} 1 PARENT_SCOPE) - else (func_${result_name}) - set (${result_name} 0 PARENT_SCOPE) - endif (func_${result_name}) - - unset (func_${result_name}) - endfunction () - -# Unix does not link libm by default while windows does. We therefore have -# a special function for testing math functions. -function (lsf_check_math_function_exists func_name result_name) - if (${UNIX}) - check_library_exists (m ${func_name} "" func_${result_name}) - else (${UNIX}) - check_function_exists (${func_name} func_${result_name}) - endif (${UNIX}) - - if (func_${result_name}) - set (${result_name} 1 PARENT_SCOPE) - else (func_${result_name}) - set (${result_name} 0 PARENT_SCOPE) - endif (func_${result_name}) - - unset (func_${result_name}) - endfunction () - -function (lsf_check_library_exists lib_name lib_func location result_name) - check_library_exists (${lib_name} ${lib_func} "${location}" lib_${result_name}) - - if (lib_${result_name}) - set (${result_name} 1 PARENT_SCOPE) - else (lib_${result_name}) - set (${result_name} 0 PARENT_SCOPE) - endif (lib_${result_name}) - - unset (lib_${result_name}) - endfunction () - diff --git a/CMake/compiler_is_gcc.c b/CMake/compiler_is_gcc.c deleted file mode 100644 index 784c8847..00000000 --- a/CMake/compiler_is_gcc.c +++ /dev/null @@ -1,11 +0,0 @@ -int main (void) -{ -#if __GNUC__ - #if __clang__ - This is clang -# endif -#else - This is not GCC. -#endif - return 0 ; -} diff --git a/CMake/external_libs.cmake b/CMake/external_libs.cmake deleted file mode 100644 index 665a7778..00000000 --- a/CMake/external_libs.cmake +++ /dev/null @@ -1,99 +0,0 @@ - -find_package (PkgConfig) -include (FindPackageHandleStandardArgs) - -function (find_libogg return_name) - pkg_check_modules (PC_LIBOGG QUIET libogg) - set (LIBOGG_DEFINITIONS ${PC_LIBOGG_CFLAGS_OTHER}) - - find_path (LIBOGG_INCLUDE_DIR ogg/ogg.h - HINTS ${PC_LIBOGG_INCLUDEDIR} ${PC_LIBOGG_INCLUDE_DIRS} - PATH_SUFFIXES libogg) - - find_library (LIBOGG_LIBRARY NAMES ogg libogg - HINTS ${PC_LIBOGG_LIBDIR} ${PC_LIBOGG_LIBRARY_DIRS}) - - find_package_handle_standard_args (LibOgg DEFAULT_MSG - LIBOGG_LIBRARY LIBOGG_INCLUDE_DIR) - - mark_as_advanced (LIBOGG_INCLUDE_DIR LIBOGG_LIBRARY) - - set (LIBOGG_LIBRARIES ${LIBOGG_LIBRARY} PARENT_SCOPE) - set (LIBOGG_INCLUDE_DIRS ${LIBOGG_INCLUDE_DIR} PARENT_SCOPE) - set (${return_name} ${LIBOGG_FOUND} PARENT_SCOPE) - endfunction (find_libogg) - - -function (find_libvorbis return_name) - pkg_check_modules (PC_LIBVORBIS QUIET libvorbis) - set (LIBVORBIS_DEFINITIONS ${PC_LIBVORBIS_CFLAGS_OTHER}) - - find_path (LIBVORBIS_INCLUDE_DIR vorbis/codec.h - HINTS ${PC_LIBVORBIS_INCLUDEDIR} ${PC_LIBVORBIS_INCLUDE_DIRS} - PATH_SUFFIXES libvorbis) - - find_library (LIBVORBIS_LIBRARY NAMES vorbis libvorbis - HINTS ${PC_LIBVORBIS_LIBDIR} ${PC_LIBVORBIS_LIBRARY_DIRS}) - - find_package_handle_standard_args (LibVorbis DEFAULT_MSG - LIBVORBIS_LIBRARY LIBVORBIS_INCLUDE_DIR) - - mark_as_advanced (LIBVORBIS_INCLUDE_DIR LIBVORBIS_LIBRARY) - - set (LIBVORBIS_LIBRARIES ${LIBVORBIS_LIBRARY} PARENT_SCOPE) - set (LIBVORBIS_INCLUDE_DIRS ${LIBVORBIS_INCLUDE_DIR} PARENT_SCOPE) - set (${return_name} ${LIBVORBIS_FOUND} PARENT_SCOPE) - endfunction (find_libvorbis) - - -function (find_libflac return_name) - pkg_check_modules (PC_LIBFLAC QUIET libFLAC) - set (LIBFLAC_DEFINITIONS ${PC_LIBFLAC_CFLAGS_OTHER}) - - find_path (LIBFLAC_INCLUDE_DIR FLAC/all.h - HINTS ${PC_LIBFLAC_INCLUDEDIR} ${PC_LIBFLAC_INCLUDE_DIRS} - PATH_SUFFIXES libFLAC) - - find_library (LIBFLAC_LIBRARY NAMES FLAC libFLAC - HINTS ${PC_LIBFLAC_LIBDIR} ${PC_LIBFLAC_LIBRARY_DIRS}) - - find_package_handle_standard_args (LibFlac DEFAULT_MSG - LIBFLAC_LIBRARY LIBFLAC_INCLUDE_DIR) - - mark_as_advanced (LIBFLAC_INCLUDE_DIR LIBFLAC_LIBRARY) - - set (LIBFLAC_LIBRARIES ${LIBFLAC_LIBRARY} PARENT_SCOPE) - set (LIBFLAC_INCLUDE_DIRS ${LIBFLAC_INCLUDE_DIR} PARENT_SCOPE) - set (${return_name} ${LIBFLAC_FOUND} PARENT_SCOPE) - endfunction (find_libflac) - - -function (find_external_xiph_libs return_name include_dirs external_libs) - find_libogg (LIBOGG_FOUND) - find_libvorbis (LIBVORBIS_FOUND) - find_libflac (LIBFLAC_FOUND) - - set (name 1) - set (includes "") - set (libs "") - - if (LIBOGG_FOUND AND LIBVORBIS_FOUND AND LIBFLAC_FOUND) - set (${name} 1) - - if (NOT (LIBOGG_INCLUDE_DIR STREQUAL "/usr/include")) - set (${includes} "${includes} ${LIBOGG_INCLUDE_DIR}") - endif () - if (NOT (LIBVORBIS_INCLUDE_DIR STREQUAL "/usr/include")) - set (${includes} "${includes} ${LIBVORBIS_INCLUDE_DIR}") - endif () - if (NOT (LIBFLAC_INCLUDE_DIR STREQUAL "/usr/include")) - set (${includes} "${includes} ${LIBFLAC_INCLUDE_DIR}") - endif () - - set (libs "FLAC;vorbis;vorbisenc;ogg") - endif () - - set (${return_name} ${name} PARENT_SCOPE) - set (${include_dirs} "${includes}" PARENT_SCOPE) - set (${external_libs} "${libs}" PARENT_SCOPE) - endfunction (find_external_xiph_libs) diff --git a/CMake/file.cmake b/CMake/file.cmake deleted file mode 100644 index b9c8cf9a..00000000 --- a/CMake/file.cmake +++ /dev/null @@ -1,37 +0,0 @@ - -function (file_line_count filename variable) - # Assume `find_progam (WC wc)` has already set this. - if (NOT WC) - message (FATAL_ERROR "Need the 'wc' program to find line coount.") - endif () - - if (NOT SED) - message (FATAL_ERROR "Need the 'sed' program to find line coount.") - endif () - - if (NOT (EXISTS "${filename}")) - message (FATAL_ERROR "File ${filename} does not exist.") - endif () - - execute_process ( - COMMAND ${WC} -l ${filename} - COMMAND ${SED} "s/^[ ]*//" # wc output on Mac has leading whitespace. - COMMAND ${SED} "s/ .*//" - OUTPUT_VARIABLE line_count - ) - - # Tedious! - string (STRIP ${line_count} line_count) - - set (${variable} ${line_count} PARENT_SCOPE) - endfunction () - -function (assert_line_count_non_zero filename) - - file_line_count (${filename} line_count) - - if (${line_count} LESS 1) - message (FATAL_ERROR "Line count of ${filename} is ${line_count}, which is less than expected.") - endif () - - endfunction () diff --git a/CMake/have_decl_s_irgrp.c b/CMake/have_decl_s_irgrp.c deleted file mode 100644 index 854a460c..00000000 --- a/CMake/have_decl_s_irgrp.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -int main (void) -{ - /* This will fail to compile if S_IRGRP doesn't exist. */ - return S_IRGRP ; -} diff --git a/CMake/libsndfile.cmake b/CMake/libsndfile.cmake deleted file mode 100644 index 080150da..00000000 --- a/CMake/libsndfile.cmake +++ /dev/null @@ -1,113 +0,0 @@ - -include (CMake/check.cmake) - -lsf_check_include_file (alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H) -lsf_check_include_file (byteswap.h HAVE_BYTESWAP_H) -lsf_check_include_file (dlfcn.h HAVE_DLFCN_H) -lsf_check_include_file (endian.h HAVE_ENDIAN_H) -lsf_check_include_file (inttypes.h HAVE_INTTYPES_H) -lsf_check_include_file (locale.h HAVE_LOCALE_H) -lsf_check_include_file (memory.h HAVE_MEMORY_H) -lsf_check_include_file (sndio.h HAVE_SNDIO_H) -lsf_check_include_file (stdint.h HAVE_STDINT_H) -lsf_check_include_file (stdlib.h HAVE_STDLIB_H) -lsf_check_include_file (string.h HAVE_STRING_H) -lsf_check_include_file (strings.h HAVE_STRINGS_H) -lsf_check_include_file (sys/stat.h HAVE_SYS_STAT_H) -lsf_check_include_file (sys/time.h HAVE_SYS_TIME_H) -lsf_check_include_file (sys/types.h HAVE_SYS_TYPES_H) -lsf_check_include_file (sys/wait.h HAVE_SYS_WAIT_H) -lsf_check_include_file (unistd.h HAVE_UNISTD_H) - - -lsf_check_type_size (double SIZEOF_DOUBLE) -lsf_check_type_size (float SIZEOF_FLOAT) -lsf_check_type_size (int SIZEOF_INT) -lsf_check_type_size (int64_t SIZEOF_INT64_T) -lsf_check_type_size (loff_t SIZEOF_LOFF_T) -lsf_check_type_size (long SIZEOF_LONG) -lsf_check_type_size (long\ long SIZEOF_LONG_LONG) -lsf_check_type_size (offt64_t SIZEOF_OFF64_T) -lsf_check_type_size (off_t SIZEOF_OFF_T) -lsf_check_type_size (short SIZEOF_SHORT) -lsf_check_type_size (size_t SIZEOF_SIZE_T) -lsf_check_type_size (ssize_t SIZEOF_SSIZE_T) -lsf_check_type_size (void* SIZEOF_VOIDP) -lsf_check_type_size (wchar_t SIZEOF_WCHAR_T) - -set (SIZEOF_SF_COUNT_T ${SIZEOF_INT64_T}) -set (TYPEOF_SF_COUNT_T int64_t) -set (SF_COUNT_MAX 0x7fffffffffffffffll) - -# Can't figure out how to make CMAKE_COMPILER_IS_GNUCC set something to either -# 1 or 0 so we do this: -lsf_try_compile_c_result (CMake/compiler_is_gcc.c COMPILER_IS_GCC 1 0) - -lsf_try_compile_c_result (CMake/have_decl_s_irgrp.c HAVE_DECL_S_IRGRP 1 0) - -TEST_BIG_ENDIAN (BIGENDIAN) -if (${BIGENDIAN}) - set (WORDS_BIGENDIAN 1) - set (CPU_IS_BIG_ENDIAN 1) - set (CPU_IS_LITTLE_ENDIAN 0) -else (${BIGENDIAN}) - set (WORDS_BIGENDIAN 0) - set (CPU_IS_LITTLE_ENDIAN 1) - set (CPU_IS_BIG_ENDIAN 0) - endif (${BIGENDIAN}) - -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - set (OS_IS_WIN32 1) - set (USE_WINDOWS_API 1) - set (USE_WINDOWS_API 1) - set (WIN32_TARGET_DLL 1) - set (__USE_MINGW_ANSI_STDIO 1) -else (${WINDOWS}) - set (OS_IS_WIN32 0) - set (USE_WINDOWS_API 0) - set (USE_WINDOWS_API 0) - set (WIN32_TARGET_DLL 0) - set (__USE_MINGW_ANSI_STDIO 0) - endif () - -if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - set (OS_IS_OPENBSD 1) -else () - set (OS_IS_OPENBSD 0) - endif () - -lsf_check_library_exists (m floor "" HAVE_LIBM) -lsf_check_library_exists (sqlite3 sqlite3_close "" HAVE_SQLITE3) - -lsf_check_function_exists (calloc HAVE_CALLOC) -lsf_check_function_exists (free HAVE_FREE) -lsf_check_function_exists (fstat HAVE_FSTAT) -lsf_check_function_exists (fstat64 HAVE_FSTAT64) -lsf_check_function_exists (fsync HAVE_FSYNC) -lsf_check_function_exists (ftruncate HAVE_FTRUNCATE) -lsf_check_function_exists (getpagesize HAVE_GETPAGESIZE) -lsf_check_function_exists (gettimeofday HAVE_GETTIMEOFDAY) -lsf_check_function_exists (gmtime HAVE_GMTIME) -lsf_check_function_exists (gmtime_r HAVE_GMTIME_R) -lsf_check_function_exists (localtime HAVE_LOCALTIME) -lsf_check_function_exists (localtime_r HAVE_LOCALTIME_R) -lsf_check_function_exists (lseek HAVE_LSEEK) -lsf_check_function_exists (lseek64 HAVE_LSEEK64) -lsf_check_function_exists (malloc HAVE_MALLOC) -lsf_check_function_exists (mmap HAVE_MMAP) -lsf_check_function_exists (open HAVE_OPEN) -lsf_check_function_exists (pipe HAVE_PIPE) -lsf_check_function_exists (read HAVE_READ) -lsf_check_function_exists (realloc HAVE_REALLOC) -lsf_check_function_exists (setlocale HAVE_SETLOCALE) -lsf_check_function_exists (snprintf HAVE_SNPRINTF) -lsf_check_function_exists (vsnprintf HAVE_VSNPRINTF) -lsf_check_function_exists (waitpid HAVE_WAITPID) -lsf_check_function_exists (write HAVE_WRITE) - -lsf_check_math_function_exists (ceil HAVE_CEIL) -lsf_check_math_function_exists (floor HAVE_FLOOR) -lsf_check_math_function_exists (fmod HAVE_FMOD) -lsf_check_math_function_exists (lrint HAVE_LRINT) -lsf_check_math_function_exists (lrintf HAVE_LRINTF) -lsf_check_math_function_exists (lround HAVE_LROUND) diff --git a/CMakeLists.txt b/CMakeLists.txt index 590429bb..ccc5dce9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,156 +1,190 @@ -# CMakeLists.txt for libsndfile +cmake_minimum_required (VERSION 3.1.3) -cmake_minimum_required (VERSION 3.0.0) +project(libsndfile VERSION 1.0.28) -project (libsndfile) +# +# Variables +# -# We may need these programs so detect them now. -find_program (AUTOGEN autogen) -find_program (AUTOHEADER autoheader) -find_program (GREP grep) -find_program (SED sed) -find_program (WC wc) +set (CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_VERSION}_MAJOR}) +set (CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_VERSION}_MINOR}) +set (CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_VERSION}_PATCH}) +set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION}pre1") +set (CMAKE_C_STANDARD 99) +set (CMAKE_C_STANDARD_REQUIRED TRUE) -include (CMake/file.cmake) +# +# System-wide includes +# -# Duplicate the autoconf/autoheader functionality. +include (GNUInstallDirs) +include (CPack) +include (CTest) +include (FeatureSummary) -# Get the version number from configure.ac. -execute_process ( - COMMAND ${GREP} ^AC_INIT configure.ac - COMMAND ${SED} "s/.*libsndfile[^0-9]*//;s/\\].*//" - OUTPUT_VARIABLE LIB_VERSION - ) +# +# Options +# -string (STRIP ${LIB_VERSION} LIB_VERSION) -string (REGEX REPLACE "\\..*" "" LIB_VERSION_MAJOR ${LIB_VERSION}) +option (BUILD_STATIC_LIBS "Build static libraries" ON) +option (BUILD_SHARED_LIBS "Build shared libraries" ON) +option (DISABLE_EXTERNAL_LIBS "Disable use of FLAC, Ogg and Vorbis" OFF) +option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF) +option (DISABLE_CPU_CLIP "Disable tricky cpu specific clipper" OFF) -message (STATUS "libsndfile version : ${LIB_VERSION}") +if ((NOT BUILD_STATIC_LIBS) AND (NOT BUILD_SHARED_LIBS)) + message (" + Both options BUILD_STATIC_LIBS and BUILD_SHARED_LIBS are manually set to OFF. To prevent configuration error + BUILD_STATIC_LIBS is now set to ON.\n") + set (BUILD_STATIC_LIBS ON) +endif () -# Generate config.h.in if it does not already exist. -if (NOT (EXISTS "${CMAKE_SOURCE_DIR}/CMakeFiles/config.h.in")) - if (NOT AUTOHEADER) - message (FATAL_ERROR "Need autoheader (part of GNU autoconf) to proceed.") - endif () +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") - message (STATUS "Running autoheader to create src/config.h.in") - execute_process (COMMAND ${AUTOHEADER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +# +# Setup definitions +# - assert_line_count_non_zero ("${CMAKE_SOURCE_DIR}/src/config.h.in") +include(${CMAKE_MODULE_PATH}/SndFileChecks.cmake) - message (STATUS "Post processing src/config.h.in") - execute_process ( - COMMAND ${SED} -E "s/undef([ \\t]+)([a-zA-Z0-8_]+)/define\\1\\2\\1@\\2@/" src/config.h.in - COMMAND ${SED} "s/.*_FILE_OFFSET_BITS.*//" - OUTPUT_FILE ${CMAKE_SOURCE_DIR}/CMakeFiles/config.h.in - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) +add_feature_info(BUILD_STATIC_LIBS BUILD_STATIC_LIBS "build static libraries") +add_feature_info(BUILD_SHARED_LIBS BUILD_SHARED_LIBS "build shared libraries") +add_feature_info(DISABLE_EXTERNAL_LIBS DISABLE_EXTERNAL_LIBS "disable use of FLAC, Ogg and Vorbis") +add_feature_info(ENABLE_EXPERIMENTAL ENABLE_EXPERIMENTAL "enable experimental code") +add_feature_info(BUILD_TESTING BUILD_TESTING "build tests") +add_feature_info(DISABLE_CPU_CLIP DISABLE_CPU_CLIP "Disable tricky cpu specific clipper") - execute_process ( - COMMAND ${GREP} -c undef ${CMAKE_SOURCE_DIR}/CMakeFiles/config.h.in - OUTPUT_VARIABLE undef_count - ) +set_package_properties(Ogg PROPERTIES TYPE RECOMMENDED + URL "www.xiph.org/ogg/" + DESCRIPTION "library for manipulating ogg bitstreams" + PURPOSE "Required to enable Vorbis, Speex and Opus support") +set_package_properties(Vorbis PROPERTIES TYPE RECOMMENDED + URL "www.vorbis.com/" + DESCRIPTION "open source lossy audio codec" + PURPOSE "Enables Vorbis support") +set_package_properties(FLAC PROPERTIES TYPE RECOMMENDED + URL "www.xiph.org/flac/" + DESCRIPTION "Free Lossless Audio Codec Library" + PURPOSE "Enables FLAC support") +set_package_properties(Speex PROPERTIES TYPE OPTIONAL + URL "www.speex.org/" + DESCRIPTION "an audio codec tuned for speech" + PURPOSE "Enables experemental Speex support") - if (${undef_count} GREATER 0) - message (FATAL_ERROR "CMake processing of CMakeFIles/config.h.in has failed.") - endif () - endif () +feature_summary (WHAT ALL) -assert_line_count_non_zero ("${CMAKE_SOURCE_DIR}/CMakeFiles/config.h.in") +# +# Setup configuration +# -# Use autogen to generate files if they don't already exist. -include (CMake/autogen.cmake) -lsf_autogen (src test_endswap) -lsf_autogen (tests pcm_test) -lsf_autogen (tests utils) -lsf_autogen (tests floating_point_test) -lsf_autogen (tests header_test) -lsf_autogen (tests pipe_test) -lsf_autogen (tests write_read_test) -lsf_autogen (tests scale_clip_test) -lsf_autogen (tests rdwr_test) -lsf_autogen (tests benchmark) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/sndfile.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/sndfile.h) -if (DEFINED ENV{CC}) - set (CMAKE_C_COMPILER $ENV{CC}) - endif() +set (PC_PREFIX ${CMAKE_INSTALL_PREFIX}) +set (PC_EXEC_PREFIX "\$\{prefix\}") +set (PC_LIBDIR "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}") +set (PC_INCLUDEDIR "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}") +set (PC_VERSION ${PROJECT_VERSION}) +if (EXTERNAL_XIPH_LIBS) + set (PC_PRIVATE_LIBS "-lFLAC -lvorbisenc") +endif () +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/sndfile.pc.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/sndfile.pc @ONLY) -if (DEFINED ENV{CXX}) - set (CMAKE_CXX_COMPILER $ENV{CXX}) - endif() +# +# libsndfile +# -message (STATUS "System : ${CMAKE_SYSTEM_NAME}") -message (STATUS "Processor : ${CMAKE_SYSTEM_PROCESSOR}") -message (STATUS "C compiler : ${CMAKE_C_COMPILER_ID}") -message (STATUS "C++ compiler : ${CMAKE_CXX_COMPILER_ID}") +# Public libsndfile headers +set (include_HEADERS src/sndfile.hh) +set (nodist_include_HEADERS src/sndfile.h) -#------------------------------------------------------------------------------- +# Private libsndfile headers +set (noinst_HEADERS + src/common.h + src/sfconfig.h + src/sfendian.h + src/wavlike.h + src/sf_unistd.h + src/ogg.h + src/chanmap.h) -set (PACKAGE \"libsndfile\") -set (PACKAGE_NAME \"libsndfile\") -set (VERSION \"${LIB_VERSION}\") -set (PACKAGE_VERSION \"${LIB_VERSION}\") +# Common libsndfile sources +set (COMMON + src/common.c + src/file_io.c + src/command.c + src/pcm.c + src/ulaw.c + src/alaw.c + src/float32.c + src/double64.c + src/ima_adpcm.c + src/ms_adpcm.c + src/gsm610.c + src/dwvw.c + src/vox_adpcm.c + src/interleave.c + src/strings.c + src/dither.c + src/cart.c + src/broadcast.c + src/audio_detect.c + src/ima_oki_adpcm.c + src/ima_oki_adpcm.h + src/alac.c + src/chunk.c + src/ogg.c + src/chanmap.c + src/id3.c) +if (WIN32) + list (APPEND COMMON src/windows.c) +if (BUILD_SHARED_LIBS) + list (APPEND COMMON src/version-metadata.rc) +endif (BUILD_SHARED_LIBS) +endif (WIN32) -set (BASEPATH "${CMAKE_SOURCE_DIR}") - -include (CMake/build.cmake) -include (CMake/external_libs.cmake) -include (CMake/libsndfile.cmake) - -if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=gnu99 -Wall -Wextra" CACHE STRING "" FORCE) - set (CMAKE_CXX__FLAGS "${CMAKE_C_FLAGS} -O3 -std=gnu99 -Wall -Wextra" CACHE STRING "" FORCE) - - set (COMPILER_IS_GCC 1) - set (_POSIX_SOURCE 1) - - if (${Werror} MATCHES "on") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror" CACHE STRING "" FORCE) - endif () - endif () - -if (CMAKE_C_COMPILER_ID STREQUAL "MSVC") - # Untested. Probably does not work. Patches accepted. - - set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4996" CACHE STRING "" FORCE) - add_definitions ("/wd4244 /wd4996") - endif () - - -# Need to actually detect this. -set (CPU_CLIPS_POSITIVE 0) -set (CPU_CLIPS_NEGATIVE 0) - -set (ENABLE_EXPERIMENTAL_CODE 0) - -find_external_xiph_libs (HAVE_EXTERNAL_XIPH_LIBS EXTERNAL_XIPH_CFLAGS EXTERNAL_XIPH_LIBS) - -#------------------------------------------------------------------------------- -# Project definitions follow. - -configure_file (${CMAKE_SOURCE_DIR}/src/sndfile.h.in ${CMAKE_SOURCE_DIR}/src/sndfile.h) -configure_file (${CMAKE_SOURCE_DIR}/CMakeFiles/config.h.in ${CMAKE_SOURCE_DIR}/src/config.h) - -include_directories (src) - -set (libsndfile_sources - src/ALAC/ALACBitUtilities.c - src/ALAC/ag_dec.c - src/ALAC/ag_enc.c - src/ALAC/alac_decoder.c - src/ALAC/alac_encoder.c - src/ALAC/dp_dec.c - src/ALAC/dp_enc.c - src/ALAC/matrix_dec.c - src/ALAC/matrix_enc.c - - src/G72x/g721.c - src/G72x/g723_16.c - src/G72x/g723_24.c - src/G72x/g723_40.c - src/G72x/g72x.c - src/G72x/g72x_test.c +# File specific libsndfile sources +set (FILESPECIFIC + src/sndfile.c + src/aiff.c + src/au.c + src/avr.c + src/caf.c + src/dwd.c + src/flac.c + src/g72x.c + src/htk.c + src/ircam.c + src/macos.c + src/mat4.c + src/mat5.c + src/nist.c + src/paf.c + src/pvf.c + src/raw.c + src/rx2.c + src/sd2.c + src/sds.c + src/svx.c + src/txw.c + src/voc.c + src/wve.c + src/w64.c + src/wavlike.c + src/wav.c + src/xi.c + src/mpc2k.c + src/rf64.c + src/ogg_vorbis.c + src/ogg_speex.c + src/ogg_pcm.c + src/ogg_opus.c) +# GSM610 sources +set (libgsm_SOURCES + src/GSM610/config.h + src/GSM610/gsm.h + src/GSM610/gsm610_priv.h src/GSM610/add.c src/GSM610/code.c src/GSM610/decode.c @@ -164,171 +198,857 @@ set (libsndfile_sources src/GSM610/preprocess.c src/GSM610/rpe.c src/GSM610/short_term.c - src/GSM610/table.c + src/GSM610/table.c) +source_group ("GSM610" FILES ${libgsm_SOURCES}) - src/aiff.c - src/alac.c - src/alaw.c - src/au.c - src/audio_detect.c - src/avr.c - src/broadcast.c - src/caf.c - src/cart.c - src/chanmap.c - src/chunk.c - src/command.c - src/common.c - src/dither.c - src/double64.c - src/dwd.c - src/dwvw.c - src/file_io.c - src/flac.c - src/float32.c - src/g72x.c - src/gsm610.c - src/htk.c - src/id3.c - src/ima_adpcm.c - src/ima_oki_adpcm.c - src/interleave.c - src/ircam.c - src/macos.c - src/mat4.c - src/mat5.c - src/mpc2k.c - src/ms_adpcm.c - src/nist.c - src/ogg.c - src/ogg_opus.c - src/ogg_pcm.c - src/ogg_speex.c - src/ogg_vorbis.c - src/paf.c - src/pcm.c - src/pvf.c - src/raw.c - src/rf64.c - src/rx2.c - src/sd2.c - src/sds.c - src/sndfile.c - src/strings.c - src/svx.c - src/txw.c - src/ulaw.c - src/voc.c - src/vox_adpcm.c - src/w64.c - src/wav.c - src/wavlike.c - src/windows.c - src/wve.c - src/xi.c - ) +# G72x sources +set (libg72x_SOURCES + src/G72x/g72x.h + src/G72x/g72x_priv.h + src/G72x/g721.c + src/G72x/g723_16.c + src/G72x/g723_24.c + src/G72x/g723_40.c + src/G72x/g72x.c) +source_group ("G72x" FILES ${libg72x_SOURCES}) -add_library (sndfile SHARED - ${libsndfile_sources} - ) +# ALAC sources +set (libalac_SOURCES + src/ALAC/ALACAudioTypes.h + src/ALAC/ALACBitUtilities.h + src/ALAC/EndianPortable.h + src/ALAC/aglib.h + src/ALAC/dplib.h + src/ALAC/matrixlib.h + src/ALAC/alac_codec.h + src/ALAC/shift.h + src/ALAC/ALACBitUtilities.c + src/ALAC/ag_dec.c + src/ALAC/ag_enc.c + src/ALAC/dp_dec.c + src/ALAC/dp_enc.c + src/ALAC/matrix_dec.c + src/ALAC/matrix_enc.c + src/ALAC/alac_decoder.c + src/ALAC/alac_encoder.c) +source_group ("ALAC" FILES ${libalac_SOURCES}) -target_link_libraries (sndfile LINK_PRIVATE ${EXTERNAL_XIPH_LIBS} LINK_PUBLIC m) +# Headers to be installed on target machine +set (libsndfile_PUBLIC_HEADERS ${include_HEADERS} ${nodist_include_HEADERS}) +set (libsndfile_SOURCES ${COMMON} ${FILESPECIFIC} ${noinst_HEADERS} + ${libgsm_SOURCES} ${libg72x_SOURCES} ${libalac_SOURCES} + ${libsndfile_PUBLIC_HEADERS}) -set_target_properties (sndfile - PROPERTIES - VERSION ${LIB_VERSION} - SOVERSION ${LIB_VERSION_MAJOR} - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src - ) +# +# libsndfile static library +# -#------------------------------------------------------------------------------- -# Programs. +if (BUILD_STATIC_LIBS) + set (SNDFILE_STATIC_TARGET sndfile-static) + add_library (${SNDFILE_STATIC_TARGET} STATIC ${libsndfile_SOURCES}) + if (LIBM_REQUIRED) + target_link_libraries (${SNDFILE_STATIC_TARGET} PUBLIC ${M_LIBRARY}) + endif () + if (NOT DISABLE_EXTERNAL_LIBS) + target_link_libraries (${SNDFILE_STATIC_TARGET} PUBLIC ${EXTERNAL_XIPH_LIBS}) + target_include_directories (${SNDFILE_STATIC_TARGET} PRIVATE + ${OGG_INCLUDE_DIRS} + ${VORBIS_INCLUDE_DIRS} + ${FLAC_INCLUDE_DIRS}) + target_compile_definitions (${SNDFILE_STATIC_TARGET} PRIVATE ${FLAC_DEFINITIONS}) + if (ENABLE_EXPERIMENTAL) + target_link_libraries (${SNDFILE_STATIC_TARGET} PUBLIC ${SPEEX_LIBRARIES}) + target_include_directories (${SNDFILE_STATIC_TARGET} PRIVATE + ${SPEEX_INCLUDE_DIRS}) + endif () + endif () + if (WIN32) + set_target_properties (${SNDFILE_STATIC_TARGET} PROPERTIES PREFIX "lib") + endif () + # Remove "-static" from output name + set_target_properties (${SNDFILE_STATIC_TARGET} PROPERTIES OUTPUT_NAME "sndfile") + target_include_directories (${SNDFILE_STATIC_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) +endif () -lsf_build_program (sndfile-cmp) -lsf_build_program (sndfile-concat) -lsf_build_program (sndfile-convert) -lsf_build_program (sndfile-deinterleave) -lsf_build_program (sndfile-info) -lsf_build_program (sndfile-interleave) -lsf_build_program (sndfile-metadata-get) -lsf_build_program (sndfile-metadata-set) -lsf_build_program (sndfile-salvage) -lsf_build_program_extra (sndfile-play asound) +if (BUILD_SHARED_LIBS) -#------------------------------------------------------------------------------- -# Tests. + set (SNDFILE_SHARED_TARGET sndfile) -configure_file (${CMAKE_SOURCE_DIR}/tests/test_wrapper.sh.in ${CMAKE_SOURCE_DIR}/tests/test_wrapper.sh) -configure_file (${CMAKE_SOURCE_DIR}/tests/pedantic-header-test.sh.in ${CMAKE_SOURCE_DIR}/tests/pedantic-header-test.sh) + if (WIN32) + configure_file(${CMAKE_SOURCE_DIR}/src/version-metadata.rc.in.cmake ${CMAKE_SOURCE_DIR}/src/version-metadata.rc) + configure_file (${CMAKE_SOURCE_DIR}/src/libsndfile.def.in.cmake ${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.def) + list (APPEND libsndfile_SOURCES + src/version-metadata.rc + src/${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.def) + endif (WIN32) -add_custom_target (check - COMMAND src/test_main && bash tests/test_wrapper.sh - DEPENDS src/test_main tests/test_wrapper.sh - ) + add_library(${SNDFILE_SHARED_TARGET} SHARED ${libsndfile_SOURCES}) -# Tests from the src/ directory. -set (src_test_sources - src/audio_detect.c - src/broadcast.c - src/cart.c - src/common.c - src/double64.c - src/file_io.c - src/float32.c - src/test_audio_detect.c - src/test_broadcast_var.c - src/test_cart_var.c - src/test_conversions.c - src/test_endswap.c - src/test_file_io.c - src/test_float.c - src/test_ima_oki_adpcm.c - src/test_log_printf.c - src/test_strncpy_crlf.c - ) + if (LIBM_REQUIRED) + target_link_libraries (${SNDFILE_SHARED_TARGET} PRIVATE ${M_LIBRARY}) + endif (LIBM_REQUIRED) -lsf_build_src_test_c (test_main "${src_test_sources}") + if (NOT DISABLE_EXTERNAL_LIBS) + target_link_libraries (${SNDFILE_SHARED_TARGET} PRIVATE ${EXTERNAL_XIPH_LIBS}) + target_include_directories (${SNDFILE_SHARED_TARGET} PRIVATE + ${OGG_INCLUDE_DIRS} + ${VORBIS_INCLUDE_DIRS} + ${FLAC_INCLUDE_DIRS}) + target_compile_definitions (${SNDFILE_SHARED_TARGET} PRIVATE ${FLAC_DEFINITIONS}) + if (ENABLE_EXPERIMENTAL) + target_link_libraries (${SNDFILE_SHARED_TARGET} PRIVATE ${SPEEX_LIBRARIES}) + target_include_directories (${SNDFILE_SHARED_TARGET} PRIVATE + ${SPEEX_INCLUDE_DIRS}) + endif (ENABLE_EXPERIMENTAL) + endif (NOT DISABLE_EXTERNAL_LIBS) -# Tests from the tests/ directory. + target_include_directories (${SNDFILE_SHARED_TARGET} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) -lsf_build_test_c (aiff_rw_test "") -lsf_build_test_c (alaw_test "") -lsf_build_test_c (benchmark "") -lsf_build_test_c (channel_test "") -lsf_build_test_c (checksum_test "") -lsf_build_test_c (chunk_test "") -lsf_build_test_c (command_test "") -lsf_build_test_c (compression_size_test "") -lsf_build_test_cc (cpp_test "") -lsf_build_test_c (dither_test "") -lsf_build_test_c (dwvw_test "") -lsf_build_test_c (error_test "") -lsf_build_test_c (external_libs_test "") -lsf_build_test_c (fix_this "") -lsf_build_test_c (floating_point_test "tests/dft_cmp.c") -lsf_build_test_c (format_check_test "") -lsf_build_test_c (headerless_test "") -lsf_build_test_c (header_test "") -lsf_build_test_c (largefile_test "") -lsf_build_test_c (locale_test "") -lsf_build_test_c (lossy_comp_test "") -lsf_build_test_c (long_read_write_test "") -lsf_build_test_c (misc_test "") -lsf_build_test_c (multi_file_test "") -lsf_build_test_c (ogg_test "") -lsf_build_test_c (pcm_test "") -lsf_build_test_c (peak_chunk_test "") -lsf_build_test_c (pipe_test "") -lsf_build_test_c (raw_test "") -lsf_build_test_c (rdwr_test "") -lsf_build_test_c (scale_clip_test "") -lsf_build_test_c (sfversion "") -lsf_build_test_c (stdin_test "") -lsf_build_test_c (stdio_test "") -lsf_build_test_c (stdout_test "") -lsf_build_test_c (string_test "") -lsf_build_test_c (ulaw_test "") -lsf_build_test_c (virtual_io_test "") -lsf_build_test_c (win32_ordinal_test "") -lsf_build_test_c (win32_test "") -lsf_build_test_c (write_read_test "tests/generate.c") + set_target_properties (${SNDFILE_SHARED_TARGET} PROPERTIES + DEFINE_SYMBOL SNDFILE_EXPORTS + PUBLIC_HEADER "${libsndfile_PUBLIC_HEADERS}" + SOVERSION ${PROJECT_VERSION_MAJOR} + VERSION ${PROJECT_VERSION} + C_VISIBILITY_PRESET hidden) + + if (WIN32) + set_target_properties(${SNDFILE_SHARED_TARGET} PROPERTIES + PREFIX "lib" + OUTPUT_NAME "sndfile-${PROJECT_VERSION_MAJOR}") + endif (WIN32) + +endif (BUILD_SHARED_LIBS) + +# +# Programs +# + +# Select libsndfile version to link +if (BUILD_SHARED_LIBS) + set (SNDFILE_TARGET ${SNDFILE_SHARED_TARGET}) +else (NOT BUILD_SHARED_LIBS) + set (SNDFILE_TARGET ${SNDFILE_STATIC_TARGET}) +endif (BUILD_SHARED_LIBS) + +# sndfile-info + +set (sndfile_info_SOURCES + programs/sndfile-info.c + programs/common.c + programs/common.h) +add_executable (sndfile-info ${sndfile_info_SOURCES}) +target_link_libraries(sndfile-info PUBLIC ${SNDFILE_TARGET}) +if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(sndfile-info PRIVATE ${M_LIBRARY}) +endif () + +# sndfile-play + +if (WIN32 OR (ALSA_FOUND OR Sndio_FOUND)) + set (sndfile_play_SOURCES + programs/sndfile-play.c + programs/common.c + programs/common.h) + add_executable (sndfile-play ${sndfile_play_SOURCES}) + target_link_libraries(sndfile-play PUBLIC ${SNDFILE_TARGET}) + if (WIN32) + target_link_libraries(sndfile-play PRIVATE Winmm.lib) + elseif (ALSA_FOUND) + target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS}) + target_link_libraries(sndfile-play PRIVATE ${ALSA_LIBRARIES}) + elseif (Sndio_FOUND) + target_include_directories (sndfile-play PRIVATE ${Sndio_INCLUDE_DIRS}) + target_link_libraries(sndfile-play PRIVATE ${Sndio_LIBRARIES}) + endif () +endif () + +# sndfile-convert + +set (sndfile_convert_SOURCES + programs/sndfile-convert.c + programs/common.c + programs/common.h) +add_executable (sndfile-convert ${sndfile_convert_SOURCES}) +target_link_libraries(sndfile-convert PUBLIC ${SNDFILE_TARGET}) + +# sndfile-cmp + +set (sndfile_cmp_SOURCES + programs/sndfile-cmp.c + programs/common.c + programs/common.h) +add_executable (sndfile-cmp ${sndfile_cmp_SOURCES}) +target_link_libraries(sndfile-cmp PUBLIC ${SNDFILE_TARGET}) + +# sndfile-metadata-set + +set (sndfile_metadata_set_SOURCES + programs/sndfile-metadata-set.c + programs/common.c + programs/common.h) +add_executable (sndfile-metadata-set ${sndfile_metadata_set_SOURCES}) +target_link_libraries(sndfile-metadata-set PUBLIC ${SNDFILE_TARGET}) + +# sndfile-metadata-get + +set (sndfile_metadata_get_SOURCES + programs/sndfile-metadata-get.c + programs/common.c + programs/common.h) +add_executable (sndfile-metadata-get ${sndfile_metadata_get_SOURCES}) +target_link_libraries(sndfile-metadata-get PUBLIC ${SNDFILE_TARGET}) + +# sndfile-interleave + +set (sndfile_interleave_SOURCES + programs/sndfile-interleave.c + programs/common.c + programs/common.h) +add_executable (sndfile-interleave ${sndfile_interleave_SOURCES}) +target_link_libraries(sndfile-interleave PUBLIC ${SNDFILE_TARGET}) + +# sndfile-deinterleave + +set (sndfile_deinterleave_SOURCES + programs/sndfile-deinterleave.c + programs/common.c + programs/common.h) +add_executable (sndfile-deinterleave ${sndfile_deinterleave_SOURCES}) +target_link_libraries(sndfile-deinterleave PUBLIC ${SNDFILE_TARGET}) + +# sndfile-concat + +set (sndfile_concat_SOURCES + programs/sndfile-concat.c + programs/common.c + programs/common.h) +add_executable (sndfile-concat ${sndfile_concat_SOURCES}) +target_link_libraries(sndfile-concat PUBLIC ${SNDFILE_TARGET}) + +# sndfile-salvage + +set (sndfile_salvage_SOURCES + programs/sndfile-salvage.c + programs/common.c + programs/common.h) +add_executable (sndfile-salvage ${sndfile_salvage_SOURCES}) +target_link_libraries(sndfile-salvage PUBLIC ${SNDFILE_TARGET}) + +# sndfile-play-beos + +# This is the BeOS version of sndfile-play. It needs to be compiled with the C++ +# compiler. +if (BEOS OR HAIKU) + set (sndfile_play_beos_SOURCES + programs/sndfile-play-beos.cpp) + add_executable (sndfile-play-beos ${sndfile_play_beos_SOURCES}) + target_link_libraries(sndfile-play-beos PUBLIC ${SNDFILE_TARGET}) +endif (BEOS OR HAIKU) + +# +# Installation +# + +install (TARGETS ${SNDFILE_STATIC_TARGET} ${SNDFILE_SHARED_TARGET} ${PROGRAMS} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +if (Unix) + set (man_MANS + man/sndfile-info.1 + man/sndfile-play.1 + man/sndfile-convert.1 + man/sndfile-cmp.1 + man/sndfile-metadata-get.1 + #man/sndfile-metadata-set.1 + man/sndfile-concat.1 + man/sndfile-interleave.1 + #man/sndfile-deinterleave.1 + man/sndfile-salvage.1) + install (FILES ${man_MANS} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 PATTERN "*.1") +endif () + +#TODO: ENABLE_BOW_DOCS option +set (HTML_BGCOLOUR "black") +set (HTML_FGCOLOUR "white") +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doc/libsndfile.css.in ${CMAKE_CURRENT_SOURCE_DIR}/doc/libsndfile.css) +set (html_DATA + doc/index.html + doc/libsndfile.jpg + doc/libsndfile.css + doc/print.css + doc/api.html + doc/command.html + doc/bugs.html + doc/sndfile_info.html + doc/new_file_type.HOWTO + doc/win32.html + doc/FAQ.html + doc/lists.html + doc/embedded_files.html + doc/octave.html + doc/tutorial.html) +install (FILES ${html_DATA} DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}) + +install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/sndfile.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# +# Testing +# + +if (BUILD_TESTING) + + # Custom commands to generate tests sources form autogen templates + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/benchmark.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable benchmark.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/floating_point_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable floating_point_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/floating_point_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable floating_point_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/header_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable header_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/pcm_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable pcm_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/pipe_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable pipe_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/rdwr_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable rdwr_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/scale_clip_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable scale_clip_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/utils.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable utils.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/tests/write_read_test.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable write_read_test.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) + + add_custom_command ( + OUTPUT ${CMAKE_SOURCE_DIR}/src/test_endswap.c + COMMAND ${AUTOGEN_EXECUTABLE} --writable test_endswap.def + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src) + + ### test_main + + set (test_main_SOURCES + src/test_main.c + src/test_main.h + src/test_conversions.c + src/test_float.c + src/test_endswap.c + src/test_audio_detect.c + src/test_log_printf.c + src/test_file_io.c + src/test_ima_oki_adpcm.c + src/test_strncpy_crlf.c + src/test_broadcast_var.c + src/test_cart_var.c + src/test_binheader_writef.c) + + add_executable (test_main ${test_main_SOURCES}) + target_link_libraries (test_main ${SNDFILE_STATIC_TARGET}) + add_test (test_main test_main) + + ### sfversion_test + + set (sfversion_SOURCES tests/sfversion.c) + add_executable (sfversion ${sfversion_SOURCES}) + target_link_libraries (sfversion ${SNDFILE_TARGET}) + add_test (sfversion sfversion) + set_tests_properties (sfversion PROPERTIES + PASS_REGULAR_EXPRESSION "libsndfile-${CPACK_PACKAGE_VERSION}") + + ### error_test + + set (error_test_SOURCES tests/error_test.c tests/utils.c) + add_executable (error_test ${error_test_SOURCES}) + target_link_libraries (error_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(error_test PRIVATE ${M_LIBRARY}) + endif () + add_test (error_test error_test) + + ### ulaw_test + set (ulaw_test_SOURCES tests/utils.c tests/ulaw_test.c) + add_executable (ulaw_test ${ulaw_test_SOURCES}) + target_link_libraries (ulaw_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(ulaw_test PRIVATE ${M_LIBRARY}) + endif () + add_test (ulaw_test ulaw_test) + + ### alaw_test + set (alaw_test_SOURCES tests/utils.c tests/alaw_test.c) + add_executable (alaw_test ${alaw_test_SOURCES}) + target_link_libraries (alaw_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(alaw_test PRIVATE ${M_LIBRARY}) + endif () + add_test (alaw_test alaw_test) + + ### dwvw_test + + set (dwvw_test_SOURCES tests/utils.c tests/dwvw_test.c) + add_executable (dwvw_test ${dwvw_test_SOURCES}) + target_link_libraries (dwvw_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(dwvw_test PRIVATE ${M_LIBRARY}) + endif () + add_test (dwvw_test dwvw_test) + + ### command_test + + set (command_test_SOURCES tests/command_test.c tests/utils.c) + add_executable (command_test ${command_test_SOURCES}) + target_link_libraries (command_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(command_test PRIVATE ${M_LIBRARY}) + endif () + add_test (command_test command_test all) + + ### floating_point_test + + set (floating_point_test_SOURCES tests/utils.c tests/dft_cmp.c tests/floating_point_test.c) + add_executable (floating_point_test ${floating_point_test_SOURCES}) + target_link_libraries (floating_point_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(floating_point_test PRIVATE ${M_LIBRARY}) + endif () + add_test (floating_point_test floating_point_test) + + ### checksum_test + + set (checksum_test_SOURCES tests/checksum_test.c tests/utils.c) + add_executable (checksum_test ${checksum_test_SOURCES}) + target_link_libraries (checksum_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(checksum_test PRIVATE ${M_LIBRARY}) + endif () + add_test (checksum_test checksum_test) + + ### scale_clip_test + + set (scale_clip_test_SOURCES tests/scale_clip_test.c tests/utils.c) + add_executable (scale_clip_test ${scale_clip_test_SOURCES}) + target_link_libraries (scale_clip_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(scale_clip_test PRIVATE ${M_LIBRARY}) + endif () + add_test (scale_clip_test scale_clip_test) + + ### headerless_test + + set (headerless_test_SOURCES tests/utils.c tests/headerless_test.c) + add_executable (headerless_test ${headerless_test_SOURCES}) + target_link_libraries (headerless_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(headerless_test PRIVATE ${M_LIBRARY}) + endif () + add_test (headerless_test headerless_test) + + ### rdwr_test + + set (rdwr_test_SOURCES tests/rdwr_test.c tests/utils.c) + add_executable (rdwr_test ${rdwr_test_SOURCES}) + target_link_libraries (rdwr_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(rdwr_test PRIVATE ${M_LIBRARY}) + endif () + add_test (rdwr_test rdwr_test) + + ### locale_test + + set (locale_test_SOURCES tests/locale_test.c tests/utils.c) + add_executable (locale_test ${locale_test_SOURCES}) + target_link_libraries (locale_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(locale_test PRIVATE ${M_LIBRARY}) + endif () + add_test (locale_test locale_test) + + ### win32_ordinal_test + + # TODO + + ### cpp_test + + set (cpp_test_SOURCES tests/cpp_test.cc tests/utils.c) + add_executable (cpp_test ${cpp_test_SOURCES}) + target_link_libraries (cpp_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(cpp_test PRIVATE ${M_LIBRARY}) + endif () + add_test (cpp_test cpp_test) + + ### external_libs_test + + set (external_libs_test_SOURCES tests/external_libs_test.c tests/utils.c) + add_executable (external_libs_test ${external_libs_test_SOURCES}) + target_link_libraries (external_libs_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(external_libs_test PRIVATE ${M_LIBRARY}) + endif () + add_test (external_libs_test external_libs_test) + + ### format_check_test + + set (format_check_test_SOURCES tests/format_check_test.c tests/utils.c) + add_executable (format_check_test ${format_check_test_SOURCES}) + target_link_libraries (format_check_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(format_check_test PRIVATE ${M_LIBRARY}) + endif () + add_test (format_check_test format_check_test) + + ### channel_test + + set (channel_test_SOURCES tests/channel_test.c tests/utils.c) + add_executable (channel_test ${channel_test_SOURCES}) + target_link_libraries (channel_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(channel_test PRIVATE ${M_LIBRARY}) + endif () + add_test (channel_test channel_test) + + ### common test executables + + set (write_read_test_SOURCES tests/utils.c tests/generate.c tests/write_read_test.c) + add_executable (write_read_test ${write_read_test_SOURCES}) + target_link_libraries (write_read_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(write_read_test PRIVATE ${M_LIBRARY}) + endif () + + set (lossy_comp_test_SOURCES tests/utils.c tests/lossy_comp_test.c) + add_executable (lossy_comp_test ${lossy_comp_test_SOURCES}) + target_link_libraries (lossy_comp_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(lossy_comp_test PRIVATE ${M_LIBRARY}) + endif () + + set (peak_chunk_test_SOURCES tests/peak_chunk_test.c tests/utils.c) + add_executable (peak_chunk_test ${peak_chunk_test_SOURCES}) + target_link_libraries (peak_chunk_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(peak_chunk_test PRIVATE ${M_LIBRARY}) + endif () + + set (header_test_SOURCES tests/header_test.c tests/utils.c) + add_executable (header_test ${header_test_SOURCES}) + target_link_libraries (header_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(header_test PRIVATE ${M_LIBRARY}) + endif () + + set (misc_test_SOURCES tests/misc_test.c tests/utils.c) + add_executable (misc_test ${misc_test_SOURCES}) + target_link_libraries (misc_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(misc_test PRIVATE ${M_LIBRARY}) + endif () + + set (string_test_SOURCES tests/string_test.c tests/utils.c) + add_executable (string_test ${string_test_SOURCES}) + target_link_libraries (string_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(string_test PRIVATE ${M_LIBRARY}) + endif () + + set (multi_file_test_SOURCES tests/multi_file_test.c tests/utils.c) + add_executable (multi_file_test ${multi_file_test_SOURCES}) + target_link_libraries (multi_file_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(multi_file_test PRIVATE ${M_LIBRARY}) + endif () + + set (aiff_rw_test_SOURCES tests/utils.c tests/aiff_rw_test.c) + add_executable (aiff_rw_test ${aiff_rw_test_SOURCES}) + target_link_libraries (aiff_rw_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(aiff_rw_test PRIVATE ${M_LIBRARY}) + endif () + + set (chunk_test_SOURCES tests/chunk_test.c tests/utils.c) + add_executable (chunk_test ${chunk_test_SOURCES}) + target_link_libraries (chunk_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(chunk_test PRIVATE ${M_LIBRARY}) + endif () + + set (long_read_write_test_SOURCES tests/long_read_write_test.c tests/utils.c) + add_executable (long_read_write_test ${long_read_write_test_SOURCES}) + target_link_libraries (long_read_write_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(long_read_write_test PRIVATE ${M_LIBRARY}) + endif () + + set (raw_test_SOURCES tests/raw_test.c tests/utils.c) + add_executable (raw_test ${raw_test_SOURCES}) + target_link_libraries (raw_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(raw_test PRIVATE ${M_LIBRARY}) + endif () + + set (compression_size_test_SOURCES tests/compression_size_test.c tests/utils.c) + add_executable (compression_size_test ${compression_size_test_SOURCES}) + target_link_libraries (compression_size_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(compression_size_test PRIVATE ${M_LIBRARY}) + endif () + + set (ogg_test_SOURCES tests/ogg_test.c tests/utils.c) + add_executable (ogg_test ${ogg_test_SOURCES}) + target_link_libraries (ogg_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(ogg_test PRIVATE ${M_LIBRARY}) + endif () + + set (stdin_test_SOURCES tests/stdin_test.c tests/utils.c) + add_executable (stdin_test ${stdin_test_SOURCES}) + target_link_libraries (stdin_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(stdin_test PRIVATE ${M_LIBRARY}) + endif () + + set (stdout_test_SOURCES tests/stdout_test.c) + add_executable (stdout_test ${stdout_test_SOURCES}) + target_link_libraries (stdout_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(stdout_test PRIVATE ${M_LIBRARY}) + endif () + + set (stdio_test_SOURCES tests/stdio_test.c tests/utils.c) + add_executable (stdio_test ${stdio_test_SOURCES}) + target_link_libraries (stdio_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(stdio_test PRIVATE ${M_LIBRARY}) + endif () + + set (pipe_test_SOURCES tests/pipe_test.c tests/utils.c) + add_executable (pipe_test ${pipe_test_SOURCES}) + target_link_libraries (pipe_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(pipe_test PRIVATE ${M_LIBRARY}) + endif () + + set (virtual_io_test_SOURCES tests/virtual_io_test.c tests/utils.c) + add_executable (virtual_io_test ${virtual_io_test_SOURCES}) + target_link_libraries (virtual_io_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(virtual_io_test PRIVATE ${M_LIBRARY}) + endif () + + ### g72x_test + + set (g72x_test_SOURCES src/G72x/g72x_test.c ${libg72x_SOURCES}) + add_executable (g72x_test ${g72x_test_SOURCES}) + target_link_libraries (g72x_test PRIVATE ${SNDFILE_TARGET}) + if (BUILD_SHARED_LIBS AND LIBM_REQUIRED) + target_link_libraries(g72x_test PRIVATE ${M_LIBRARY}) + endif () + add_test (g72x_test g72x_test all) + + ### aiff-tests + + add_test (write_read_test_aiff write_read_test aiff) + add_test (lossy_comp_test_aiff_ulaw lossy_comp_test aiff_ulaw) + add_test (lossy_comp_test_aiff_alaw lossy_comp_test aiff_alaw) + add_test (lossy_comp_test_aiff_gsm610 lossy_comp_test aiff_gsm610) + add_test (peak_chunk_test_aiff peak_chunk_test aiff) + add_test (header_test_aiff header_test aiff) + add_test (misc_test_aiff misc_test aiff) + add_test (string_test_aiff string_test aiff) + add_test (multi_file_test_aiff multi_file_test aiff) + add_test (aiff_rw_test aiff_rw_test) + + ### au-tests + + add_test (write_read_test_au write_read_test au) + add_test (lossy_comp_test_au_ulaw lossy_comp_test au_ulaw) + add_test (lossy_comp_test_au_alaw lossy_comp_test au_alaw) + add_test (lossy_comp_test_au_g721 lossy_comp_test au_g721) + add_test (lossy_comp_test_au_g723 lossy_comp_test au_g723) + add_test (header_test_au header_test au) + add_test (misc_test_au misc_test au) + add_test (multi_file_test_au multi_file_test au) + + ### caf-tests + + add_test (write_read_test_caf write_read_test caf) + add_test (lossy_comp_test_caf_ulaw lossy_comp_test caf_ulaw) + add_test (lossy_comp_test_caf_alaw lossy_comp_test caf_alaw) + add_test (header_test_caf header_test caf) + add_test (peak_chunk_test_caf peak_chunk_test caf) + add_test (misc_test_caf misc_test caf) + add_test (chunk_test_caf chunk_test caf) + add_test (string_test_caf string_test caf) + add_test (long_read_write_test_alac long_read_write_test alac) + + # wav-tests + add_test (write_read_test_wav write_read_test wav) + add_test (lossy_comp_test_wav_pcm lossy_comp_test wav_pcm) + add_test (lossy_comp_test_wav_ima lossy_comp_test wav_ima) + add_test (lossy_comp_test_wav_msadpcm lossy_comp_test wav_msadpcm) + add_test (lossy_comp_test_wav_ulaw lossy_comp_test wav_ulaw) + add_test (lossy_comp_test_wav_alaw lossy_comp_test wav_alaw) + add_test (lossy_comp_test_wav_gsm610 lossy_comp_test wav_gsm610) + add_test (lossy_comp_test_wav_g721 lossy_comp_test wav_g721) + add_test (peak_chunk_test_wav peak_chunk_test wav) + add_test (header_test_wav header_test wav) + add_test (misc_test_wav misc_test wav) + add_test (string_test_wav string_test wav) + add_test (multi_file_test_wav multi_file_test wav) + add_test (chunk_test_wav chunk_test wav) + + ### w64-tests + + add_test (write_read_test_w64 write_read_test w64) + add_test (lossy_comp_test_w64_ima lossy_comp_test w64_ima) + add_test (lossy_comp_test_w64_msadpcm lossy_comp_test w64_msadpcm) + add_test (lossy_comp_test_w64_ulaw lossy_comp_test w64_ulaw) + add_test (lossy_comp_test_w64_alaw lossy_comp_test w64_alaw) + add_test (lossy_comp_test_w64_gsm610 lossy_comp_test w64_gsm610) + add_test (header_test_w64 header_test w64) + add_test (misc_test_w64 misc_test w64) + + ### rf64-tests + + add_test (write_read_test_rf64 write_read_test rf64) + add_test (header_test_rf64 header_test rf64) + add_test (misc_test_rf64 misc_test rf64) + add_test (string_test_rf64 string_test rf64) + add_test (peak_chunk_test_rf64 peak_chunk_test rf64) + add_test (chunk_test_rf64 chunk_test rf64) + + ### raw-tests + add_test (write_read_test_raw write_read_test raw) + add_test (lossy_comp_test_raw_ulaw lossy_comp_test raw_ulaw) + add_test (lossy_comp_test_raw_alaw lossy_comp_test raw_alaw) + add_test (lossy_comp_test_raw_gsm610 lossy_comp_test raw_gsm610) + add_test (lossy_comp_test_vox_adpcm lossy_comp_test vox_adpcm) + add_test (raw_test raw_test) + + ### paf-tests + add_test (write_read_test_paf write_read_test paf) + add_test (header_test_paf header_test paf) + add_test (misc_test_paf misc_test paf) + + ### svx-tests + add_test (write_read_test_svx write_read_test svx) + add_test (header_test_svx header_test svx) + add_test (misc_test_svx misc_test svx) + + ### nist-tests + add_test (write_read_test_nist write_read_test nist) + add_test (lossy_comp_test_nist_ulaw lossy_comp_test nist_ulaw) + add_test (lossy_comp_test_nist_alaw lossy_comp_test nist_alaw) + add_test (header_test_nist header_test nist) + add_test (misc_test_nist misc_test nist) + + ### ircam-tests + add_test (write_read_test_ircam write_read_test ircam) + add_test (lossy_comp_test_ircam_ulaw lossy_comp_test ircam_ulaw) + add_test (lossy_comp_test_ircam_alaw lossy_comp_test ircam_alaw) + add_test (header_test_ircam header_test ircam) + add_test (misc_test_ircam misc_test ircam) + + ### voc-tests + add_test (write_read_test_voc write_read_test voc) + add_test (lossy_comp_test_voc_ulaw lossy_comp_test voc_ulaw) + add_test (lossy_comp_test_voc_alaw lossy_comp_test voc_alaw) + add_test (header_test_voc header_test voc) + add_test (misc_test_voc misc_test voc) + + ### mat4-tests + add_test (write_read_test_mat4 write_read_test mat4) + add_test (header_test_mat4 header_test mat4) + add_test (misc_test_mat4 misc_test mat4) + + ### mat5-tests + add_test (write_read_test_mat5 write_read_test mat5) + add_test (header_test_mat5 header_test mat5) + add_test (misc_test_mat5 misc_test mat5) + + ### pvf-tests + add_test (write_read_test_pvf write_read_test pvf) + add_test (header_test_pvf header_test pvf) + add_test (misc_test_pvf misc_test pvf) + + ### xi-tests + add_test (lossy_comp_test_xi_dpcm lossy_comp_test xi_dpcm) + + ### htk-tests + add_test (write_read_test_htk write_read_test htk) + add_test (header_test_htk header_test htk) + add_test (misc_test_htk misc_test htk) + + ### avr-tests + add_test (write_read_test_avr write_read_test avr) + add_test (header_test_avr header_test avr) + add_test (misc_test_avr misc_test avr) + + ### sds-tests + add_test (write_read_test_sds write_read_test sds) + add_test (header_test_sds header_test sds) + add_test (misc_test_sds misc_test sds) + + # sd2-tests + add_test (write_read_test_sd2 write_read_test sd2) + + ### wve-tests + add_test (lossy_comp_test_wve lossy_comp_test wve) + + ### mpc2k-tests + add_test (write_read_test_mpc2k write_read_test mpc2k) + add_test (header_test_mpc2k header_test mpc2k) + add_test (misc_test_mpc2k misc_test mpc2k) + + ### flac-tests + add_test (write_read_test_flac write_read_test flac) + add_test (compression_size_test_flac compression_size_test flac) + add_test (string_test_flac string_test flac) + + ### vorbis-tests + add_test (ogg_test ogg_test) + add_test (compression_size_test_vorbis compression_size_test vorbis) + add_test (lossy_comp_test_ogg_vorbis lossy_comp_test ogg_vorbis) + add_test (string_test_ogg string_test ogg) + add_test (misc_test_ogg misc_test ogg) + + ### io-tests + add_test (stdio_test stdio_test) + add_test (pipe_test pipe_test) + add_test (virtual_io_test virtual_io_test) + +endif (BUILD_TESTING) diff --git a/Makefile.am b/Makefile.am index b9d912a2..f048a961 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,14 +14,14 @@ if FULL_SUITE SUBDIRS += man doc $(octave_dir) regtest programs endif -DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs +DIST_SUBDIRS = M4 cmake man doc Win32 src Octave examples regtest tests programs EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Scripts/android-configure.sh \ Scripts/linux-to-win-cross-configure.sh Scripts/build-test-tarball.mk.in \ CMakeLists.txt CMake/autogen.cmake CMake/build.cmake CMake/check.cmake \ CMake/compiler_is_gcc.c CMake/external_libs.cmake CMake/file.cmake \ - CMake/have_decl_s_irgrp.c CMake/libsndfile.cmake .editorconfig - + CMake/have_decl_s_irgrp.c CMake/libsndfile.cmake .editorconfig \ + CMakeLists.txt sndfile.pc.cmake.in CLEANFILES = *~ diff --git a/cmake/ClipMode.cmake b/cmake/ClipMode.cmake new file mode 100644 index 00000000..e47497dc --- /dev/null +++ b/cmake/ClipMode.cmake @@ -0,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 + 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 + 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) diff --git a/cmake/FindFLAC.cmake b/cmake/FindFLAC.cmake new file mode 100644 index 00000000..b1ccf0f0 --- /dev/null +++ b/cmake/FindFLAC.cmake @@ -0,0 +1,47 @@ +# - Find FLAC +# Find the native FLAC includes and libraries +# +# FLAC_INCLUDE_DIRS - where to find FLAC headers. +# FLAC_LIBRARIES - List of libraries when using libFLAC. +# FLAC_FOUND - True if libFLAC found. +# FLAC_DEFINITIONS - FLAC compile definitons + +if (FLAC_INCLUDE_DIR) + # Already in cache, be silent + set (FLAC_FIND_QUIETLY TRUE) +endif (FLAC_INCLUDE_DIR) + +find_package (Ogg QUIET) + +find_package (PkgConfig QUIET) +pkg_check_modules(PC_FLAC QUIET flac) + +find_path (FLAC_INCLUDE_DIR FLAC/stream_decoder.h + HINTS ${PC_FLAC_INCLUDEDIR} ${PC_FLAC_INCLUDE_DIRS} ${FLAC_ROOT} + PATH_SUFFIXES include) + +# MSVC built libraries can name them *_static, which is good as it +# distinguishes import libraries from static libraries with the same extension. +find_library (FLAC_LIBRARY NAMES FLAC libFLAC libFLAC_dynamic libFLAC_static + HINTS ${PC_FLAC_LIBDIR} ${PC_FLAC_LIBRARY_DIRS} ${FLAC_ROOT} + PATH_SUFFIXES lib) + +# Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if +# all listed variables are TRUE. +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (FLAC DEFAULT_MSG + FLAC_INCLUDE_DIR FLAC_LIBRARY) + +if (FLAC_FOUND) + set (FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR} ${OGG_INCLUDE_DIRS}) + set (FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARIES}) + if (WIN32) + set (FLAC_LIBRARIES ${FLAC_LIBRARIES} wsock32) + get_filename_component (FLAC_LIBRARY_FILENAME ${FLAC_LIBRARY} NAME_WE) + if (FLAC_LIBRARY_FILENAME MATCHES "libFLAC_static") + set (FLAC_DEFINITIONS -DFLAC__NO_DLL) + endif () + endif (WIN32) +endif (FLAC_FOUND) + +mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY) diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake new file mode 100644 index 00000000..a710518d --- /dev/null +++ b/cmake/FindOgg.cmake @@ -0,0 +1,30 @@ +# - Find ogg +# Find the native ogg includes and libraries +# +# OGG_INCLUDE_DIRS - where to find ogg.h, etc. +# OGG_LIBRARIES - List of libraries when using ogg. +# Ogg_FOUND - True if ogg found. + +if(OGG_INCLUDE_DIR) + # Already in cache, be silent + set(OGG_FIND_QUIETLY TRUE) +endif(OGG_INCLUDE_DIR) + +find_package (PkgConfig QUIET) +pkg_check_modules(PC_OGG QUIET ogg) + +find_path(OGG_INCLUDE_DIR ogg/ogg.h HINTS ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS} ${OGG_ROOT} PATH_SUFFIXES include) +# MSVC built ogg may be named ogg_static. +# The provided project files name the library with the lib prefix. +find_library(OGG_LIBRARY NAMES ogg ogg_static libogg libogg_static HINTS ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS} ${OGG_ROOT} PATH_SUFFIXES lib) +# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDE_DIR OGG_LIBRARY) + +if (OGG_FOUND) + set (OGG_LIBRARIES ${OGG_LIBRARY}) + set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR}) +endif (OGG_FOUND) + +mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY) diff --git a/cmake/FindSndio.cmake b/cmake/FindSndio.cmake new file mode 100644 index 00000000..6aece463 --- /dev/null +++ b/cmake/FindSndio.cmake @@ -0,0 +1,33 @@ +# - Find SoundIO (sndio) includes and libraries +# +# Sndio_FOUND - True if SNDIO_INCLUDE_DIR & SNDIO_LIBRARY are +# found +# SNDIO_LIBRARIES - Set when SNDIO_LIBRARY is found +# SNDIO_INCLUDE_DIRS - Set when SNDIO_INCLUDE_DIR is found +# +# SNDIO_INCLUDE_DIR - where to find sndio.h, etc. +# SNDIO_LIBRARY - the sndio library +# + +find_path(SNDIO_INCLUDE_DIR + NAMES sndio.h + DOC "The SoundIO include directory" +) + +find_library(SNDIO_LIBRARY + NAMES sndio + DOC "The SoundIO library" +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Sndio + REQUIRED_VARS SNDIO_LIBRARY SNDIO_INCLUDE_DIR +) + +if(Sndio_FOUND) + set(SNDIO_LIBRARIES ${SNDIO_LIBRARY}) + set(SNDIO_INCLUDE_DIRS ${SNDIO_INCLUDE_DIR}) +endif() + +mark_as_advanced(SNDIO_INCLUDE_DIR SNDIO_LIBRARY) + diff --git a/cmake/FindSpeex.cmake b/cmake/FindSpeex.cmake new file mode 100644 index 00000000..1620d9fd --- /dev/null +++ b/cmake/FindSpeex.cmake @@ -0,0 +1,25 @@ +# - Find Speex +# Find the native Speex includes and libraries +# +# SPEEX_INCLUDE_DIRS - where to find speex.h, etc. +# SPEEX_LIBRARIES - List of libraries when using Speex. +# Speex_FOUND - True if Speex found. + +if (SPEEX_INCLUDE_DIR) + set (SPEEX_FIND_QUIETLY TRUE) +endif () + +find_package (PkgConfig QUIET) +pkg_check_modules(PC_SPEEX QUIET speex) + +find_path (SPEEX_INCLUDE_DIR speex/speex.h HINTS ${PC_SPEEX_INCLUDEDIR} ${PC_SPEEX_INCLUDE_DIRS} ${SPEEX_ROOT} PATH_SUFFIXES include) +find_library (SPEEX_LIBRARY NAMES speex HINTS ${PC_SPEEX_LIBDIR} ${PC_SPEEX_LIBRARY_DIRS} ${SPEEX_ROOT} PATH_SUFFIXES lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Speex DEFAULT_MSG SPEEX_INCLUDE_DIR SPEEX_LIBRARY) + +mark_as_advanced (SPEEX_INCLUDE_DIR SPEEX_LIBRARY) + +set(SPEEX_INCLUDE_DIRS ${SPEEX_INCLUDE_DIR}) +set(SPEEX_LIBRARIES ${SPEEX_LIBRARY}) + diff --git a/cmake/FindVorbis.cmake b/cmake/FindVorbis.cmake new file mode 100644 index 00000000..2ba2de5d --- /dev/null +++ b/cmake/FindVorbis.cmake @@ -0,0 +1,49 @@ +# - Find vorbis +# Find the native vorbis includes and libraries +# +# VORBIS_INCLUDE_DIRS - where to find vorbis.h, etc. +# VORBIS_LIBRARIES - List of libraries when using vorbis(file). +# Vorbis_FOUND - True if vorbis found. + +if(VORBIS_INCLUDE_DIR) + # Already in cache, be silent + set(VORBIS_FIND_QUIETLY TRUE) +endif(VORBIS_INCLUDE_DIR) + +find_package (Ogg QUIET) + +find_package (PkgConfig QUIET) +pkg_check_modules(PC_VORBIS QUIET vorbis) +pkg_check_modules(PC_VORBISFILE QUIET vorbisfile) +pkg_check_modules(PC_VORBISENC QUIET vorbisenc) + +find_path(VORBIS_INCLUDE_DIR vorbis/codec.h vorbis/vorbisfile.h vorbis/vorbisfile.h + HINTS ${PC_VORBIS_INCLUDEDIR} ${PC_VORBIS_INCLUDE_DIRS} ${VORBIS_ROOT} + PATH_SUFFIXES include) +# MSVC built vorbis may be named vorbis_static +# The provided project files name the library with the lib prefix. +find_library(VORBIS_LIBRARY + NAMES vorbis vorbis_static libvorbis libvorbis_static + HINTS ${PC_VORBIS_LIBDIR} ${PC_VORBIS_LIBRARY_DIRS} ${VORBIS_ROOT} + PATH_SUFFIXES lib) +find_library(VORBISFILE_LIBRARY + NAMES vorbisfile vorbisfile_static libvorbisfile libvorbisfile_static + HINTS ${PC_VORBISFILE_LIBDIR} ${PC_VORBISFILE_LIBRARY_DIRS} ${VORBIS_ROOT} + PATH_SUFFIXES lib) +find_library(VORBISENC_LIBRARY + NAMES vorbisenc vorbisenc_static libvorbisenc libvorbisenc_static + HINTS ${PC_VORBISENC_LIBDIR} ${PC_VORBISENC_LIBRARY_DIRS} ${VORBIS_ROOT} + PATH_SUFFIXES lib) + +# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vorbis DEFAULT_MSG VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY) + +if (VORBIS_FOUND) + set (VORBIS_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIRS}) + set (VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${VORBISENC_LIBRARY} + ${OGG_LIBRARIES}) +endif (VORBIS_FOUND) + +mark_as_advanced(VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY) diff --git a/cmake/Makefile.am b/cmake/Makefile.am new file mode 100644 index 00000000..b071c0b6 --- /dev/null +++ b/cmake/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = FindFLAC.cmake FindOgg.cmake FindSndio.cmake \ + FindSpeex.cmake FindVorbis.cmake SndFileChecks.cmake \ + TestInline.cmake TestInline.c.in TestLargeFiles.cmake diff --git a/cmake/SndFileChecks.cmake b/cmake/SndFileChecks.cmake new file mode 100644 index 00000000..53e966e4 --- /dev/null +++ b/cmake/SndFileChecks.cmake @@ -0,0 +1,198 @@ +include (CheckFunctionExists) +include (CheckIncludeFile) +include (CheckLibraryExists) +include (CheckSymbolExists) +include (CheckTypeSize) +include (TestBigEndian) + +include (TestInline) +include (ClipMode) +include(TestLargeFiles) + +test_large_files(_LARGEFILES) + +if (LARGE_FILES_DEFINITIONS) + add_definitions(${LARGE_FILES_DEFINITIONS}) +endif () + +if (WIN32) + set(TYPEOF_SF_COUNT_T __int64) +else (UNIX) + set(TYPEOF_SF_COUNT_T int64_t) +endif () +set(SF_COUNT_MAX 0x7fffffffffffffffll) + +if (NOT WIN32) + find_package (ALSA) + if (ALSA_FOUND) + set (HAVE_ALSA_ASOUNDLIB_H TRUE) + else () + find_package (Sndio) + set (HAVE_SNDIO_H ${SNDIO_FOUND}) + endif (ALSA_FOUND) +endif () + +if (NOT DISABLE_EXTERNAL_LIBS) +find_package (Ogg) +find_package (Vorbis) +find_package (FLAC) +if (OGG_FOUND AND VORBIS_FOUND AND FLAC_FOUND) + set (HAVE_EXTERNAL_XIPH_LIBS 1) + set (EXTERNAL_XIPH_LIBS + ${OGG_LIBRARIES} + ${VORBIS_LIBRARIES} + ${FLAC_LIBRARIES}) +else () + set (DISABLE_EXTERNAL_LIBS ON) +endif () +endif () + +if (ENABLE_EXPERIMENTAL) + find_package (Speex) +endif () + +check_include_file(byteswap.h HAVE_BYTESWAP_H) +check_include_file(dlfcn.h HAVE_DLFCN_H) +check_include_file(endian.h HAVE_ENDIAN_H) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(locale.h HAVE_LOCALE_H) +check_include_file(memory.h HAVE_MEMORY_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(stdlib.h HAVE_STDLIB_H) +check_include_file(string.h HAVE_STRING_H) +check_include_file(strings.h HAVE_STRINGS_H) +check_include_file(sys/stat.h HAVE_SYS_STAT_H) +check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(sys/wait.h HAVE_SYS_WAIT_H) +check_include_file(unistd.h HAVE_UNISTD_H) +check_include_file(io.h HAVE_IO_H) +check_type_size(int64_t SIZEOF_INT64_T) +check_type_size(double SIZEOF_DOUBLE) +check_type_size(float SIZEOF_FLOAT) +check_type_size(int SIZEOF_INT) +check_type_size(loff_t SIZEOF_LOFF_T) +check_type_size(long SIZEOF_LONG) +check_type_size(long\ long SIZEOF_LONG_LONG) +check_type_size(offt64_t SIZEOF_OFF64_T) +check_type_size(short SIZEOF_SHORT) +check_type_size(size_t SIZEOF_SIZE_T) +check_type_size(ssize_t SIZEOF_SSIZE_T) +check_type_size(void* SIZEOF_VOIDP) +check_type_size(wchar_t SIZEOF_WCHAR_T) + +if ((SIZEOF_OFF_T EQUAL 8) OR (SIZEOF_LOFF_T EQUAL 8) OR (SIZEOF_OFF64_T EQUAL 8)) + set (TYPEOF_SF_COUNT_T "int64_t") + set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL") + set (SIZEOF_SF_COUNT_T 8) +else () + if (WIN32) + set (TYPEOF_SF_COUNT_T "__int64") + set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL") + set (SIZEOF_SF_COUNT_T 8) + else (NOT WIN32) + message ("") + message ("*** The configure process has determined that this system is capable") + message ("*** of Large File Support but has not been able to find a type which") + message ("*** is an unambiguous 64 bit file offset.") + message ("*** Please contact the author to help resolve this problem.") + message ("") + message (FATAL_ERROR "Bad file offset type.") + endif (WIN32) +endif () + +check_type_size(${TYPEOF_SF_COUNT_T} SIZEOF_SF_COUNT_T) + +find_library (M_LIBRARY m) +if (M_LIBRARY) + # Check if he need to link 'm' for math functions + check_library_exists (m floor "" LIBM_REQUIRED) + if (LIBM_REQUIRED) + list (APPEND CMAKE_REQUIRED_LIBRARIES ${M_LIBRARY}) + else () + unset (M_LIBRARY) + endif () +endif () + +check_library_exists (sqlite3 sqlite3_close "" HAVE_SQLITE3) + +check_function_exists(calloc HAVE_CALLOC) +check_function_exists(free HAVE_FREE) +check_function_exists(fstat HAVE_FSTAT) +check_function_exists(fstat64 HAVE_FSTAT64) +check_function_exists(fsync HAVE_FSYNC) +check_function_exists(ftruncate HAVE_FTRUNCATE) +check_function_exists(getpagesize HAVE_GETPAGESIZE) +check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) +check_function_exists(gmtime HAVE_GMTIME) +check_function_exists(gmtime_r HAVE_GMTIME_R) +check_function_exists(localtime HAVE_LOCALTIME) +check_function_exists(localtime_r HAVE_LOCALTIME_R) +check_function_exists(lseek HAVE_LSEEK) +check_function_exists(lseek64 HAVE_LSEEK64) +check_function_exists(malloc HAVE_MALLOC) +check_function_exists(mmap HAVE_MMAP) +check_function_exists(open HAVE_OPEN) +check_function_exists(pipe HAVE_PIPE) +check_function_exists(read HAVE_READ) +check_function_exists(realloc HAVE_REALLOC) +check_function_exists(setlocale HAVE_SETLOCALE) +check_function_exists(snprintf HAVE_SNPRINTF) +check_function_exists(vsnprintf HAVE_VSNPRINTF) +check_function_exists(waitpid HAVE_WAITPID) +check_function_exists(write HAVE_WRITE) +check_function_exists(ceil HAVE_CEIL) +check_function_exists(floor HAVE_FLOOR) +check_function_exists(fmod HAVE_FMOD) +check_function_exists(lrint HAVE_LRINT) +check_function_exists(lrintf HAVE_LRINTF) +check_function_exists(lround HAVE_LROUND) + +check_symbol_exists (S_IRGRP sys/stat.h HAVE_DECL_S_IRGRP) + +test_big_endian(WORDS_BIGENDIAN) +if (WORDS_BIGENDIAN) + set (WORDS_BIGENDIAN 1) + set (CPU_IS_BIG_ENDIAN 1) +else (${LITTLE_ENDIAN}) + set (CPU_IS_LITTLE_ENDIAN 1) +endif () + +if (WIN32) + set (OS_IS_WIN32 1) + set (USE_WINDOWS_API 1) + if (BUILD_SHARED_LIBS) + set (WIN32_TARGET_DLL 1) + endif () +if (MINGW) + set (__USE_MINGW_ANSI_STDIO 1) +endif (MINGW) +endif (WIN32) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") + set (OS_IS_OPENBSD 1) +endif () + + +if (CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang")) + set (COMPILER_IS_GCC 1) +endif () + +if (COMPILER_IS_GCC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") +endif () + +if (ENABLE_EXPERIMENTAL) + set (ENABLE_EXPERIMENTAL_CODE 1) +endif () + +test_inline () +if (NOT DISABLE_CPU_CLIP) + clip_mode () +endif () + +find_program (AUTOGEN_EXECUTABLE NAMES autogen) +if (NOT AUTOGEN_EXECUTABLE) + message ("autogen tool not found: tests will not be build.") + SET (BUILD_TESTING OFF) +endif () diff --git a/cmake/TestInline.c.in b/cmake/TestInline.c.in new file mode 100644 index 00000000..2aed6433 --- /dev/null +++ b/cmake/TestInline.c.in @@ -0,0 +1,10 @@ +static @INLINE_KEYWORD@ void test_inline(void) +{ + return; +} + +int main (void) +{ + test_inline (); + return 0; +} diff --git a/cmake/TestInline.cmake b/cmake/TestInline.cmake new file mode 100644 index 00000000..eb24c68c --- /dev/null +++ b/cmake/TestInline.cmake @@ -0,0 +1,54 @@ +macro (TEST_INLINE) + if (NOT DEFINED INLINE_CODE) + message (STATUS "Checking for inline...") + set (INLINE_KEYWORD "inline") + configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c) + try_compile (HAVE_INLINE "${CMAKE_CURRENT_BINARY_DIR}" + "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") + if (HAVE_INLINE) + message (STATUS "Checking for inline... supported") + else () + message (STATUS "Checking for inline... not supported") + + message (STATUS "Checking for __inline...") + set (INLINE_KEYWORD "__inline") + configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c) + try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}" + "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") + if (HAVE___INLINE) + message (STATUS "Checking for __inline... supported") + else () + message (STATUS "Checking for __inline... not supported") + + message (STATUS "Checking for __inline__...") + set (INLINE_KEYWORD "__inline__") + configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c) + try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}" + "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") + if (HAVE___INLINE) + message (STATUS "Checking for __inline__... supported") + + message (STATUS "Checking for __inline__...") + set (INLINE_KEYWORD "__inline__") + configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${CMAKE_SOURCE_DIR}/cmake/TestInline.c) + try_compile (HAVE___INLINE__ "${CMAKE_CURRENT_BINARY_DIR}" + "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") + else () + message (STATUS "Checking for __inline__... not supported") + set (INLINE_KEYWORD "") + endif () + + endif () + endif () + + if (HAVE_INLINE) + set (INLINE_CODE "/* #undef inline */" CACHE INTERNAL "") + elseif (HAVE___INLINE) + set (INLINE_CODE "#define inline __inline" CACHE INTERNAL "") + elseif (HAVE___INLINE__) + set (INLINE_CODE "#define inline __inline__" CACHE INTERNAL "") + else () + set (INLINE_CODE "#define inline " CACHE INTERNAL "") + endif () + endif () +endmacro (TEST_INLINE) diff --git a/cmake/TestLargeFiles.cmake b/cmake/TestLargeFiles.cmake new file mode 100644 index 00000000..c073d7b9 --- /dev/null +++ b/cmake/TestLargeFiles.cmake @@ -0,0 +1,113 @@ +include (CheckIncludeFile) +include (CheckTypeSize) +include (CMakePushCheckState) + +macro (TEST_LARGE_FILES VARIABLE) + +if (NOT DEFINED ${VARIABLE}) + + cmake_push_check_state() + + message (STATUS "") + message (STATUS "") + message (STATUS "Checking large files support...") + + message (STATUS "") + check_include_file(sys/types.h HAVE_SYS_TYPES_H) + check_include_file(stdint.h HAVE_STDINT_H) + check_include_file(stddef.h HAVE_STDDEF_H) + message (STATUS "") + + message (STATUS "Checking size of off_t without any definitions:") + check_type_size (off_t SIZEOF_OFF_T) + message (STATUS "Checking of off_t without any definitions: ${SIZEOF_OFF_T}") + if (SIZEOF_OFF_T EQUAL 8) + set (LARGE_FILES_DEFINITIONS "" CACHE INTERNAL "64-bit off_t required definitions") + set (FILE64 TRUE) + else () + unset (HAVE_SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T_CODE CACHE) + cmake_pop_check_state() + set (FILE64 FALSE) + endif () + + if (NOT FILE64) + set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_FILE_OFFSET_BITS=64) + message (STATUS "") + message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64:") + check_type_size (off_t SIZEOF_OFF_T) + message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64: ${SIZEOF_OFF_T}") + if (SIZEOF_OFF_T EQUAL 8) + set (_FILE_OFFSET_BITS 64 CACHE INTERNAL "") + set (_FILE_OFFSET_BITS_CODE "#define _FILE_OFFSET_BITS 64" CACHE INTERNAL "") + set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_FILE_OFFSET_BITS=64" CACHE INTERNAL "64-bit off_t required definitions") + set (FILE64 TRUE) + else () + set (_FILE_OFFSET_BITS_CODE "" CACHE INTERNAL "") + unset (HAVE_SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T_CODE CACHE) + cmake_pop_check_state() + set (FILE64 FALSE) + endif () + endif () + + if (NOT FILE64) + set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGE_FILES) + message (STATUS "") + message (STATUS "Checking size of off_t with _LARGE_FILES:") + check_type_size (off_t SIZEOF_OFF_T) + message (STATUS "Checking size of off_t with _LARGE_FILES: ${SIZEOF_OFF_T}") + if (SIZEOF_OFF_T EQUAL 8) + set (_LARGE_FILES 1 CACHE INTERNAL "") + set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGE_FILES" CACHE INTERNAL "64-bit off_t required definitions") + set (FILE64 TRUE) + else () + unset (HAVE_SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T_CODE CACHE) + cmake_pop_check_state() + set (FILE64 FALSE) + endif () + endif () + + if (NOT FILE64) + set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGEFILE_SOURCE) + unset (HAVE_SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T CACHE) + unset (SIZEOF_OFF_T_CODE CACHE) + message (STATUS "") + message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE:") + check_type_size (off_t SIZEOF_OFF_T) + message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE: ${SIZEOF_OFF_T}") + if (SIZEOF_OFF_T EQUAL 8) + set (_LARGEFILE_SOURCE 1 CACHE INTERNAL "") + set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGEFILE_SOURCE" CACHE INTERNAL "64-bit off_t required definitions") + set (FILE64 TRUE) + else () + cmake_pop_check_state() + set (FILE64 FALSE) + endif () + endif () + + message (STATUS "") + if (FILE64) + set (${VARIABLE} 1 CACHE INTERNAL "Result of tests for large file support" FORCE) + if (NOT SIZEOF_OFF_T_REQURED_DEFINITIONS) + message (STATUS "Result of checking large files support: supported") + else () + message (STATUS "Result of checking large files support: supported with ${LARGE_FILES_DEFINITIONS}") + message (STATUS "Add LARGE_FILES_DEFINITIONS to your compiler definitions or configure with _FILE_OFFSET_BITS,") + message (STATUS "_FILE_OFFSET_BITS_CODE, _LARGE_FILES and _LARGEFILE_SOURCE variables.") + endif () + else () + message ("Result of checking large files support: not supported") + set (${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE) + endif () + message ("") + message ("") + +endif (NOT DEFINED ${VARIABLE}) + +endmacro (TEST_LARGE_FILES VARIABLE) diff --git a/programs/sndfile-salvage.c b/programs/sndfile-salvage.c index d6200a6b..7164194f 100644 --- a/programs/sndfile-salvage.c +++ b/programs/sndfile-salvage.c @@ -30,6 +30,8 @@ ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "sfconfig.h" + #include #include #include @@ -37,7 +39,11 @@ #include #include #include +#if HAVE_UNISTD_H #include +#else +#include "sf_unistd.h" +#endif #include #include #include diff --git a/sndfile.pc.cmake.in b/sndfile.pc.cmake.in new file mode 100644 index 00000000..7e873299 --- /dev/null +++ b/sndfile.pc.cmake.in @@ -0,0 +1,12 @@ +prefix=@PC_PREFIX@ +exec_prefix=@PC_EXEC_PREFIX@ +libdir=@PC_LIBDIR@ +includedir=@PC_INCLUDEDIR@ + +Name: sndfile +Description: A library for reading and writing audio files +Requires: +Version: @PC_VERSION@ +Libs: -L${libdir} -lsndfile +Libs.private: @PC_PRIVATE_LIBS@ +Cflags: -I${includedir} diff --git a/src/Makefile.am b/src/Makefile.am index a86547a4..11313537 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,7 +14,8 @@ EXTRA_DIST = sndfile.h.in config.h.in test_endswap.c test_endswap.tpl test_endsw $(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py \ GSM610/README GSM610/COPYRIGHT GSM610/ChangeLog \ G72x/README G72x/README.original G72x/ChangeLog \ - make-static-lib-hidden-privates.sh + make-static-lib-hidden-privates.sh \ + config.h.cmake libsndfile.def.in.cmake version-metadata.rc.in.cmake noinst_HEADERS = common.h sfconfig.h sfendian.h wavlike.h sf_unistd.h ogg.h chanmap.h diff --git a/src/common.c b/src/common.c index b9f32233..3bf71471 100644 --- a/src/common.c +++ b/src/common.c @@ -22,6 +22,8 @@ #include #if HAVE_UNISTD_H #include +#else +#include "sf_unistd.h" #endif #include #include diff --git a/src/config.h.cmake b/src/config.h.cmake new file mode 100644 index 00000000..55fbb7cb --- /dev/null +++ b/src/config.h.cmake @@ -0,0 +1,311 @@ +/* Set to 1 if the compile is GNU GCC. */ +#cmakedefine01 COMPILER_IS_GCC + +/* 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 + +/* Set to 1 to enable experimental code. */ +#cmakedefine01 ENABLE_EXPERIMENTAL_CODE + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_ALSA_ASOUNDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_BYTESWAP_H + +/* Define to 1 if you have the `calloc' function. */ +#cmakedefine01 HAVE_CALLOC + +/* Define to 1 if you have the `ceil' function. */ +#cmakedefine01 HAVE_CEIL + +/* Set to 1 if S_IRGRP is defined. */ +#cmakedefine01 HAVE_DECL_S_IRGRP + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_ENDIAN_H + +/* Will be set to 1 if flac, ogg and vorbis are available. */ +#cmakedefine01 HAVE_EXTERNAL_XIPH_LIBS + +/* Define to 1 if you have the `floor' function. */ +#cmakedefine01 HAVE_FLOOR + +/* Define to 1 if you have the `fmod' function. */ +#cmakedefine01 HAVE_FMOD + +/* Define to 1 if you have the `free' function. */ +#cmakedefine01 HAVE_FREE + +/* Define to 1 if you have the `fstat' function. */ +#cmakedefine01 HAVE_FSTAT + +/* Define to 1 if you have the `fstat64' function. */ +#cmakedefine01 HAVE_FSTAT64 + +/* Define to 1 if you have the `fsync' function. */ +#cmakedefine01 HAVE_FSYNC + +/* Define to 1 if you have the `ftruncate' function. */ +#cmakedefine01 HAVE_FTRUNCATE + +/* Define to 1 if you have the `getpagesize' function. */ +#cmakedefine01 HAVE_GETPAGESIZE + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine01 HAVE_GETTIMEOFDAY + +/* Define if you have the `gmtime' function. */ +#cmakedefine HAVE_GMTIME + +/* Define if you have the `gmtime_r' function. */ +#cmakedefine HAVE_GMTIME_R + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IO_H + +/* Define to 1 if you have the `m' library (-lm). */ +#cmakedefine01 HAVE_LIBM + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_LOCALE_H + +/* Define if you have the `localtime' function. */ +#cmakedefine HAVE_LOCALTIME + +/* Define if you have the `localtime_r' function. */ +#cmakedefine HAVE_LOCALTIME_R + +/* Define if you have C99's lrint function. */ +#cmakedefine01 HAVE_LRINT + +/* Define if you have C99's lrintf function. */ +#cmakedefine01 HAVE_LRINTF + +/* Define to 1 if you have the `lround' function. */ +#cmakedefine01 HAVE_LROUND + +/* Define to 1 if you have the `lseek' function. */ +#cmakedefine01 HAVE_LSEEK + +/* Define to 1 if you have the `lseek64' function. */ +#cmakedefine01 HAVE_LSEEK64 + +/* Define to 1 if you have the `malloc' function. */ +#cmakedefine01 HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_MEMORY_H + +/* Define to 1 if you have the `mmap' function. */ +#cmakedefine01 HAVE_MMAP + +/* Define to 1 if you have the `open' function. */ +#cmakedefine01 HAVE_OPEN + +/* Define to 1 if you have the `pipe' function. */ +#cmakedefine01 HAVE_PIPE + +/* Define to 1 if you have the `read' function. */ +#cmakedefine01 HAVE_READ + +/* Define to 1 if you have the `realloc' function. */ +#cmakedefine01 HAVE_REALLOC + +/* Define to 1 if you have the `setlocale' function. */ +#cmakedefine01 HAVE_SETLOCALE + +/* Set to 1 if is available. */ +#cmakedefine01 HAVE_SNDIO_H + +/* Define to 1 if you have the `snprintf' function. */ +#cmakedefine01 HAVE_SNPRINTF + +/* Set to 1 if you have libsqlite3. */ +#cmakedefine01 HAVE_SQLITE3 + +/* Define to 1 if the system has the type `ssize_t'. */ +#cmakedefine01 HAVE_SSIZE_T + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#cmakedefine01 HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_UNISTD_H + +/* Define to 1 if you have the `vsnprintf' function. */ +#cmakedefine01 HAVE_VSNPRINTF + +/* Define to 1 if you have the `waitpid' function. */ +#cmakedefine01 HAVE_WAITPID + +/* Define to 1 if you have the `write' function. */ +#cmakedefine01 HAVE_WRITE + +/* The darwin version, no-zero is valid */ +#cmakedefine01 OSX_DARWIN_VERSION + +/* Set to 1 if compiling for OpenBSD */ +#cmakedefine01 OS_IS_OPENBSD + +/* Set to 1 if compiling for Win32 */ +#cmakedefine01 OS_IS_WIN32 + +/* Name of package */ +#define PACKAGE "@CPACK_PACKAGE_NAME@" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@CPACK_PACKAGE_NAME@" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@CPACK_PACKAGE_NAME@ @CPACK_PACKAGE_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@CPACK_PACKAGE_NAME@" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "@PACKAGE_URL@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@" + +/* Set to maximum allowed value of sf_count_t type. */ +#define SF_COUNT_MAX @SF_COUNT_MAX@ + +/* The size of `double', as computed by sizeof. */ +@SIZEOF_DOUBLE_CODE@ + +/* The size of `float', as computed by sizeof. */ +@SIZEOF_FLOAT_CODE@ + +/* The size of `int', as computed by sizeof. */ +@SIZEOF_INT_CODE@ + +/* The size of `int64_t', as computed by sizeof. */ +@SIZEOF_INT64_T_CODE@ + +/* The size of `loff_t', as computed by sizeof. */ +@SIZEOF_LOFF_T_CODE@ + +/* The size of `long', as computed by sizeof. */ +@SIZEOF_LONG_CODE@ + +/* The size of `long long', as computed by sizeof. */ +@SIZEOF_LONG_LONG_CODE@ + +/* The size of `off64_t', as computed by sizeof. */ +@SIZEOF_OFF64_T_CODE@ + +/* The size of `off_t', as computed by sizeof. */ +@SIZEOF_OFF_T_CODE@ + +/* Set to sizeof (long) if unknown. */ +@SIZEOF_SF_COUNT_T_CODE@ + +/* The size of `short', as computed by sizeof. */ +@SIZEOF_SHORT_CODE@ + +/* The size of `size_t', as computed by sizeof. */ +@SIZEOF_SIZE_T_CODE@ + +/* The size of `ssize_t', as computed by sizeof. */ +@SIZEOF_SSIZE_T_CODE@ + +/* The size of `void*', as computed by sizeof. */ +@SIZEOF_VOIDP_CODE@ + +/* The size of `wchar_t', as computed by sizeof. */ +@SIZEOF_WCHAR_T_CODE@ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine01 STDC_HEADERS + +/* Set to long if unknown. */ +#define TYPEOF_SF_COUNT_T @TYPEOF_SF_COUNT_T@ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Set to 1 to use the native windows API */ +#cmakedefine01 USE_WINDOWS_API + +/* Version number of package */ +#define VERSION "@PROJECT_VERSION@" + +/* Set to 1 if windows DLL is being built. */ +#cmakedefine01 WIN32_TARGET_DLL + +/* Target processor is big endian. */ +#cmakedefine01 WORDS_BIGENDIAN + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Define to 1 if on MINIX. */ +#cmakedefine01 _MINIX + +/* Set to 1 to use C99 printf/snprintf in MinGW. */ +#cmakedefine01 __USE_MINGW_ANSI_STDIO + +/* Define as `__inline' or '__inline__' if that's what the C compiler calls it, or to nothing if it is not supported. */ +@INLINE_CODE@ diff --git a/src/libsndfile.def.in.cmake b/src/libsndfile.def.in.cmake new file mode 100644 index 00000000..0e34c132 --- /dev/null +++ b/src/libsndfile.def.in.cmake @@ -0,0 +1,46 @@ +; Auto-generated by cmake + +LIBRARY ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.dll +EXPORTS + +sf_command @1 +sf_open @2 +sf_close @3 +sf_seek @4 +sf_error @7 +sf_perror @8 +sf_error_str @9 +sf_error_number @10 +sf_format_check @11 +sf_read_raw @16 +sf_readf_short @17 +sf_readf_int @18 +sf_readf_float @19 +sf_readf_double @20 +sf_read_short @21 +sf_read_int @22 +sf_read_float @23 +sf_read_double @24 +sf_write_raw @32 +sf_writef_short @33 +sf_writef_int @34 +sf_writef_float @35 +sf_writef_double @36 +sf_write_short @37 +sf_write_int @38 +sf_write_float @39 +sf_write_double @40 +sf_strerror @50 +sf_get_string @60 +sf_set_string @61 +sf_version_string @68 +sf_open_fd @70 +sf_wchar_open @71 +sf_open_virtual @80 +sf_write_sync @90 +sf_set_chunk @100 +sf_get_chunk_size @101 +sf_get_chunk_data @102 +sf_get_chunk_iterator @103 +sf_next_chunk_iterator @104 +sf_current_byterate @110 diff --git a/src/sf_unistd.h b/src/sf_unistd.h index 9fca68ef..2c32ab87 100644 --- a/src/sf_unistd.h +++ b/src/sf_unistd.h @@ -16,8 +16,34 @@ ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Microsoft declares some 'unistd.h' functions in 'io.h'. */ + +#ifdef HAVE_IO_H +#include +#endif + /* Some defines that microsoft 'forgot' to implement. */ +#ifndef R_OK +#define R_OK 4 /* Test for read permission. */ +#endif + +#ifndef W_OK +#define W_OK 2 /* Test for write permission. */ +#endif + +#ifndef X_OK +#ifdef WIN32 +#define X_OK 0 +#else +#define X_OK 1 /* execute permission - unsupported in windows*/ +#endif +#endif + +#ifndef F_OK +#define F_OK 0 /* Test for existence. */ +#endif + #ifndef S_IRWXU #define S_IRWXU 0000700 /* rwx, owner */ #endif diff --git a/src/sfconfig.h b/src/sfconfig.h index 0f308557..2f8a5d3f 100644 --- a/src/sfconfig.h +++ b/src/sfconfig.h @@ -116,4 +116,12 @@ #define CPU_IS_X86 (defined __i486__ || defined __i586__ || defined __i686__ || defined __x86_64__) #define CPU_IS_X86_64 (defined __x86_64__) +#ifndef HAVE_SSIZE_T +#define HAVE_SSIZE_T 0 +#endif + +#if (HAVE_SSIZE_T == 0) +#define ssize_t intptr_t +#endif + #endif diff --git a/src/version-metadata.rc.in.cmake b/src/version-metadata.rc.in.cmake new file mode 100644 index 00000000..aadc1ca5 --- /dev/null +++ b/src/version-metadata.rc.in.cmake @@ -0,0 +1,32 @@ +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +1 VERSIONINFO + FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 + PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN + FILEFLAGSMASK 0x00000000 + FILEFLAGS 0x00000000 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904e4" + { + VALUE "FileDescription", "A library for reading and writing audio files." + VALUE "FileVersion", "@PROJECT_VERSION@\0" + VALUE "Full Version", "@PROJECT_VERSION@" + VALUE "InternalName", "@PROJECT_NAME@" + VALUE "LegalCopyright", "Copyright (C) 1999-2012, Licensed LGPL" + VALUE "OriginalFilename", "@PROJECT_NAME@-@PROJECT_VERSION_MAJOR@.dll" + VALUE "ProductName", "@PROJECT_NAME@-@PROJECT_VERSION_MAJOR@ DLL" + VALUE "ProductVersion", "@PROJECT_VERSION@.0\0" + VALUE "Language", "Language Neutral" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04E4 + } +}