Blob Blame History Raw
From 3f6adc99506f065d0858e4d9d46055be9d070634 Mon Sep 17 00:00:00 2001
From: Nicola Sella <nsella@redhat.com>
Date: Fri, 22 Jan 2021 16:07:37 +0100
Subject: [PATCH] Avoid multilib file conflict in config.h (RhBug:1918818)

=changelog=
msg: Avoid multilib file conflicts in config.h
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1918818
---
 .gitignore                             |  2 +-
 libdnf/CMakeLists.txt                  |  8 ++++++-
 libdnf/{config.h.in => config-64.h.in} |  6 +++---
 libdnf/config.h                        | 29 ++++++++++++++++++++++++++
 4 files changed, 40 insertions(+), 5 deletions(-)
 rename libdnf/{config.h.in => config-64.h.in} (87%)
 create mode 100644 libdnf/config.h

diff --git a/.gitignore b/.gitignore
index e17a9b9bb..0a63bdae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,4 @@
 build
 *.pyc
 data/tests/modules/yum.repos.d/test.repo
-libdnf/config.h
+libdnf/config-64.h
diff --git a/libdnf/CMakeLists.txt b/libdnf/CMakeLists.txt
index e82aac11e..25f33d7b0 100644
--- a/libdnf/CMakeLists.txt
+++ b/libdnf/CMakeLists.txt
@@ -35,7 +35,13 @@ set(LIBDNF_SRCS
 include_directories(transaction)
 add_subdirectory("transaction")
 
-configure_file("config.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    set(MULTILIB_ARCH "64")
+    configure_file("config-64.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config-64.h)
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    set(MULTILIB_ARCH "32")
+    configure_file("config-64.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config-32.h)
+endif()
 configure_file("dnf-version.h.in"  ${CMAKE_CURRENT_SOURCE_DIR}/dnf-version.h)
 configure_file("libdnf.pc.in" ${CMAKE_CURRENT_BINARY_DIR}/libdnf.pc @ONLY)
 
diff --git a/libdnf/config.h.in b/libdnf/config-64.h.in
similarity index 87%
rename from libdnf/config.h.in
rename to libdnf/config-64.h.in
index 77974f757..e2329fe71 100644
--- a/libdnf/config.h.in
+++ b/libdnf/config-64.h.in
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef _LIBDNF_CONFIG_H_
-#define _LIBDNF_CONFIG_H_
+#ifndef _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
+#define _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
 
 #define DEFAULT_PLUGINS_DIRECTORY "@CMAKE_INSTALL_FULL_LIBDIR@/libdnf/plugins/"
 
-#endif // _LIBDNF_CONFIG_H_
+#endif // _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
diff --git a/libdnf/config.h b/libdnf/config.h
new file mode 100644
index 000000000..16121f6f5
--- /dev/null
+++ b/libdnf/config.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+#include "config-32.h"
+#elif __WORDSIZE == 64
+#include "config-64.h"
+#else
+#error "Unknown word size"
+#endif