Re: [libvirt] [PATCH] fix MinGW compilation(200808)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Atsushi SAKAI <sakaia@xxxxxxxxxxxxxx> wrote:

> Hi, Jim
>
>   Thsnk you for your reply.
>
> src/network_conf.c defines #include <arpa/inet.h>.
> The error message says the link does not exist.
> So I think it should add inet_pton.c to Makefile
...
>> > I try to compile libvirt on MinGW after some modification.
>> > The error message says follows.
>> > C:/msys/1.0/home/sakaia/work/libvirt/src/network_conf.c:290: undefined reference to `inet_pton'
>> > C:/msys/1.0/home/sakaia/work/libvirt/src/network_conf.c:296: undefined reference to `inet_pton'

Ahh.. those are _link_ errors.
That's due to a missing file: gnulib/m4/inet_pton.m4, and one
that I didn't update: gnulib/m4/gnulib-comp.m4

My smoke test configure/build worked fine because I ran
it on a Linux system, which doesn't need inet_pton.

Please try this patch:
(this gnulib-comp.m4 changes also reflects some
unrelated changes in gnulib -- FYI, I'm preparing another
gnulib-related patch that updates several files with bug-
and portability- fixes)

>From 335ac36a1e22da0922eb4abb7501c79bf418b8b0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 7 Aug 2008 09:56:38 +0200
Subject: [PATCH] complete the MinGW inet_pton portability fix

* gnulib/m4/inet_pton.m4: New file.  Required for MinGW.
* gnulib/m4/gnulib-comp.m4: Update.
---
 gnulib/m4/gnulib-comp.m4 |   62 +++++++++++++++++++++++++++++----------------
 gnulib/m4/inet_pton.m4   |   27 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 22 deletions(-)
 create mode 100644 gnulib/m4/inet_pton.m4

diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
index 6341bc2..239eb7a 100644
--- a/gnulib/m4/gnulib-comp.m4
+++ b/gnulib/m4/gnulib-comp.m4
@@ -39,6 +39,8 @@ AC_DEFUN([gl_INIT],
   m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
   m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
   m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
+  m4_pushdef([gl_LIBSOURCES_LIST], [])
+  m4_pushdef([gl_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='gnulib/lib'
   gl_EOVERFLOW
@@ -60,6 +62,8 @@ AC_DEFUN([gl_INIT],
   AC_SUBST([LTLIBINTL])
   gl_INET_NTOP
   gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
+  gl_INET_PTON
+  gl_ARPA_INET_MODULE_INDICATOR([inet_pton])
   gl_FUNC_LSEEK
   gl_UNISTD_MODULE_INDICATOR([lseek])
   gl_FUNC_MALLOC_POSIX
@@ -107,6 +111,19 @@ AC_DEFUN([gl_INIT],
      AM_XGETTEXT_OPTION([--flag=vasprintf:2:c-format])])
   gl_WCHAR_H
   gl_XSIZE
+  m4_ifval(gl_LIBSOURCES_LIST, [
+    m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
+      for gl_file in ]gl_LIBSOURCES_LIST[ ; do
+        if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then
+          echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2
+          exit 1
+        fi
+      done])dnl
+      m4_if(m4_sysval, [0], [],
+        [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
+  ])
+  m4_popdef([gl_LIBSOURCES_DIR])
+  m4_popdef([gl_LIBSOURCES_LIST])
   m4_popdef([AC_LIBSOURCES])
   m4_popdef([AC_REPLACE_FUNCS])
   m4_popdef([AC_LIBOBJ])
@@ -129,6 +146,8 @@ AC_DEFUN([gl_INIT],
   m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ]))
   m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS]))
   m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
