public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] Enable building libelf of elfutils on win32
@ 2022-10-15 16:36 Yonggang Luo
  2022-10-15 16:36 ` [PATCH v2 2/7] move platform depended include into system.h of libelf Yonggang Luo
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yonggang Luo @ 2022-10-15 16:36 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

After these changes, now libelf can be build with mingw/gcc and msvc/clang

v1 -> v2

Do no modify libebl in commit move platform depended include into system.h of libelf
Add commit Move the #include <libintl.h> into eu-config.h to

Yonggang Luo (7):
  Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  move platform depended include into system.h of libelf
  Move the #include <libintl.h> into eu-config.h
  lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h>
  Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
  Fixes building with msvc/clang mingw/gcc
  Add CMake build files

 .gitignore                                    |   1 +
 CMakeLists.txt                                |  47 +++++
 configure.ac                                  |   1 +
 debuginfod/debuginfod.cxx                     |   1 -
 lib/color.c                                   |   1 -
 lib/eu-config.h                               |   8 +
 lib/printversion.c                            |   1 -
 lib/system.h                                  |  74 ++++++-
 lib/system_win32.c                            | 162 +++++++++++++++
 lib/xasprintf.c                               |   1 -
 lib/xmalloc.c                                 |   1 -
 libasm/asm_end.c                              |   1 -
 libasm/asm_error.c                            |   1 -
 libasm/asm_newscn.c                           |   1 -
 libcpu/i386_disasm.c                          |   2 +-
 libcpu/i386_lex.l                             |   1 -
 libcpu/i386_parse.y                           |   1 -
 libcpu/memory-access.h                        |  26 +--
 libcpu/riscv_disasm.c                         |   2 +-
 libdw/libdwP.h                                |   1 -
 libdw/memory-access.h                         |   8 +-
 libdwfl/argp-std.c                            |   1 -
 libdwfl/dwfl_error.c                          |   1 -
 libdwfl/dwfl_segment_report_module.c          |   2 +-
 libebl/libeblP.h                              |   1 -
 libelf/CMakeLists.txt                         | 192 ++++++++++++++++++
 libelf/common.h                               |   5 +-
 libelf/config-cmake/config.h                  |  27 +++
 libelf/elf32_checksum.c                       |   5 +-
 libelf/elf32_getphdr.c                        |   2 -
 libelf/elf32_getshdr.c                        |   2 -
 libelf/elf32_updatefile.c                     |   6 +-
 libelf/elf32_updatenull.c                     |   2 -
 libelf/elf32_xlatetof.c                       |   5 +-
 libelf/elf32_xlatetom.c                       |   1 -
 libelf/elf_begin.c                            |  10 +-
 libelf/elf_cntl.c                             |   2 -
 libelf/elf_compress.c                         |   2 -
 libelf/elf_end.c                              |   3 +-
 libelf/elf_error.c                            |   1 -
 libelf/elf_getarsym.c                         |  10 +-
 libelf/elf_getdata.c                          |   2 -
 libelf/elf_getdata_rawchunk.c                 |   2 -
 libelf/elf_getshdrstrndx.c                    |   2 -
 libelf/elf_readall.c                          |   2 -
 libelf/elf_update.c                           |   7 +-
 libelf/gelf_xlate.c                           |   1 -
 libelf/libelf.h                               |   6 +
 libelf/libelfP.h                              |   5 +
 libelf/nlist.c                                |   1 -
 lib/xasprintf.c => libelf/win32/ar.h          | 104 +++++-----
 src/addr2line.c                               |   1 -
 src/ar.c                                      |   1 -
 src/arlib-argp.c                              |   1 -
 src/arlib.c                                   |   1 -
 src/arlib.h                                   |   2 +-
 src/arlib2.c                                  |   1 -
 src/elfcmp.c                                  |   1 -
 src/elflint.c                                 |   1 -
 src/findtextrel.c                             |   1 -
 src/nm.c                                      |   1 -
 src/objdump.c                                 |   1 -
 src/ranlib.c                                  |   1 -
 src/readelf.c                                 |   1 -
 src/size.c                                    |   1 -
 src/strings.c                                 |   1 -
 src/strip.c                                   |   1 -
 src/unstrip.c                                 |   1 -
 tests/Makefile.am                             |   2 +-
 .../{hello2.spec. => hello2.spec}             |   0
 .../{hello3.spec. => hello3.spec}             |   0
 71 files changed, 612 insertions(+), 162 deletions(-)
 create mode 100644 CMakeLists.txt
 create mode 100644 lib/system_win32.c
 create mode 100644 libelf/CMakeLists.txt
 create mode 100644 libelf/config-cmake/config.h
 copy lib/xasprintf.c => libelf/win32/ar.h (66%)
 rename tests/debuginfod-rpms/{hello2.spec. => hello2.spec} (100%)
 rename tests/debuginfod-rpms/{hello3.spec. => hello3.spec} (100%)

-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/7] move platform depended include into system.h of libelf
  2022-10-15 16:36 [PATCH v2 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
@ 2022-10-15 16:36 ` Yonggang Luo
  2022-10-16 20:47   ` Mark Wielaard
  2022-10-15 16:36 ` [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h Yonggang Luo
  2022-10-15 16:36 ` [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h> Yonggang Luo
  2 siblings, 1 reply; 7+ messages in thread
From: Yonggang Luo @ 2022-10-15 16:36 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

All of these files either #include <system.h> directly or #include "libelfP.h"
And now "libelfP.h also #include <system.h>, so the platform depended include
can be moved to system.h safely

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 lib/system.h                  | 11 +++++++----
 libelf/common.h               |  3 ---
 libelf/elf32_checksum.c       |  1 -
 libelf/elf32_getphdr.c        |  2 --
 libelf/elf32_getshdr.c        |  2 --
 libelf/elf32_updatefile.c     |  3 ---
 libelf/elf32_updatenull.c     |  2 --
 libelf/elf32_xlatetof.c       |  1 -
 libelf/elf32_xlatetom.c       |  1 -
 libelf/elf_begin.c            |  3 ---
 libelf/elf_cntl.c             |  2 --
 libelf/elf_compress.c         |  2 --
 libelf/elf_end.c              |  1 -
 libelf/elf_getarsym.c         |  4 ----
 libelf/elf_getdata.c          |  2 --
 libelf/elf_getdata_rawchunk.c |  2 --
 libelf/elf_getshdrstrndx.c    |  2 --
 libelf/elf_readall.c          |  2 --
 libelf/elf_update.c           |  2 --
 libelf/gelf_xlate.c           |  1 -
 libelf/libelfP.h              |  1 +
 libelf/nlist.c                |  1 -
 22 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/lib/system.h b/lib/system.h
index d3f42c91..48004df1 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -35,14 +35,17 @@
 #include <errno.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <sys/param.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdarg.h>
 #include <stdlib.h>
 
+/* System dependend headers */
+#include <byteswap.h>
+#include <endian.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <unistd.h>
+
 #if defined(HAVE_ERROR_H)
 #include <error.h>
 #elif defined(HAVE_ERR_H)
diff --git a/libelf/common.h b/libelf/common.h
index 3718b3fd..4561854f 100644
--- a/libelf/common.h
+++ b/libelf/common.h
@@ -30,9 +30,6 @@
 #ifndef _COMMON_H
 #define _COMMON_H       1
 
-#include <ar.h>
-#include <byteswap.h>
-#include <endian.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c
index c5f27bbe..521668a7 100644
--- a/libelf/elf32_checksum.c
+++ b/libelf/elf32_checksum.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/libelf/elf32_getphdr.c b/libelf/elf32_getphdr.c
index 99b4ac09..4bfca24b 100644
--- a/libelf/elf32_getphdr.c
+++ b/libelf/elf32_getphdr.c
@@ -34,10 +34,8 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <assert.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
index 237d9122..fc696302 100644
--- a/libelf/elf32_getshdr.c
+++ b/libelf/elf32_getshdr.c
@@ -34,9 +34,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
-#include <unistd.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 1ff58900..46afa1f4 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -37,10 +37,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
 
-#include <system.h>
 #include "libelfP.h"
 
 
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index d0d4d1eb..6c06e5e4 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -32,12 +32,10 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <libelf.h>
 #include <stdbool.h>
 #include <string.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "elf-knowledge.h"
 
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index 082d833f..377659c8 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <string.h>
 
 #include "libelfP.h"
diff --git a/libelf/elf32_xlatetom.c b/libelf/elf32_xlatetom.c
index cb0bb8d5..fa3dc9a7 100644
--- a/libelf/elf32_xlatetom.c
+++ b/libelf/elf32_xlatetom.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <string.h>
 
 #include "libelfP.h"
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 71eb3594..fe8c640a 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -39,11 +39,8 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
 #include <sys/stat.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_cntl.c b/libelf/elf_cntl.c
index fd681789..04aa9132 100644
--- a/libelf/elf_cntl.c
+++ b/libelf/elf_cntl.c
@@ -31,8 +31,6 @@
 # include <config.h>
 #endif
 
-#include <unistd.h>
-
 #include "libelfP.h"
 
 
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index df0144e8..d7f53af2 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -31,14 +31,12 @@
 #endif
 
 #include <libelf.h>
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <zlib.h>
 
 /* Cleanup and return result.  Don't leak memory.  */
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 160f0b88..5c451f36 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -34,7 +34,6 @@
 #include <assert.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <sys/mman.h>
 
 #include "libelfP.h"
 
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 05ebf6a9..2203521f 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -32,16 +32,12 @@
 #endif
 
 #include <assert.h>
-#include <byteswap.h>
-#include <endian.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
-#include <system.h>
 #include <dl-hash.h>
 #include "libelfP.h"
 
diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c
index a704aae3..5ebd270f 100644
--- a/libelf/elf_getdata.c
+++ b/libelf/elf_getdata.c
@@ -35,10 +35,8 @@
 #include <errno.h>
 #include <stddef.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "libelfP.h"
-#include <system.h>
 #include "common.h"
 #include "elf-knowledge.h"
 
diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c
index 2f55cbb4..5a35ccdc 100644
--- a/libelf/elf_getdata_rawchunk.c
+++ b/libelf/elf_getdata_rawchunk.c
@@ -35,9 +35,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_getshdrstrndx.c b/libelf/elf_getshdrstrndx.c
index ad884fd3..2391317b 100644
--- a/libelf/elf_getshdrstrndx.c
+++ b/libelf/elf_getshdrstrndx.c
@@ -35,9 +35,7 @@
 #include <errno.h>
 #include <gelf.h>
 #include <stddef.h>
-#include <unistd.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_readall.c b/libelf/elf_readall.c
index 0a3a233d..d0f9a28c 100644
--- a/libelf/elf_readall.c
+++ b/libelf/elf_readall.c
@@ -32,10 +32,8 @@
 #endif
 
 #include <errno.h>
-#include <unistd.h>
 #include <sys/stat.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index 97ca9ca9..56af3a1c 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -33,8 +33,6 @@
 
 #include <libelf.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <sys/mman.h>
 #include <sys/stat.h>
 
 #include "libelfP.h"
diff --git a/libelf/gelf_xlate.c b/libelf/gelf_xlate.c
index 6f8c57b7..d8ad0634 100644
--- a/libelf/gelf_xlate.c
+++ b/libelf/gelf_xlate.c
@@ -32,7 +32,6 @@
 # include <config.h>
 #endif
 
-#include <byteswap.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 56331f45..d88a613c 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <system.h>
 
 /* Helper Macros to write 32 bit and 64 bit functions.  */
 #define __elfw2_(Bits, Name) __elf##Bits##_##Name
diff --git a/libelf/nlist.c b/libelf/nlist.c
index 8593c1de..b3d60435 100644
--- a/libelf/nlist.c
+++ b/libelf/nlist.c
@@ -35,7 +35,6 @@
 #include <gelf.h>
 #include <libelf.h>
 #include <nlist.h>
-#include <unistd.h>
 
 #include "libelfP.h"
 
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h
  2022-10-15 16:36 [PATCH v2 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
  2022-10-15 16:36 ` [PATCH v2 2/7] move platform depended include into system.h of libelf Yonggang Luo
@ 2022-10-15 16:36 ` Yonggang Luo
  2022-10-16 20:49   ` Mark Wielaard
  2022-10-15 16:36 ` [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h> Yonggang Luo
  2 siblings, 1 reply; 7+ messages in thread
From: Yonggang Luo @ 2022-10-15 16:36 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

So we do not need include in each file.
And indeed the macro
#define _(Str) dgettext ("elfutils", Str)
access libintl function dgettext, so it's make more sense
#include <libintl.h> in file eu-config.h

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 debuginfod/debuginfod.cxx | 1 -
 lib/color.c               | 1 -
 lib/eu-config.h           | 1 +
 lib/printversion.c        | 1 -
 lib/xasprintf.c           | 1 -
 lib/xmalloc.c             | 1 -
 libasm/asm_end.c          | 1 -
 libasm/asm_error.c        | 1 -
 libasm/asm_newscn.c       | 1 -
 libcpu/i386_lex.l         | 1 -
 libcpu/i386_parse.y       | 1 -
 libdw/libdwP.h            | 1 -
 libdwfl/argp-std.c        | 1 -
 libdwfl/dwfl_error.c      | 1 -
 libebl/libeblP.h          | 1 -
 libelf/elf_error.c        | 1 -
 src/addr2line.c           | 1 -
 src/ar.c                  | 1 -
 src/arlib-argp.c          | 1 -
 src/arlib.c               | 1 -
 src/arlib2.c              | 1 -
 src/elfcmp.c              | 1 -
 src/elflint.c             | 1 -
 src/findtextrel.c         | 1 -
 src/nm.c                  | 1 -
 src/objdump.c             | 1 -
 src/ranlib.c              | 1 -
 src/readelf.c             | 1 -
 src/size.c                | 1 -
 src/strings.c             | 1 -
 src/strip.c               | 1 -
 src/unstrip.c             | 1 -
 32 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 000a41c4..8e7ee499 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -47,7 +47,6 @@ extern "C" {
 
 #include <unistd.h>
 #include <stdlib.h>
-#include <libintl.h>
 #include <locale.h>
 #include <pthread.h>
 #include <signal.h>
diff --git a/lib/color.c b/lib/color.c
index e43b6143..bd105ec2 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <argp.h>
-#include <libintl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
diff --git a/lib/eu-config.h b/lib/eu-config.h
index c7d7cbb2..78a5c4fe 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -52,6 +52,7 @@
 # define rwlock_unlock(lock) ((void) (lock))
 #endif	/* USE_LOCKS */
 
+#include <libintl.h>
 /* gettext helper macros.  */
 #define N_(Str) Str
 #define _(Str) dgettext ("elfutils", Str)
diff --git a/lib/printversion.c b/lib/printversion.c
index f657329c..7d31fa83 100644
--- a/lib/printversion.c
+++ b/lib/printversion.c
@@ -30,7 +30,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include "printversion.h"
 
 void
diff --git a/lib/xasprintf.c b/lib/xasprintf.c
index 179ea2e8..d61fad90 100644
--- a/lib/xasprintf.c
+++ b/lib/xasprintf.c
@@ -33,7 +33,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <libintl.h>
 #include "libeu.h"
 #include "system.h"
 
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 7c094985..de7211f1 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -30,7 +30,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <sys/types.h>
diff --git a/libasm/asm_end.c b/libasm/asm_end.c
index 077d2aa5..a26120f2 100644
--- a/libasm/asm_end.c
+++ b/libasm/asm_end.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/libasm/asm_error.c b/libasm/asm_error.c
index cc3e660b..2b769395 100644
--- a/libasm/asm_error.c
+++ b/libasm/asm_error.c
@@ -31,7 +31,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdlib.h>
 
diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c
index 1150015f..d258d969 100644
--- a/libasm/asm_newscn.c
+++ b/libasm/asm_newscn.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/libcpu/i386_lex.l b/libcpu/i386_lex.l
index b6ec0f87..9b33ed95 100644
--- a/libcpu/i386_lex.l
+++ b/libcpu/i386_lex.l
@@ -31,7 +31,6 @@
 #endif
 
 #include <ctype.h>
-#include <libintl.h>
 
 #include <libeu.h>
 #include "system.h"
diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y
index 9a92c2e0..d2236d59 100644
--- a/libcpu/i386_parse.y
+++ b/libcpu/i386_parse.y
@@ -35,7 +35,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <math.h>
 #include <obstack.h>
 #include <search.h>
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 56b388c1..961fa4e7 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -29,7 +29,6 @@
 #ifndef _LIBDWP_H
 #define _LIBDWP_H 1
 
-#include <libintl.h>
 #include <stdbool.h>
 #include <pthread.h>
 
diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c
index 01ec18e2..bc013aa0 100644
--- a/libdwfl/argp-std.c
+++ b/libdwfl/argp-std.c
@@ -34,7 +34,6 @@
 #include <argp.h>
 #include <stdlib.h>
 #include <assert.h>
-#include <libintl.h>
 #include <fcntl.h>
 #include <unistd.h>
 
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index a5c683a9..43fa1dcc 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -31,7 +31,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index fa1c2c9f..c408ed97 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -32,7 +32,6 @@
 #include <gelf.h>
 #include <libasm.h>
 #include <libebl.h>
-#include <libintl.h>
 
 
 /* Backend handle.  */
diff --git a/libelf/elf_error.c b/libelf/elf_error.c
index 5364e685..e596108d 100644
--- a/libelf/elf_error.c
+++ b/libelf/elf_error.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/src/addr2line.c b/src/addr2line.c
index 25db2926..7768b266 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -28,7 +28,6 @@
 #include <inttypes.h>
 #include <libdwfl.h>
 #include <dwarf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/ar.c b/src/ar.c
index 04456c18..3bcb18fe 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -24,7 +24,6 @@
 #include <assert.h>
 #include <fcntl.h>
 #include <gelf.h>
-#include <libintl.h>
 #include <limits.h>
 #include <locale.h>
 #include <search.h>
diff --git a/src/arlib-argp.c b/src/arlib-argp.c
index a3c12e4d..115b9d76 100644
--- a/src/arlib-argp.c
+++ b/src/arlib-argp.c
@@ -20,7 +20,6 @@
 #endif
 
 #include <argp.h>
-#include <libintl.h>
 
 #include "arlib.h"
 
diff --git a/src/arlib.c b/src/arlib.c
index c09fc3c6..b8f89ba7 100644
--- a/src/arlib.c
+++ b/src/arlib.c
@@ -23,7 +23,6 @@
 #include <assert.h>
 #include <gelf.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/src/arlib2.c b/src/arlib2.c
index 11f44e5d..9ae6662c 100644
--- a/src/arlib2.c
+++ b/src/arlib2.c
@@ -20,7 +20,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include <limits.h>
 #include <string.h>
 
diff --git a/src/elfcmp.c b/src/elfcmp.c
index 21d8d9dc..fba67e02 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -25,7 +25,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <locale.h>
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/elflint.c b/src/elflint.c
index b0e5415e..565cffdc 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -27,7 +27,6 @@
 #include <fcntl.h>
 #include <gelf.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdlib.h>
diff --git a/src/findtextrel.c b/src/findtextrel.c
index ecb1d118..d3021a3a 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -26,7 +26,6 @@
 #include <fcntl.h>
 #include <gelf.h>
 #include <libdw.h>
-#include <libintl.h>
 #include <locale.h>
 #include <search.h>
 #include <stdbool.h>
diff --git a/src/nm.c b/src/nm.c
index 16647589..b46c1fd7 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -30,7 +30,6 @@
 #include <gelf.h>
 #include <inttypes.h>
 #include <libdw.h>
-#include <libintl.h>
 #include <locale.h>
 #include <obstack.h>
 #include <search.h>
diff --git a/src/objdump.c b/src/objdump.c
index b32de17d..d43c1dd6 100644
--- a/src/objdump.c
+++ b/src/objdump.c
@@ -23,7 +23,6 @@
 #include <argp.h>
 #include <fcntl.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/ranlib.c b/src/ranlib.c
index bd7e1d8a..7838d69e 100644
--- a/src/ranlib.c
+++ b/src/ranlib.c
@@ -26,7 +26,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <gelf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <obstack.h>
 #include <stdlib.h>
diff --git a/src/readelf.c b/src/readelf.c
index 1a10fd01..a206e60e 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -30,7 +30,6 @@
 #include <langinfo.h>
 #include <libdw.h>
 #include <libdwfl.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdarg.h>
 #include <stdbool.h>
diff --git a/src/size.c b/src/size.c
index 8f203167..ff8ca075 100644
--- a/src/size.c
+++ b/src/size.c
@@ -25,7 +25,6 @@
 #include <gelf.h>
 #include <inttypes.h>
 #include <libelf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/strings.c b/src/strings.c
index 04aac3b6..55b047be 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -28,7 +28,6 @@
 #include <fcntl.h>
 #include <gelf.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/strip.c b/src/strip.c
index 452b1279..2a2cc801 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -28,7 +28,6 @@
 #include <fnmatch.h>
 #include <gelf.h>
 #include <libelf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/unstrip.c b/src/unstrip.c
index 3472637a..d5bd1821 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -33,7 +33,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h>
  2022-10-15 16:36 [PATCH v2 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
  2022-10-15 16:36 ` [PATCH v2 2/7] move platform depended include into system.h of libelf Yonggang Luo
  2022-10-15 16:36 ` [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h Yonggang Luo
@ 2022-10-15 16:36 ` Yonggang Luo
  2022-10-16 20:55   ` Mark Wielaard
  2 siblings, 1 reply; 7+ messages in thread
From: Yonggang Luo @ 2022-10-15 16:36 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

Add NOT_HAVE_LIBINTL macro to disable internationalization,
sometimes we have don't want access internationalization such as MSVC,
so the macro NOT_HAVE_LIBINTL can help that.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 lib/eu-config.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/eu-config.h b/lib/eu-config.h
index 78a5c4fe..5e6c3c72 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -52,10 +52,17 @@
 # define rwlock_unlock(lock) ((void) (lock))
 #endif	/* USE_LOCKS */
 
+#if !defined(NOT_HAVE_LIBINTL)
 #include <libintl.h>
+#endif
+
 /* gettext helper macros.  */
 #define N_(Str) Str
+#if !defined(NOT_HAVE_LIBINTL)
 #define _(Str) dgettext ("elfutils", Str)
+#else
+#define _(Str) N_(Str)
+#endif
 
 /* Compiler-specific definitions.  */
 #define strong_alias(name, aliasname) \
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/7] move platform depended include into system.h of libelf
  2022-10-15 16:36 ` [PATCH v2 2/7] move platform depended include into system.h of libelf Yonggang Luo
@ 2022-10-16 20:47   ` Mark Wielaard
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2022-10-16 20:47 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

On Sun, Oct 16, 2022 at 12:36:20AM +0800, Yonggang Luo via Elfutils-devel wrote:
> All of these files either #include <system.h> directly or #include "libelfP.h"
> And now "libelfP.h also #include <system.h>, so the platform depended include
> can be moved to system.h safely

Thanks. While reviewing wrote ChangeLog entries. Pushed with those added.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h
  2022-10-15 16:36 ` [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h Yonggang Luo
@ 2022-10-16 20:49   ` Mark Wielaard
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2022-10-16 20:49 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

On Sun, Oct 16, 2022 at 12:36:21AM +0800, Yonggang Luo via Elfutils-devel wrote:
> So we do not need include in each file.
> And indeed the macro
> #define _(Str) dgettext ("elfutils", Str)
> access libintl function dgettext, so it's make more sense
> #include <libintl.h> in file eu-config.h

And this works because we include eu-config.h in config.h.  All files
where libintl.h is removed includes config.h, except for libdwP.h and
libeblP.h, but it isn't expected there.

Pushed,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h>
  2022-10-15 16:36 ` [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h> Yonggang Luo
@ 2022-10-16 20:55   ` Mark Wielaard
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2022-10-16 20:55 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

Hi,

On Sun, Oct 16, 2022 at 12:36:22AM +0800, Yonggang Luo via Elfutils-devel wrote:
> Add NOT_HAVE_LIBINTL macro to disable internationalization,
> sometimes we have don't want access internationalization such as MSVC,
> so the macro NOT_HAVE_LIBINTL can help that.

This needs a configure check.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-16 20:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-15 16:36 [PATCH v2 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
2022-10-15 16:36 ` [PATCH v2 2/7] move platform depended include into system.h of libelf Yonggang Luo
2022-10-16 20:47   ` Mark Wielaard
2022-10-15 16:36 ` [PATCH v2 3/7] Move the #include <libintl.h> into eu-config.h Yonggang Luo
2022-10-16 20:49   ` Mark Wielaard
2022-10-15 16:36 ` [PATCH v2 4/7] lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h> Yonggang Luo
2022-10-16 20:55   ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).