浏览代码

improve linux-tools (#319)

ruki 4 年之前
父节点
当前提交
08c82bb171
共有 4 个文件被更改,包括 41 次插入10 次删除
  1. 15 0
      packages/l/libcap/xmake.lua
  2. 11 3
      packages/l/libelf/xmake.lua
  3. 8 0
      packages/l/linux-tools/xmake.lua
  4. 7 7
      packages/p/pcre2/xmake.lua

+ 15 - 0
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)
 

+ 11 - 3
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)

+ 8 - 0
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

+ 7 - 7
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)