+  m4_pushdef([gltests_LIBSOURCES_LIST], [])
+  m4_pushdef([gltests_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='gnulib/tests'
   gt_TYPE_WCHAR_T
@@ -136,6 +155,19 @@ AC_DEFUN([gl_INIT],
   AC_CHECK_FUNCS([shutdown])
   abs_aux_dir=`cd "$ac_aux_dir"; pwd`
   AC_SUBST([abs_aux_dir])
+  m4_ifval(gltests_LIBSOURCES_LIST, [
+    m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
+      for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
+        if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then
+          echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2
+          exit 1
+        fi
+      done])dnl
+      m4_if(m4_sysval, [0], [],
+        [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
+  ])
+  m4_popdef([gltests_LIBSOURCES_DIR])
+  m4_popdef([gltests_LIBSOURCES_LIST])
   m4_popdef([AC_LIBSOURCES])
   m4_popdef([AC_REPLACE_FUNCS])
   m4_popdef([AC_LIBOBJ])
@@ -164,13 +196,6 @@ AC_DEFUN([gl_LIBOBJ], [
   gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext"
 ])

-# m4_foreach_w is provided by autoconf-2.59c and later.
-# This definition is to accommodate developers using versions
-# of autoconf older than that.
-m4_ifndef([m4_foreach_w],
-  [m4_define([m4_foreach_w],
-    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
-
 # Like AC_REPLACE_FUNCS, except that the module name goes
 # into gl_LIBOBJS instead of into LIBOBJS.
 AC_DEFUN([gl_REPLACE_FUNCS], [
@@ -179,15 +204,14 @@ AC_DEFUN([gl_REPLACE_FUNCS], [
 ])

 # Like AC_LIBSOURCES, except the directory where the source file is
-# expected is derived from the gnulib-tool parametrization,
+# expected is derived from the gnulib-tool parameterization,
 # and alloca is special cased (for the alloca-opt module).
 # We could also entirely rely on EXTRA_lib..._SOURCES.
 AC_DEFUN([gl_LIBSOURCES], [
   m4_foreach([_gl_NAME], [$1], [
     m4_if(_gl_NAME, [alloca.c], [], [
-      m4_syscmd([test -r gnulib/lib/]_gl_NAME[ || test ! -d gnulib/lib])dnl
-      m4_if(m4_sysval, [0], [],
-        [AC_FATAL([missing gnulib/lib/]_gl_NAME)])
+      m4_define([gl_LIBSOURCES_DIR], [gnulib/lib])
+      m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ])
     ])
   ])
 ])
@@ -199,13 +223,6 @@ AC_DEFUN([gltests_LIBOBJ], [
   gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext"
 ])

-# m4_foreach_w is provided by autoconf-2.59c and later.
-# This definition is to accommodate developers using versions
-# of autoconf older than that.
-m4_ifndef([m4_foreach_w],
-  [m4_define([m4_foreach_w],
-    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
-
 # Like AC_REPLACE_FUNCS, except that the module name goes
 # into gltests_LIBOBJS instead of into LIBOBJS.
 AC_DEFUN([gltests_REPLACE_FUNCS], [
@@ -214,15 +231,14 @@ AC_DEFUN([gltests_REPLACE_FUNCS], [
 ])

 # Like AC_LIBSOURCES, except the directory where the source file is
-# expected is derived from the gnulib-tool parametrization,
+# expected is derived from the gnulib-tool parameterization,
 # and alloca is special cased (for the alloca-opt module).
 # We could also entirely rely on EXTRA_lib..._SOURCES.
 AC_DEFUN([gltests_LIBSOURCES], [
   m4_foreach([_gl_NAME], [$1], [
     m4_if(_gl_NAME, [alloca.c], [], [
-      m4_syscmd([test -r gnulib/tests/]_gl_NAME[ || test ! -d gnulib/tests])dnl
-      m4_if(m4_sysval, [0], [],
-        [AC_FATAL([missing gnulib/tests/]_gl_NAME)])
+      m4_define([gltests_LIBSOURCES_DIR], [gnulib/tests])
+      m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ])
     ])
   ])
 ])
@@ -253,6 +269,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/getpass.h
   lib/gettext.h
   lib/inet_ntop.c
+  lib/inet_pton.c
   lib/lseek.c
   lib/malloc.c
   lib/netinet_in.in.h
@@ -307,6 +324,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/iconv.m4
   m4/include_next.m4
   m4/inet_ntop.m4
+  m4/inet_pton.m4
   m4/intdiv0.m4
   m4/intl.m4
   m4/intldir.m4
diff --git a/gnulib/m4/inet_pton.m4 b/gnulib/m4/inet_pton.m4
new file mode 100644
index 0000000..a57e4c6
--- /dev/null
+++ b/gnulib/m4/inet_pton.m4
@@ -0,0 +1,27 @@
+# inet_pton.m4 serial 5
+dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_INET_PTON],
+[
+  dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+  ARPA_INET_H='arpa/inet.h'
+
+  AC_REPLACE_FUNCS(inet_pton)
+  gl_PREREQ_INET_PTON
+])
+
+# Prerequisites of lib/inet_pton.c.
+AC_DEFUN([gl_PREREQ_INET_PTON], [
+  AC_CHECK_DECLS([inet_pton],,,[#include <arpa/inet.h>])
+  if test $ac_cv_have_decl_inet_pton = no; then
+    HAVE_DECL_INET_PTON=0
+  fi
+  AC_REQUIRE([gl_SOCKET_FAMILIES])
+  AC_REQUIRE([AC_C_RESTRICT])
+])
--
1.6.0.rc1.92.g189f7

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]