ref: 89027689b10428a4bac3b593915b7e0f71116d5f
parent: 4d5872263236aa13a90352d9ba3b0bb13434a065
author: Tal Aviram <me@talaviram.com>
date: Fri Jul 19 15:23:39 EDT 2019
Improve handling of config.h This allows libsamplerate to be more easily embedded in other projects.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,7 @@
include(CheckTypeSize)
include(CMakePushCheckState)
include(ClipMode)
+add_definitions(-DHAVE_CONFIG_H)
set(SAMPLERATE_SRC
${PROJECT_SOURCE_DIR}/src/samplerate.c
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,7 +27,8 @@
# MinGW requires -no-undefined if a DLL is to be built.
src_libsamplerate_la_LDFLAGS = -no-undefined -version-info $(SHARED_VERSION_INFO) $(SHLIB_VERSION_ARG)
src_libsamplerate_la_SOURCES = src/samplerate.c src/src_sinc.c src/src_zoh.c src/src_linear.c \
- src/common.h src/float_cast.h src/fastest_coeffs.h src/mid_qual_coeffs.h src/high_qual_coeffs.h
+ src/common.h src/float_cast.h src/fastest_coeffs.h src/mid_qual_coeffs.h src/high_qual_coeffs.h \
+ src/src_config.h
#-------------------------------------------------------------------------------
# An extra check for bad asm.
--- a/configure.ac
+++ b/configure.ac
@@ -223,7 +223,7 @@
dnl Compiler stuff.
AS_IF([test "x$enable_flags_setting" = "xyes"], [
- AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CFLAGS])
+ AX_APPEND_COMPILE_FLAGS([-DHAVE_CONFIG_H -O2 -pipe], [CFLAGS])
AS_CASE([${host_os}],
[darwin*], [
--- a/examples/audio_out.c
+++ b/examples/audio_out.c
@@ -11,7 +11,7 @@
#include <string.h>
#include <unistd.h>
-#include <config.h>
+#include "src_config.h"
#include "audio_out.h"
--- a/examples/timewarp-file.c
+++ b/examples/timewarp-file.c
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#include <stdio.h>
#include <stdlib.h>
--- a/examples/varispeed-play.c
+++ b/examples/varispeed-play.c
@@ -11,7 +11,7 @@
#include <unistd.h>
#include <string.h>
-#include "config.h"
+#include "src_config.h"
#include <float_cast.h>
--- a/src/float_cast.h
+++ b/src/float_cast.h
@@ -35,7 +35,7 @@
** long int lrint (double x) ;
*/
-#include "config.h"
+#include "src_config.h"
/*
** The presence of the required functions are detected during the configure
--- a/src/samplerate.c
+++ b/src/samplerate.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#include "config.h"
+#include "src_config.h"
#include "samplerate.h"
#include "float_cast.h"
--- /dev/null
+++ b/src/src_config.h
@@ -1,0 +1,12 @@
+/*
+** Copyright (c) 1999-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
+** All rights reserved.
+**
+** This code is released under 2-clause BSD license. Please see the
+** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
+*/
+
+// allow config.h to be optional
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#include "config.h"
+#include "src_config.h"
#include "float_cast.h"
#include "common.h"
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#include "config.h"
+#include "src_config.h"
#include "float_cast.h"
#include "common.h"
--- a/src/src_zoh.c
+++ b/src/src_zoh.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#include "config.h"
+#include "src_config.h"
#include "float_cast.h"
#include "common.h"
--- a/tests/calc_snr.c
+++ b/tests/calc_snr.c
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#include "util.h"
--- a/tests/callback_hang_test.c
+++ b/tests/callback_hang_test.c
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#include <stdio.h>
#include <stdlib.h>
--- a/tests/multi_channel_test.c
+++ b/tests/multi_channel_test.c
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#include <stdio.h>
#include <stdlib.h>
--- a/tests/multichan_throughput_test.c
+++ b/tests/multichan_throughput_test.c
@@ -14,7 +14,7 @@
#include <samplerate.h>
-#include "config.h"
+#include "src_config.h"
#include "util.h"
#include "float_cast.h"
--- a/tests/snr_bw_test.c
+++ b/tests/snr_bw_test.c
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#include <stdio.h>
#include <stdlib.h>
--- a/tests/src-evaluate.c
+++ b/tests/src-evaluate.c
@@ -12,7 +12,7 @@
#include <string.h>
#include <ctype.h>
-#include "config.h"
+#include "src_config.h"
#if (HAVE_FFTW3 && HAVE_SNDFILE && HAVE_SYS_TIMES_H)
--- a/tests/throughput_test.c
+++ b/tests/throughput_test.c
@@ -14,7 +14,7 @@
#include <samplerate.h>
-#include "config.h"
+#include "src_config.h"
#include "util.h"
#include "float_cast.h"
--- a/tests/util.h
+++ b/tests/util.h
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#define ABS(a) (((a) < 0) ? - (a) : (a))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
--- a/tests/varispeed_test.c
+++ b/tests/varispeed_test.c
@@ -6,7 +6,7 @@
** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
*/
-#include "config.h"
+#include "src_config.h"
#include <stdio.h>
#include <stdlib.h>