From 08c82bb171a6a152953232a53c71c19b4f48aa08 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 11 Mar 2021 11:36:42 +0800 Subject: [PATCH] improve linux-tools (#319) --- packages/l/libcap/xmake.lua | 15 +++++++++++++++ packages/l/libelf/xmake.lua | 14 +++++++++++--- packages/l/linux-tools/xmake.lua | 8 ++++++++ packages/p/pcre2/xmake.lua | 14 +++++++------- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/packages/l/libcap/xmake.lua b/packages/l/libcap/xmake.lua index 031a79e47..807e199ee 100644 --- a/packages/l/libcap/xmake.lua +++ b/packages/l/libcap/xmake.lua @@ -7,6 +7,21 @@ package("libcap") add_versions("2.27", "dac1792d0118bee6aae6ba7fb93ff1602c6a9bda812fd63916eee1435b9c486a") on_install("linux", function (package) + if not package:config("shared") then + io.replace("libcap/Makefile", "all: $(MINLIBNAME) $(STALIBNAME) libcap.pc", "all: $(STALIBNAME) libcap.pc", {plain = true}) + io.replace("libcap/Makefile", [[install: all + mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys + install -m 0644 include/sys/capability.h $(FAKEROOT)$(INCDIR)/sys + mkdir -p -m 0755 $(FAKEROOT)$(LIBDIR) + install -m 0644 $(STALIBNAME) $(FAKEROOT)$(LIBDIR)/$(STALIBNAME) + install -m 0644 $(MINLIBNAME) $(FAKEROOT)$(LIBDIR)/$(MINLIBNAME) + ln -sf $(MINLIBNAME) $(FAKEROOT)$(LIBDIR)/$(MAJLIBNAME) + ln -sf $(MAJLIBNAME) $(FAKEROOT)$(LIBDIR)/$(LIBNAME)]], [[install: all + mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys + install -m 0644 include/sys/capability.h $(FAKEROOT)$(INCDIR)/sys + mkdir -p -m 0755 $(FAKEROOT)$(LIBDIR) + install -m 0644 $(STALIBNAME) $(FAKEROOT)$(LIBDIR)/$(STALIBNAME)]], {plain = true}) + end os.vrunv("make", {"install", "prefix=" .. package:installdir(), "lib=lib", "RAISE_SETFCAP=no"}) end) diff --git a/packages/l/libelf/xmake.lua b/packages/l/libelf/xmake.lua index f77ecf12e..6f146804f 100644 --- a/packages/l/libelf/xmake.lua +++ b/packages/l/libelf/xmake.lua @@ -9,10 +9,18 @@ package("libelf") add_includedirs("include", "include/libelf") on_install("linux", function (package) - local configs = {"--disable-debug", - "--disable-dependency-tracking", + local configs = {"--disable-dependency-tracking", "--disable-compat"} - import("package.tools.autoconf").install(package, configs) + table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) + table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes")) + if package:debug() then + table.insert(configs, "--enable-debug") + end + local cxflags + if package:config("pic") ~= false then + cxflags = "-fPIC" + end + import("package.tools.autoconf").install(package, configs, {cxflags = cxflags}) end) on_test(function (package) diff --git a/packages/l/linux-tools/xmake.lua b/packages/l/linux-tools/xmake.lua index f082d1bfb..cc3887c25 100644 --- a/packages/l/linux-tools/xmake.lua +++ b/packages/l/linux-tools/xmake.lua @@ -22,6 +22,9 @@ package("linux-tools") if package:is_plat("linux") and package:is_arch("x86_64") then package:add("links", "bpf") package:add("linkdirs", "lib64") + if package:config("shared") then + package:addenv("LD_LIBRARY_PATH", "lib64") + end end end end) @@ -58,6 +61,11 @@ package("linux-tools") os.vrunv("make", table.join("install", configs)) os.cd("../../lib/bpf") io.replace("Makefile", "prefix ?= /usr/local", "prefix ?= " .. package:installdir(), {plain = true}) + if not package:config("shared") then + io.replace("Makefile", "LIB_TARGET%s-=.-\n", "LIB_TARGET = libbpf.a\n") + io.replace("Makefile", "LIB_FILE%s-=.-\n", "LIB_FILE = libbpf.a\n") + io.replace("Makefile", "all_cmd: $(CMD_TARGETS) check", "all_cmd: $(CMD_TARGETS)", {plain = true}) + end os.vrunv("make", table.join("install", configs)) os.cd(oldir) end diff --git a/packages/p/pcre2/xmake.lua b/packages/p/pcre2/xmake.lua index 14700ee36..af5312277 100644 --- a/packages/p/pcre2/xmake.lua +++ b/packages/p/pcre2/xmake.lua @@ -43,10 +43,13 @@ package("pcre2") on_install("macosx", "linux", "mingw", function (package) local configs = {} - if package:config("shared") then - table.insert(configs, "--enable-shared=yes") - else - table.insert(configs, "--enable-shared=no") + table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) + table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes")) + if package:debug() then + table.insert(configs, "--enable-debug") + end + if package:config("pic") ~= false then + table.insert(configs, "--with-pic") end if package:config("jit") then table.insert(configs, "--enable-jit") @@ -56,9 +59,6 @@ package("pcre2") table.insert(configs, "--disable-pcre2-8") table.insert(configs, "--enable-pcre2-" .. bitwidth) end - if package:debug() then - table.insert(configs, "--enable-debug") - end import("package.tools.autoconf").install(package, configs) end)