diff --git a/packages/g/gl2ps/port/xmake.lua b/packages/g/gl2ps/port/xmake.lua new file mode 100644 index 00000000000..34cc3b57b3a --- /dev/null +++ b/packages/g/gl2ps/port/xmake.lua @@ -0,0 +1,64 @@ +add_rules("mode.debug", "mode.release") + +set_project("gl2ps") +set_version("1.4.2") +set_languages("c99") + +option("zlib", {description = "Enable ZLIB compression", default = true}) +option("png", {description = "Enable PNG support", default = true}) + +includes("@builtin/check") + +set_configvar("GL2PS_MAJOR_VERSION", 1) +set_configvar("GL2PS_MINOR_VERSION", 4) +set_configvar("GL2PS_PATCH_VERSION", 2) +set_configvar("GL2PS_EXTRA_VERSION", "") +set_configvar("GL2PS_OS", is_plat("macosx") and "MacOSX" or (is_plat("windows", "mingw") and "Windows" or "Linux")) + +option("HAVE_VSNPRINTF") + add_cfuncs("vsnprintf") + add_cincludes("stdio.h") +option_end() + +if not has_config("HAVE_VSNPRINTF") then + add_defines("HAVE_NO_VSNPRINTF") +end + +add_requires("opengl", {optional = true}) +add_requires("glut") +if has_config("zlib") then + add_requires("zlib") + add_defines("HAVE_ZLIB") +end +if has_config("png") then + add_requires("libpng") + add_defines("HAVE_PNG") +end + +if is_plat("linux", "macosx") then + add_syslinks("m") +end + +if is_plat("macosx") then + add_cflags("-Wno-deprecated-declarations") +end + +target("gl2ps") + set_kind("$(kind)") + add_files("gl2ps.c") + add_headerfiles("gl2ps.h") + add_packages("opengl", "glut") + + if is_kind("shared") and is_plat("windows", "cygwin") then + add_defines("GL2PSDLL", "GL2PSDLL_EXPORTS") + end + if is_kind("static") then + add_defines("GL2PS_STATIC") + end + + if has_config("zlib") then + add_packages("zlib") + end + if has_config("png") then + add_packages("libpng") + end diff --git a/packages/g/gl2ps/xmake.lua b/packages/g/gl2ps/xmake.lua new file mode 100644 index 00000000000..443ee67425a --- /dev/null +++ b/packages/g/gl2ps/xmake.lua @@ -0,0 +1,52 @@ +package("gl2ps") + set_homepage("https://gitlab.onelab.info/gl2ps/gl2ps") + set_description("OpenGL to PostScript printing library") + set_license("LGPL") + + add_urls("https://gitlab.onelab.info/gl2ps/gl2ps/-/archive/gl2ps_$(version)/gl2ps-gl2ps_$(version).tar.gz", + "https://gitlab.onelab.info/gl2ps/gl2ps.git", { version = function(version) + return version:gsub("%.", "_") + end}) + + add_versions("1.4.2", "afb6f4a8df9c7639449546a79aabd1baaccacc4360fc23741c6485138512ff72") + + add_configs("zlib", {description = "Enable compression using ZLIB", default = true, type = "boolean"}) + add_configs("png", {description = "Enable PNG support", default = true, type = "boolean"}) + + add_deps("opengl", "glut") + + if is_plat("macosx", "linux", "bsd") then + add_deps("libx11") + end + + if is_plat("linux", "bsd") then + add_syslinks("m") + elseif is_plat("macosx") then + add_frameworks("Cocoa", "OpenGL") + end + + on_check("windows", function (package) + local msvc = package:toolchain("msvc") + if msvc and package:is_arch("arm.*") then + local vs = msvc:config("vs") + assert(vs and tonumber(vs) >= 2022, "package(gl2ps): requires Visual Studio 2022 and later for arm targets") + end + end) + + on_load(function (package) + if package:config("zlib") then + package:add("deps", "zlib") + end + if package:config("png") then + package:add("deps", "libpng") + end + end) + + on_install("windows", "linux", "macosx", "mingw", function (package) + os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:has_cfuncs("gl2psEndPage", {includes = "gl2ps.h"})) + end)