Skip to content

πŸŽ› πŸ”Š A Python library for audio.

Fix ubuntu build with explicit lame_config.h.

Peter Sobot2aaa35db7ff0
diff --git a/setup.py b/setup.py
index 7159501..66c1312 100644
--- a/setup.py
+++ b/setup.py
@@ -31,6 +31,7 @@ ALL_COMPILER_FLAGS = [
]
ALL_INCLUDES = []
ALL_LINK_ARGS = []
+ALL_CFLAGS = []
ALL_CPPFLAGS = []
ALL_LIBRARIES = []
ALL_SOURCE_PATHS = []
@@ -89,37 +90,7 @@ ALL_SOURCE_PATHS += list(Path("vendors/rubberband/single").glob("*.cpp"))
# LAME/mpglib:
# (man, this code is portable)
-ALL_COMPILER_FLAGS.extend(
- [
- "-DSIZEOF_DOUBLE=8",
- "-DSIZEOF_FLOAT=4",
- "-DSIZEOF_INT=4",
- "-DSIZEOF_LONG=4",
- "-DSIZEOF_LONG_DOUBLE=12",
- "-DSIZEOF_SHORT=2",
- "-DSIZEOF_UNSIGNED_INT=4",
- "-DSIZEOF_UNSIGNED_LONG=4",
- "-DSIZEOF_UNSIGNED_SHORT=2",
- "-DSTDC_HEADERS",
- "-DHAVE_ERRNO_H",
- "-DHAVE_FCNTL_H",
- "-DHAVE_LIMITS_H",
- "-DPROTOTYPES=1",
- "-DHAVE_STRCHR",
- "-DHAVE_MEMCPY",
- "-DHAVE_MPGLIB",
- # Some data types are defined in config.h, which we don't include:
- "-Dieee754_float32_t=float",
- "-Duint8_t=u_int8_t",
- "-Duint16_t=u_int16_t",
- "-Duint32_t=u_int32_t",
- "-Duint64_t=u_int64_t",
- "-Dint8_t=char",
- "-Dint16_t=short",
- "-Dint32_t=int",
- "-Dint64_t=(long long)",
- ]
-)
+ALL_CFLAGS.extend(["-includevendors/lame_config.h", "-DHAVE_MPGLIB"])
ALL_SOURCE_PATHS += list(Path("vendors/lame/libmp3lame").glob("*.c"))
ALL_SOURCE_PATHS += list(Path("vendors/lame/mpglib").glob("*.c"))
ALL_INCLUDES += [
@@ -255,6 +226,7 @@ def patch_compile(original_compile):
elif ext in ('.c',):
# We're compiling C code, remove the -std= arg:
extra_postargs = [arg for arg in extra_postargs if 'std=' not in arg]
+ _cc_args = cc_args + ALL_CFLAGS
return original_compile(obj, src, ext, _cc_args, extra_postargs, *args, **kwargs)
diff --git a/vendors/lame_config.h b/vendors/lame_config.h
new file mode 100644
index 0000000..c7259d5
--- /dev/null
+++ b/vendors/lame_config.h
@@ -0,0 +1,122 @@
+#include <stdlib.h>
+
+#ifndef CONFIGMS_H_INCLUDED
+#define CONFIGMS_H_INCLUDED
+
+/* The number of bytes in a double. */
+#define SIZEOF_DOUBLE 8
+
+/* The number of bytes in a float. */
+#define SIZEOF_FLOAT 4
+
+/* The number of bytes in a int. */
+#define SIZEOF_INT 4
+
+/* The number of bytes in a long. */
+#define SIZEOF_LONG 4
+
+/* The number of bytes in a long double. */
+#define SIZEOF_LONG_DOUBLE 12
+
+/* The number of bytes in a short. */
+#define SIZEOF_SHORT 2
+
+/* The number of bytes in a unsigned int. */
+#define SIZEOF_UNSIGNED_INT 4
+
+/* The number of bytes in a unsigned long. */
+#define SIZEOF_UNSIGNED_LONG 4
+
+/* The number of bytes in a unsigned short. */
+#define SIZEOF_UNSIGNED_SHORT 2
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H
+
+/* Name of package */
+#define PACKAGE "lame"
+
+/* Define if compiler has function prototypes */
+#define PROTOTYPES 1
+
+/* faster log implementation with less but enough precission */
+#define USE_FAST_LOG 1
+
+#define HAVE_STRCHR
+#define HAVE_MEMCPY
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+#pragma warning( disable : 4305 )
+ typedef __int8 int8_t;
+ typedef __int16 int16_t;
+ typedef __int32 int32_t;
+ typedef __int64 int64_t;
+
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int64 uint64_t;
+
+ typedef float float32_t;
+ typedef double float64_t;
+#elif defined (__GNUC__)
+#define __int8_t_defined
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_t;
+typedef signed short int16_t;
+typedef signed int int32_t;
+#endif
+
+typedef long double ieee854_float80_t;
+typedef double ieee754_float64_t;
+typedef float ieee754_float32_t;
+
+#ifdef HAVE_MPGLIB
+# define DECODE_ON_THE_FLY 1
+#endif
+
+#ifdef LAME_ACM
+/* memory hacking for driver purposes */
+#define calloc(x,y) acm_Calloc(x,y)
+#define free(x) acm_Free(x)
+#define malloc(x) acm_Malloc(x)
+
+#include <stddef.h>
+void *acm_Calloc( size_t num, size_t size );
+void *acm_Malloc( size_t size );
+void acm_Free( void * mem);
+#endif /* LAME_ACM */
+
+#define LAME_LIBRARY_BUILD
+
+
+#ifdef HAVE_NASM
+ #if (defined(__ICL) && (__ICL >= 450))
+ #define HAVE_XMMINTRIN_H
+ #elif defined(_MSC_VER)
+ #include <malloc.h>
+ #ifdef _mm_malloc
+ #define HAVE_XMMINTRIN_H
+ #endif
+ #endif
+#endif
+
+#if defined(_M_X64) && !defined(HAVE_XMMINTRIN_H)
+ #define HAVE_XMMINTRIN_H
+#endif
+
+#endif