#include "config.h"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include <iostream>
#include <snapper/Snapper.h>
#include <snapper/SnapperTmpl.h>
#include <snapper/Enum.h>
+#include <snapper/Version.h>
#include "utils/text.h"
#include "utils/Table.h"
if (global_options.version())
{
cout << "snapper " << Snapper::compileVersion() << endl;
+ cout << "libsnapper " << LIBSNAPPER_VERSION_STRING;
+ if (strcmp(LIBSNAPPER_VERSION_STRING, get_libversion_string()) != 0)
+ cout << " (" << get_libversion_string() << ")";
+ cout << '\n';
cout << "flags " << Snapper::compileFlags() << endl;
exit(EXIT_SUCCESS);
}
AC_CHECK_HEADER(acl/libacl.h,[],[AC_MSG_ERROR([Cannout find libacl headers. Please install libacl-devel])])
AC_SUBST(VERSION)
+AC_SUBST(LIBVERSION)
AC_SUBST(LIBVERSION_MAJOR)
AC_SUBST(LIBVERSION_MINOR)
AC_SUBST(LIBVERSION_PATCHLEVEL)
SnapperTmpl.h \
SnapperTypes.h \
SnapperDefines.h \
- Version.h
+ Version.cc Version.h
if ENABLE_BTRFS
libsnapper_la_SOURCES += \
#include "snapper/Hooks.h"
#include "snapper/ComparisonImpl.h"
#include "snapper/Systemctl.h"
+#include "snapper/Version.h"
#ifdef ENABLE_BTRFS
#include "snapper/Btrfs.h"
#include "snapper/BtrfsUtils.h"
: snapshots(this)
{
y2mil("Snapper constructor");
- y2mil("libsnapper version " VERSION);
+ y2mil("snapper version " VERSION);
+ y2mil("libsnapper version " LIBSNAPPER_VERSION_STRING);
y2mil("config_name:" << config_name << " root_prefix:" << root_prefix <<
" disable_filters:" << disable_filters);
--- /dev/null
+/*
+ * Copyright (c) 2023 SUSE LLC
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "snapper/Version.h"
+
+
+namespace snapper
+{
+
+ const char*
+ get_libversion_string()
+ {
+ return LIBSNAPPER_VERSION_STRING;
+ }
+
+}
/*
* Copyright (c) 2013 Novell, Inc.
+ * Copyright (c) 2023 SUSE LLC
*
* All Rights Reserved.
*
#define SNAPPER_VERSION_H
+#define LIBSNAPPER_VERSION_STRING "@LIBVERSION@"
+
#define LIBSNAPPER_MAJOR "@LIBVERSION_MAJOR@"
#define LIBSNAPPER_MINOR "@LIBVERSION_MINOR@"
#define LIBSNAPPER_PATCHLEVEL "@LIBVERSION_PATCHLEVEL@"
-#define LIBSNAPPER_VERSION ( LIBSNAPPER_MAJOR * 10000 + \\
- LIBSNAPPER_MINOR * 100 + \\
- LIBSNAPPER_PATCHLEVEL )
+#define LIBSNAPPER_VERSION_AT_LEAST(major, minor) \
+ ((LIBSNAPPER_VERSION_MAJOR > (major)) || \
+ (LIBSNAPPER_VERSION_MAJOR == (major) && LIBSNAPPER_VERSION_MINOR >= (minor)))
+
+
+namespace snapper
+{
+
+ /**
+ * Return LIBSNAPPER_VERSION_STRING libsnapper was compiled with. May differ
+ * from the define (compile time vs. link time).
+ */
+ const char* get_libversion_string();
+
+}
#endif