Переглянути джерело

liba52: improve config.h (#4826)

* liba52: improve config.h

* improve set_configvar

* fix bsd
star9029 1 рік тому
батько
коміт
55d96d2f7e

+ 151 - 0
packages/l/liba52/port/config.h.in

@@ -0,0 +1,151 @@
+/* Suppress spurious compiler warnings */
+#ifdef _MSC_VER
+#pragma warning (disable: 4098 4244 4305 4761)
+#endif
+
+/* a52dec profiling */
+// ${define A52DEC_GPROF}
+
+/* maximum supported data alignment */
+// ${define ATTRIBUTE_ALIGNED_MAX}
+
+/* debug mode configuration */
+// ${define DEBUG}
+
+/* Define if you have the `__builtin_expect' function. */
+${define HAVE_BUILTIN_EXPECT}
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+// ${define HAVE_DLFCN_H}
+
+/* Define to 1 if you have the `ftime' function. */
+${define HAVE_FTIME}
+
+/* Define to 1 if you have the `gettimeofday' function. */
+${define HAVE_GETTIMEOFDAY}
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+${define HAVE_INTTYPES_H}
+
+/* Define to 1 if you have the <io.h> header file. */
+${define HAVE_IO_H}
+
+/* Define to 1 if you have the `memalign' function. */
+${define HAVE_MEMALIGN}
+
+/* Define to 1 if you have the <memory.h> header file. */
+// ${define HAVE_MEMORY_H}
+
+/* Define to 1 if you have the <stdint.h> header file. */
+// ${define HAVE_STDINT_H}
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+// ${define HAVE_STDLIB_H}
+
+/* Define to 1 if you have the <strings.h> header file. */
+// ${define HAVE_STRINGS_H}
+
+/* Define to 1 if you have the <string.h> header file. */
+${define HAVE_STRING_H}
+
+/* Define to 1 if the system has the type `struct timeval'. */
+// ${define HAVE_STRUCT_TIMEVAL}
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+// ${define HAVE_SYS_STAT_H}
+
+/* Define to 1 if you have the <sys/timeb.h> header file. */
+${define HAVE_SYS_TIMEB_H}
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+${define HAVE_SYS_TIME_H}
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+// ${define HAVE_SYS_TYPES_H}
+
+/* Define to 1 if you have the <time.h> header file. */
+${define HAVE_TIME_H}
+
+/* Define to 1 if you have the <unistd.h> header file. */
+// ${define HAVE_UNISTD_H}
+
+/* liba52 djbfft support */
+${define LIBA52_DJBFFT}
+
+/* a52 sample precision */
+// ${define LIBA52_DOUBLE}
+
+/* use fixed-point arithmetic */
+// ${define LIBA52_FIXED}
+
+/* libao al support */
+// ${define LIBAO_AL}
+
+/* libao OSS support */
+${define LIBAO_OSS}
+
+/* libao solaris support */
+// ${define LIBAO_SOLARIS}
+
+/* libao win support */
+${define LIBAO_WIN}
+
+/* Name of package */
+#define PACKAGE "a52dec"
+
+/* Define to the address where bug reports for this package should be sent. */
+// #define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+// #define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+// #define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+// #define PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+// #define PACKAGE_VERSION ""
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* The size of a `char', as computed by sizeof. */
+// #define SIZEOF_CHAR 1
+
+/* The size of a `int', as computed by sizeof. */
+// #define SIZEOF_INT 4
+
+/* The size of a `long', as computed by sizeof. */
+// #define SIZEOF_LONG 4
+
+/* The size of a `short', as computed by sizeof. */
+// #define SIZEOF_SHORT 2
+
+/* The size of a `void*', as computed by sizeof. */
+// #define SIZEOF_VOIDP 4
+
+/* Define to 1 if you have the ANSI C header files. */
+// #define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "0.8.0"
+
+/* Define to 1 if your processor stores words with the most significant byte
+   first (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef WORDS_BIGENDIAN */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+   if it is not supported. */
+// #define inline __inline
+
+/* Define as `__restrict' if that's what the C compiler calls it, or to
+   nothing if it is not supported. */
+// #define restrict __restrict
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef size_t */

+ 52 - 19
packages/l/liba52/port/xmake.lua

@@ -2,11 +2,6 @@ option("tools", {default = false})
 
 add_rules("mode.debug", "mode.release")
 
-add_includedirs("include")
-if is_plat("windows", "mingw") or is_host("windows") then
-    add_includedirs("vc++")
-end
-
 if is_plat("windows") and has_config("tools") then
     add_requires("strings_h")
 end
@@ -16,21 +11,43 @@ if is_plat("macosx") or (is_host("macosx") and is_plat("mingw")) then
     set_languages("gnu89")
 end
 
-rule("tools")
-    on_load(function (target)
-        if not get_config("tools") then
-            target:set("enabled", false)
-            return
-        end
+add_includedirs("include")
 
-        target:add("kind", "binary")
-        target:add("files", "src/getopt.c")
-        target:add("includedirs", "src")
-        target:add("deps", "a52")
-        if target:is_plat("windows") then
-            target:add("packages", "strings_h")
-        end
-    end)
+set_configdir("include")
+add_configfiles("config.h.in")
+
+includes("@builtin/check")
+-- set_configvar("ATTRIBUTE_ALIGNED_MAX", 4)
+configvar_check_cfuncs("HAVE_BUILTIN_EXPECT", "__builtin_expect")
+-- configvar_check_cincludes("HAVE_DLFCN_H", "dlfcn.h")
+configvar_check_cfuncs("HAVE_FTIME", "ftime", {includes = "time.h"})
+configvar_check_cfuncs("HAVE_GETTIMEOFDAY", "gettimeofday", {includes = "time.h"})
+configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h")
+configvar_check_cincludes("HAVE_IO_H", "io.h")
+configvar_check_cfuncs("HAVE_MEMALIGN", "memalign", {includes = "stdlib.h"})
+-- configvar_check_cincludes("HAVE_MEMORY_H", "memory.h")
+-- configvar_check_cincludes("HAVE_STDINT_H", "stdint.h")
+-- configvar_check_cincludes("HAVE_STDLIB_H", "stdlib.h")
+-- configvar_check_cincludes("HAVE_STRINGS_H", "strings.h")
+configvar_check_cincludes("HAVE_STRING_H", "string.h")
+configvar_check_cincludes("HAVE_STRUCT_TIMEVAL", ".h")
+-- configvar_check_cincludes("HAVE_SYS_STAT_H", "sys/stat.h")
+configvar_check_cincludes("HAVE_SYS_TIMEB_H", "sys/timeb.h")
+configvar_check_cincludes("HAVE_SYS_TIME_H", "sys/time.h")
+-- configvar_check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h")
+configvar_check_cincludes("HAVE_TIME_H", "time.h")
+-- configvar_check_cincludes("HAVE_UNISTD_H", "unistd.h")
+
+configvar_check_cincludes("LIBA52_DJBFFT", "fftc4.h")
+-- set_configvar("LIBA52_DOUBLE", "1")
+-- set_configvar("LIBA52_FIXED", "1")
+-- set_configvar("LIBAO_AL", "1")
+if is_plat("linux") then
+    set_configvar("LIBAO_OSS", "1")
+end
+if is_plat("windows", "mingw", "msys", "cygwin") then
+    set_configvar("LIBAO_WIN", 1)
+end
 
 target("a52")
     set_kind("$(kind)")
@@ -53,6 +70,22 @@ target("a52")
         add_rules("utils.symbols.export_all")
     end
 
+rule("tools")
+    on_load(function (target)
+        if not get_config("tools") then
+            target:set("enabled", false)
+            return
+        end
+
+        target:add("kind", "binary")
+        target:add("files", "src/getopt.c")
+        target:add("includedirs", "src")
+        target:add("deps", "a52")
+        if target:is_plat("windows") then
+            target:add("packages", "strings_h")
+        end
+    end)
+
 target("a52dec")
     add_rules("tools")
     add_files("src/a52dec.c", "src/gettimeofday.c")

+ 2 - 14
packages/l/liba52/xmake.lua

@@ -26,26 +26,14 @@ package("liba52")
         add_syslinks("m")
     end
 
-    if not is_host("windows") then
-        add_deps("autoconf", "automake", "libtool", "m4")
-    end
-
     on_load("windows", function (package)
         if package:config("tools") then
             package:add("deps", "strings_h", {private = true})
         end
     end)
 
-    on_install("!iphoneos and (!android or android@!windows)", function (package)
-        if not is_host("windows")then
-            -- Generate config.h by autotools
-            local configs = {}
-            if package:is_plat("android", "bsd", "wasm") then
-                table.insert(configs, "--disable-oss")
-                table.insert(configs, "--disable-djbfft")
-            end
-            import("package.tools.autoconf").configure(package, configs)
-        end
+    on_install(function (package)
+        os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "config.h.in")
         os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
         import("package.tools.xmake").install(package, {tools = package:config("tools")})
     end)