-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected]/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 <glpk.h> | ||
int main() { | ||
glp_prob* prob = glp_create_prob(); | ||
if (prob) { | ||
glp_delete_prob(prob); | ||
} | ||
return 0; | ||
} | ||
]]})) | ||
end) |