Browse Source

improve libelf (#321)

ruki 4 years ago
parent
commit
f3add34062

+ 21 - 0
packages/a/argp-standalone/xmake.lua

@@ -0,0 +1,21 @@
+package("argp-standalone")
+
+    set_homepage("https://www.lysator.liu.se/~nisse/misc/")
+    set_description("Standalone version of arguments parsing functions from GLIBC")
+
+    add_urls("https://www.lysator.liu.se/~nisse/misc/argp-standalone-$(version).tar.gz")
+    add_versions("1.3", "dec79694da1319acd2238ce95df57f3680fea2482096e483323fddf3d818d8be")
+
+    on_install("macosx", "android", function (package)
+        local cxflags
+        if package:config("pic") ~= false then
+            cxflags = "-fPIC"
+        end
+        import("package.tools.autoconf").install(package, {}, {cxflags = cxflags})
+        os.vcp("libargp.a", package:installdir("lib"))
+        os.vcp("argp.h", package:installdir("include"))
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("argp_parse", {includes = "argp.h"}))
+    end)

+ 303 - 0
packages/e/elfutils/patches/0.183/configure.patch

@@ -0,0 +1,303 @@
+diff --git a/configure b/configure
+index ec4ed1f..b173800 100755
+--- a/configure
++++ b/configure
+@@ -5160,55 +5160,6 @@ else
+   NM="$ac_cv_prog_NM"
+ fi
+ 
+-
+-# We use -std=gnu99 but have explicit checks for some language constructs
+-# and GNU extensions since some compilers claim GNU99 support, but don't
+-# really support all language extensions. In particular we need
+-# Mixed Declarations and Code
+-# https://gcc.gnu.org/onlinedocs/gcc/Mixed-Declarations.html
+-# Nested Functions
+-# https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
+-# Arrays of Variable Length
+-# https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc with GNU99 support" >&5
+-$as_echo_n "checking for gcc with GNU99 support... " >&6; }
+-if ${ac_cv_c99+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  old_CFLAGS="$CFLAGS"
+-CFLAGS="$CFLAGS -std=gnu99"
+-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h.  */
+-int foo (int a)
+-{
+-  for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s;
+-}
+-
+-double bar (double a, double b)
+-{
+-  double square (double z) { return z * z; }
+-  return square (a) + square (b);
+-}
+-
+-void baz (int n)
+-{
+-  struct S { int x[n]; };
+-}
+-_ACEOF
+-if ac_fn_c_try_compile "$LINENO"; then :
+-  ac_cv_c99=yes
+-else
+-  ac_cv_c99=no
+-fi
+-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+-CFLAGS="$old_CFLAGS"
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c99" >&5
+-$as_echo "$ac_cv_c99" >&6; }
+-if test "x$ac_cv_c99" != xyes; then :
+-  as_fn_error $? "gcc with GNU99 support required" "$LINENO" 5
+-fi
+-
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc supports __attribute__((visibility()))" >&5
+ $as_echo_n "checking whether gcc supports __attribute__((visibility()))... " >&6; }
+ if ${ac_cv_visibility+:} false; then :
+@@ -5363,43 +5314,6 @@ if test "$ac_cv_zdefs" = "yes"; then
+ 	dso_LDFLAGS="$dso_LDFLAGS $ZDEFS_LDFLAGS"
+ fi
+ 
+-# We really want build-ids. Warn and force generating them if gcc was
+-# configure without --enable-linker-build-id
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler generates build-ids" >&5
+-$as_echo_n "checking whether the compiler generates build-ids... " >&6; }
+-if ${ac_cv_buildid+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h.  */
+-
+-int
+-main ()
+-{
+-
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-if ac_fn_c_try_link "$LINENO"; then :
+-  ac_cv_buildid=yes; $READELF -n conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || ac_cv_buildid=no
+-else
+-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "unexpected compile failure
+-See \`config.log' for more details" "$LINENO" 5; }
+-fi
+-rm -f core conftest.err conftest.$ac_objext \
+-    conftest$ac_exeext conftest.$ac_ext
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_buildid" >&5
+-$as_echo "$ac_cv_buildid" >&6; }
+-if test "$ac_cv_buildid" = "no"; then
+-	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compiler doesn't generate build-id by default" >&5
+-$as_echo "$as_me: WARNING: compiler doesn't generate build-id by default" >&2;}
+-	LDFLAGS="$LDFLAGS -Wl,--build-id"
+-fi
+-
+ ZRELRO_LDFLAGS="-Wl,-z,relro"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc supports $ZRELRO_LDFLAGS" >&5
+ $as_echo_n "checking whether gcc supports $ZRELRO_LDFLAGS... " >&6; }
+@@ -5436,47 +5350,6 @@ if test "$ac_cv_zrelro" = "yes"; then
+ fi
+ 
+ 
+-
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __thread support" >&5
+-$as_echo_n "checking for __thread support... " >&6; }
+-if ${ac_cv_tls+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  # Use the same flags that we use for our DSOs, so the test is representative.
+-# Some old compiler/linker/libc combinations fail some ways and not others.
+-save_CFLAGS="$CFLAGS"
+-save_LDFLAGS="$LDFLAGS"
+-CFLAGS="$fpic_CFLAGS $CFLAGS"
+-LDFLAGS="$dso_LDFLAGS $LDFLAGS"
+-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h.  */
+-#include <stdlib.h>
+-#undef __thread
+-static __thread int a; int foo (int b) { return a + b; }
+-int
+-main ()
+-{
+-exit (foo (0));
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-if ac_fn_c_try_link "$LINENO"; then :
+-  ac_cv_tls=yes
+-else
+-  ac_cv_tls=no
+-fi
+-rm -f core conftest.err conftest.$ac_objext \
+-    conftest$ac_exeext conftest.$ac_ext
+-CFLAGS="$save_CFLAGS"
+-LDFLAGS="$save_LDFLAGS"
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tls" >&5
+-$as_echo "$ac_cv_tls" >&6; }
+-if test "x$ac_cv_tls" != xyes; then :
+-  as_fn_error $? "__thread support required" "$LINENO" 5
+-fi
+-
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc provides stdatomic.h" >&5
+ $as_echo_n "checking whether gcc provides stdatomic.h... " >&6; }
+ if ${ac_cv_has_stdatomic+:} false; then :
+@@ -7345,74 +7218,6 @@ $as_echo "#define HAVE_FALLTHROUGH 1" >>confdefs.h
+ 
+ fi
+ 
+-saved_LIBS="$LIBS"
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing argp_parse" >&5
+-$as_echo_n "checking for library containing argp_parse... " >&6; }
+-if ${ac_cv_search_argp_parse+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  ac_func_search_save_LIBS=$LIBS
+-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h.  */
+-
+-/* Override any GCC internal prototype to avoid an error.
+-   Use char because int might match the return type of a GCC
+-   builtin and then its argument prototype would still apply.  */
+-#ifdef __cplusplus
+-extern "C"
+-#endif
+-char argp_parse ();
+-int
+-main ()
+-{
+-return argp_parse ();
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-for ac_lib in '' argp; do
+-  if test -z "$ac_lib"; then
+-    ac_res="none required"
+-  else
+-    ac_res=-l$ac_lib
+-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+-  fi
+-  if ac_fn_c_try_link "$LINENO"; then :
+-  ac_cv_search_argp_parse=$ac_res
+-fi
+-rm -f core conftest.err conftest.$ac_objext \
+-    conftest$ac_exeext
+-  if ${ac_cv_search_argp_parse+:} false; then :
+-  break
+-fi
+-done
+-if ${ac_cv_search_argp_parse+:} false; then :
+-
+-else
+-  ac_cv_search_argp_parse=no
+-fi
+-rm conftest.$ac_ext
+-LIBS=$ac_func_search_save_LIBS
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_argp_parse" >&5
+-$as_echo "$ac_cv_search_argp_parse" >&6; }
+-ac_res=$ac_cv_search_argp_parse
+-if test "$ac_res" != no; then :
+-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+-
+-fi
+-
+-LIBS="$saved_LIBS"
+-case "$ac_cv_search_argp_parse" in
+-        no) { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "failed to find argp_parse
+-See \`config.log' for more details" "$LINENO" 5; } ;;
+-        -l*) argp_LDADD="$ac_cv_search_argp_parse" ;;
+-        *) argp_LDADD= ;;
+-esac
+-
+-
+ saved_LIBS="$LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing fts_close" >&5
+ $as_echo_n "checking for library containing fts_close... " >&6; }
+@@ -7481,75 +7286,6 @@ See \`config.log' for more details" "$LINENO" 5; } ;;
+ esac
+ 
+ 
+-saved_LIBS="$LIBS"
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _obstack_free" >&5
+-$as_echo_n "checking for library containing _obstack_free... " >&6; }
+-if ${ac_cv_search__obstack_free+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  ac_func_search_save_LIBS=$LIBS
+-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h.  */
+-
+-/* Override any GCC internal prototype to avoid an error.
+-   Use char because int might match the return type of a GCC
+-   builtin and then its argument prototype would still apply.  */
+-#ifdef __cplusplus
+-extern "C"
+-#endif
+-char _obstack_free ();
+-int
+-main ()
+-{
+-return _obstack_free ();
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-for ac_lib in '' obstack; do
+-  if test -z "$ac_lib"; then
+-    ac_res="none required"
+-  else
+-    ac_res=-l$ac_lib
+-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+-  fi
+-  if ac_fn_c_try_link "$LINENO"; then :
+-  ac_cv_search__obstack_free=$ac_res
+-fi
+-rm -f core conftest.err conftest.$ac_objext \
+-    conftest$ac_exeext
+-  if ${ac_cv_search__obstack_free+:} false; then :
+-  break
+-fi
+-done
+-if ${ac_cv_search__obstack_free+:} false; then :
+-
+-else
+-  ac_cv_search__obstack_free=no
+-fi
+-rm conftest.$ac_ext
+-LIBS=$ac_func_search_save_LIBS
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__obstack_free" >&5
+-$as_echo "$ac_cv_search__obstack_free" >&6; }
+-ac_res=$ac_cv_search__obstack_free
+-if test "$ac_res" != no; then :
+-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+-
+-fi
+-
+-LIBS="$saved_LIBS"
+-case "$ac_cv_search__obstack_free" in
+-        no) { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "failed to find _obstack_free
+-See \`config.log' for more details" "$LINENO" 5; } ;;
+-        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
+-        *) obstack_LIBS= ;;
+-esac
+-
+-
+-
+ ac_config_files="$ac_config_files doc/Makefile"
+ 
+ 

+ 53 - 0
packages/e/elfutils/xmake.lua

@@ -0,0 +1,53 @@
+package("elfutils")
+
+    set_homepage("https://fedorahosted.org/elfutils/")
+    set_description("Libraries and utilities for handling ELF objects")
+    set_license("GPL-2.0")
+
+    set_urls("https://sourceware.org/elfutils/ftp/$(version)/elfutils-$(version).tar.bz2")
+    add_versions("0.183", "c3637c208d309d58714a51e61e63f1958808fead882e9b607506a29e5474f2c5")
+
+    add_patches("0.183", path.join(os.scriptdir(), "patches", "0.183", "configure.patch"), "7a16719d9e3d8300b5322b791ba5dd02986f2663e419c6798077dd023ca6173a")
+
+    add_deps("m4", "zlib")
+    --[[
+    if is_plat("android") then
+        add_deps("argp-standalone")
+    end]]
+
+    on_install("linux", function (package)
+        local configs = {"--disable-dependency-tracking",
+                         "--disable-silent-rules",
+                         "--program-prefix=elfutils-",
+                         "--disable-symbol-versioning",
+                         "--disable-debuginfod",
+                         "--disable-libdebuginfod"}
+        local cflags = {}
+        local ldflags = {}
+        for _, dep in ipairs(package:orderdeps()) do
+            local fetchinfo = dep:fetch()
+            if fetchinfo then
+                for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
+                    table.insert(cflags, "-I" .. includedir)
+                end
+                for _, linkdir in ipairs(fetchinfo.linkdirs) do
+                    table.insert(ldflags, "-L" .. linkdir)
+                end
+                for _, link in ipairs(fetchinfo.links) do
+                    table.insert(ldflags, "-l" .. link)
+                end
+            end
+        end
+        if package:config("pic") ~= false then
+            table.insert(cflags, "-fPIC")
+        end
+        for _, makefile in ipairs(os.files(path.join("*/Makefile.in"))) do
+            io.replace(makefile, "-Wtrampolines", "", {plain = true})
+            io.replace(makefile, "-Wimplicit-fallthrough=5", "", {plain = true})
+        end
+        import("package.tools.autoconf").install(package, configs, {cflags = cflags, ldflags = ldflags})
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("elf_begin", {includes = "gelf.h"}))
+    end)

+ 3 - 1
packages/l/libelf/xmake.lua

@@ -3,7 +3,9 @@ package("libelf")
     set_homepage("https://web.archive.org/web/20181111033959/www.mr511.de/software/english.html")
     set_homepage("https://web.archive.org/web/20181111033959/www.mr511.de/software/english.html")
     set_description("ELF object file access library")
     set_description("ELF object file access library")
 
 
-    set_urls("https://dl.bintray.com/homebrew/mirror/libelf-$(version).tar.gz")
+    set_urls("https://dl.bintray.com/homebrew/mirror/libelf-$(version).tar.gz",
+             "https://github.com/xmake-mirror/libelf/releases/download/$(version)/libelf-$(version).tar.gz",
+             "https://github.com/xmake-mirror/libelf.git")
     add_versions("0.8.13", "591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d")
     add_versions("0.8.13", "591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d")
 
 
     add_includedirs("include", "include/libelf")
     add_includedirs("include", "include/libelf")