From 1f67ccfa203ee81cdd223501c01c8f7b9b3115f4 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 13 Nov 2022 16:45:42 +0800 Subject: [PATCH] Show license information in the --help message --- config.h.in | 1 + main.cc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config.h.in b/config.h.in index 203b4846..250e9fdc 100644 --- a/config.h.in +++ b/config.h.in @@ -1,2 +1,3 @@ #define MOLD_VERSION "@mold_VERSION@" #define MOLD_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@" +#cmakedefine01 MOLD_HAS_COMMERCIAL_LICENSE diff --git a/main.cc b/main.cc index dfa6d07d..e74dd532 100644 --- a/main.cc +++ b/main.cc @@ -27,10 +27,20 @@ namespace macho { int main(int argc, char **argv); } +static bool has_commercial_license() { + if (MOLD_HAS_COMMERCIAL_LICENSE) + return true; + char *env = getenv("MOLD_HAS_COMMERCIAL_LICENSE"); + return env && env[0]; +} + static std::string get_mold_version() { + std::string ver = "mold " MOLD_VERSION; + ver += has_commercial_license() ? " commercial edition" : " free edition"; + if (mold_git_hash.empty()) - return "mold " MOLD_VERSION " (compatible with GNU ld)"; - return "mold " MOLD_VERSION " (" + mold_git_hash + "; compatible with GNU ld)"; + return ver + " (compatible with GNU ld)"; + return ver + " (" + mold_git_hash + "; compatible with GNU ld)"; } void cleanup() {