This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] Add a "selfcontained" mode to provide missing headers on windows
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: <elfutils-devel at sourceware dot org>
- Date: Wed, 3 May 2017 18:18:16 +0200
- Subject: [PATCH] Add a "selfcontained" mode to provide missing headers on windows
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=qt.io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=H+jAUegl3ArbsglwExrs8n3yPYhZ7w2y20CCv8GBSS4=; b=O47oYWUPo4gsjGsGOMGpJh2okE2oMWjKr7nx34if2YRS0qDxPPIGu6Ej3muzC4nNv1Mqb59sMLCWyxgXZOfVJSJluC2h9cCIY+z0NEH30+0UzYDiNQJHYUQS7GSGSXpzpxmmkulk/r3cxNCHBT1pd3EIWdj5LeL5NRKa2noqJQE=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
With MSVC there is no features.h, uid_t, gid_t, mode_t, and pid_t are
not defined and there is also no elf.h. To make it possible to build
other software against libelf and libdw, install our own version of
elf.h, and a bare-bones features.h that provides exactly the above
declarations. The features.h declarations are provided like mingw
defines them.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
ChangeLog | 4 ++++
configure.ac | 6 ++++++
lib/ChangeLog | 6 ++++++
lib/Makefile.am | 11 ++++++++++-
lib/features.h.in | 43 +++++++++++++++++++++++++++++++++++++++++++
libelf/ChangeLog | 4 ++++
libelf/Makefile.am | 9 ++++++++-
tests/ChangeLog | 5 +++++
tests/Makefile.am | 6 ++++++
9 files changed, 92 insertions(+), 2 deletions(-)
create mode 100644 lib/features.h.in
diff --git a/ChangeLog b/ChangeLog
index d43eeb6..cf14aec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-03 Ulf Hermann <ulf.hermann@qt.io>
+
+ * configure.ac: Add an --enable-selfcontained switch.
+
2017-04-28 Ulf Hermann <ulf.hermann@qt.io>
* configure.ac: Determine the binary format we're building natively.
diff --git a/configure.ac b/configure.ac
index e4b2946..1e7778d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,12 @@ AS_HELP_STRING([--enable-gnulib],
use_gnulib=$enableval, use_gnulib=no)
AM_CONDITIONAL(USE_GNULIB, test "$use_gnulib" = yes)
+AC_ARG_ENABLE([selfcontained],
+AS_HELP_STRING([--enable-selfcontained],
+ [install extra headers to enable including and linking the libraries on non-GNU systems]),
+ selfcontained=$enableval, selfcontained=no)
+AM_CONDITIONAL(SELFCONTAINED, test "$selfcontained" = yes)
+
AC_PROG_CC
gl_EARLY
diff --git a/lib/ChangeLog b/lib/ChangeLog
index ecc6179..2da6235 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-03 Ulf Hermann <ulf.hermann@qt.io>
+
+ * features.h.in: New file.
+ * Makefile.am: In selfcontained mode, install features.h.in as
+ features.h.
+
2017-04-27 Ulf Hermann <ulf.hermann@qt.io>
* eu-config.h: Define attribute_hidden to be empty if the compiler
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 17d16d0..87a922a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -39,8 +39,17 @@ libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
md5.h sha1.h eu-config.h color.h printversion.h
-EXTRA_DIST = dynamicsizehash.c
+EXTRA_DIST = dynamicsizehash.c features.h.in
if !GPROF
xmalloc_CFLAGS = -ffunction-sections
endif
+
+if SELFCONTAINED
+install: install-am features.h.in
+ $(mkinstalldirs) $(DESTDIR)$(includedir)
+ $(INSTALL_HEADER) $(top_srcdir)/lib/features.h.in $(DESTDIR)$(includedir)/features.h
+
+uninstall: uninstall-am
+ rm -f $(DESTDIR)$(includedir)/features.h
+endif
diff --git a/lib/features.h.in b/lib/features.h.in
new file mode 100644
index 0000000..6eb3c67
--- /dev/null
+++ b/lib/features.h.in
@@ -0,0 +1,43 @@
+/* This file defines uid_t, gid_t, mode_t, pid_t
+ Copyright (C) 2017 The Qt Company Ltd
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils 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 copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _FEATURES_H
+#define _FEATURES_H 1
+
+#include <stdint.h>
+
+typedef uint32_t uid_t;
+typedef uint32_t gid_t;
+typedef uint32_t mode_t;
+#ifdef _WIN64
+typedef int64_t pid_t;
+#else
+typedef int32_t pid_t;
+#endif
+
+#endif /* features.h */
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index e947e19..36da20c 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-03 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: In selfcontained mode, install elf.h.
+
2017-02-28 Ulf Hermann <ulf.hermann@qt.io>
* Makefile.am: Use the predefined common library names rather than
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 3286dda..1a2b85a 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -141,9 +141,16 @@ uninstall: uninstall-am uninstall-lib
rm -f $(DESTDIR)$(libdir)/$(libelf_SONAME)
rm -f $(DESTDIR)$(libdir)/$(libelf_BARE)
-noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
+noinst_HEADERS = abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
version_xlate.h gnuhash_xlate.h note_xlate.h dl-hash.h \
chdr_xlate.h
+
+if SELFCONTAINED
+include_HEADERS += elf.h
+else
+noinst_HEADERS += elf.h
+endif
+
EXTRA_DIST = libelf.map
CLEANFILES += $(am_libelf_pic_a_OBJECTS) $(libelf_SONAME) $(libelf_BARE)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index ab1a3788..b5a1866 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-03 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: In selfcontained mode, run the system libelf test
+ against our bundled elf.h.
+
2017-04-28 Ulf Hermann <ulf.hermann@qt.io>
* run-disasm-x86-64.sh: Disable if the native binary format is not
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 114ab7a..ed050eb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -511,9 +511,15 @@ emptyfile_LDADD = $(libelf) $(libgnu)
vendorelf_LDADD = $(libelf) $(libgnu)
fillfile_LDADD = $(libelf) $(libgnu)
+if SELFCONTAINED
+# In self contained mode we cannot expect a system elf header.
+# Use our own then
+system_elf_libelf_test_CPPFLAGS = -I$(top_srcdir)/libelf
+else
# We want to test the libelf header against the system elf.h header.
# Don't include any -I CPPFLAGS.
system_elf_libelf_test_CPPFLAGS =
+endif
if USE_GNULIB
system_elf_libelf_test_CPPFLAGS += -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu
endif
--
2.1.4