From e269b9519bd8145cbefbde996dae157607753196 Mon Sep 17 00:00:00 2001 From: Julien Bernard Date: Sat, 27 Jan 2024 01:35:44 +0100 Subject: [PATCH] add GLPK package (#3165) * add GLPK package * add a library call to glpk * apt is available only on Linux * try to build on windows too * remove readonly on config("shared") * fix glpk_5_0.def for shared library * use package version to set filenames * allow only x86_64 for macos * fix mistakes --- packages/g/glpk/xmake.lua | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 packages/g/glpk/xmake.lua diff --git a/packages/g/glpk/xmake.lua b/packages/g/glpk/xmake.lua new file mode 100644 index 00000000000..73face3fbed --- /dev/null +++ b/packages/g/glpk/xmake.lua @@ -0,0 +1,53 @@ +package("glpk") + set_homepage("https://www.gnu.org/software/glpk/") + set_description("The GLPK (GNU Linear Programming Kit) package is intended for solving large-scale linear programming (LP), mixed integer programming (MIP), and other related problems.") + set_license("GPL-3.0") + + set_urls("https://ftp.gnu.org/gnu/glpk/glpk-$(version).tar.gz") + + add_versions("5.0", "4a1013eebb50f728fc601bdd833b0b2870333c3b3e5a816eeba921d95bec6f15") + + if is_plat("linux") then + add_extsources("apt::libglpk-dev") + end + + on_install("macosx|x86_64", "linux", function (package) + local 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")) + import("package.tools.autoconf").install(package, configs) + end) + + on_install("windows", function (package) + os.cd("w64") -- Makefiles are the same in w64 and w32 directory + os.cp("config_VC", "config.h") + local version = package:version() + local basename = string.format("glpk_%d_%d", version:major(), version:minor()) + -- glp_netgen_prob is not defined, but should be disabled + -- see: https://www.mail-archive.com/bug-glpk@gnu.org/msg01020.html + io.replace(basename .. ".def", "glp_netgen_prob\n", "", {plain = true}) + import("package.tools.nmake").build(package, {"/f", package:config("shared") and "makefile_VC_DLL" or "makefile_VC"}) + + if package:config("shared") then + os.cp(basename .. ".dll", package:installdir("bin")) + os.cp(basename .. ".lib", package:installdir("lib")) + else + os.cp("glpk.lib", package:installdir("lib")) + end + + os.cd("..") + os.cp("src/glpk.h", package:installdir("include")) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + int main() { + glp_prob* prob = glp_create_prob(); + if (prob) { + glp_delete_prob(prob); + } + return 0; + } + ]]})) + end)