diff --git a/Makefile b/Makefile index f98cb10c63e527c78e5aa188172363b41fc2661b..168eec9aff3fda656619f6151d96291e615bdc35 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ LD = $(CXX) CFLAGS = -pipe -std=c18 -Wall -Wextra -Wpedantic -Wshadow -g -O2 -fPIC CXXFLAGS = -pipe -std=c++20 -Wall -Wextra -Wpedantic -Wshadow -g -O2 -fPIC -fopenmp \ $(shell pkg-config --cflags-only-other $(pkg-config-deps)) -CPPFLAGS = -iquote include \ +CPPFLAGS = -DWEIL_VERSION='"$(version-major).$(version-minor)"' -iquote include \ $(shell pkg-config --cflags-only-I $(pkg-config-deps)) LDFLAGS = -fopenmp -Llib $(LDFLAGS_EXTRA) \ $(shell pkg-config --libs-only-L --libs-only-other $(pkg-config-deps)) diff --git a/src/weil.cpp b/src/weil.cpp index caa9857f476e88b2063b2837982c221859e728a7..f0a9b32679b51863139fe284381495db8bd0f3cc 100644 --- a/src/weil.cpp +++ b/src/weil.cpp @@ -49,6 +49,7 @@ print_help(bool error) "\n" "Options:\n" " --help, -h show this help message\n" + " --version, -V show version information\n" " --print-style=STYLE use this style to print things: pretty (default), sage, pari, latex\n" "\n" "Options specific to VV-Theta-series:\n" @@ -61,6 +62,28 @@ print_help(bool error) return error ? EXIT_FAILURE : EXIT_SUCCESS; } +int +print_version(void) +{ + std::cout << "weil version " WEIL_VERSION "\n" + "Copyright (C) 2022 Maik Herbers\n" + "\n" + "This program is free software: you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation, either version 3 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program. If not, see <https://www.gnu.org/licenses/>.\n"; + + return EXIT_SUCCESS; +} + static std::optional<weil::mpz_matrix> read_square_mpz_matrix(const char* file) { @@ -537,6 +560,7 @@ main(int argc, const char** argv) const struct option long_options[] = { { "help", no_argument, nullptr, 'h' }, + { "version", no_argument, nullptr, 'V' }, { "print-style", required_argument, nullptr, 0 }, { nullptr, 0, nullptr, 0 }, }; @@ -545,7 +569,7 @@ main(int argc, const char** argv) int opt; while (true) { // the `+' instructs `getopt_long' not to permute `argv' - opt = getopt_long(argc, const_cast<char* const*>(argv), "+h", long_options, &opt_idx); + opt = getopt_long(argc, const_cast<char* const*>(argv), "+hV", long_options, &opt_idx); if (opt == -1) { break; } @@ -568,6 +592,7 @@ main(int argc, const char** argv) } break; case 'h': return print_help(false); + case 'V': return print_version(); case '?': default: return print_help(true); }