[ovs-dev,ovn,1/4] configure: Improve checks for OVS source and build directories.
diff mbox series

Message ID 20190925163400.1171-1-blp@ovn.org
State New
Headers show
Series
  • [ovs-dev,ovn,1/4] configure: Improve checks for OVS source and build directories.
Related show

Commit Message

Ben Pfaff Sept. 25, 2019, 4:33 p.m. UTC
Until now, "configure" was willing to accept anything as the OVS source
and build directory, but obviously only an actual OVS source or build
directory will actually work.  This commit adds some basic checking.

In addition, this changes relative paths so that they are relative to
the current working directory when "configure" is invoked, instead of
relative to the location of the "configure" script.  This is less
surprising.

Finally, this moves the `eval echo "$dir"` lines up higher so that they
do their intended job of expanding ~ in the right place.  That has to
happen early, otherwise, ~/foo will effectively end up as $PWD/\~/foo.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 acinclude.m4 | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

Comments

Numan Siddique Sept. 26, 2019, 6:37 a.m. UTC | #1
On Thu, Sep 26, 2019 at 12:04 AM Ben Pfaff <blp@ovn.org> wrote:

> Until now, "configure" was willing to accept anything as the OVS source
> and build directory, but obviously only an actual OVS source or build
> directory will actually work.  This commit adds some basic checking.
>
> In addition, this changes relative paths so that they are relative to
> the current working directory when "configure" is invoked, instead of
> relative to the location of the "configure" script.  This is less
> surprising.
>
> Finally, this moves the `eval echo "$dir"` lines up higher so that they
> do their intended job of expanding ~ in the right place.  That has to
> happen early, otherwise, ~/foo will effectively end up as $PWD/\~/foo.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
>

Please consider this Ack for the whole series.

Acked-by: Numan Siddique <nusiddiq@redhat.com>

Numan


> ---
>  acinclude.m4 | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/acinclude.m4 b/acinclude.m4
> index 31e4f0b5413f..9dfed9034910 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -1220,32 +1220,37 @@ AC_DEFUN([OVN_CHECK_OVS], [
>
>    AC_MSG_CHECKING([for OVS source directory])
>    if test X"$with_ovs_source" != X; then
> -    OVSDIR=$with_ovs_source
> +    OVSDIR=`eval echo "$with_ovs_source"`
>      case $OVSDIR in
>        /*) ;;
> -      *) OVSDIR=$ac_abs_confdir/$OVSDIR ;;
> +      *) OVSDIR=`pwd`/$OVSDIR ;;
>      esac
> +    if test ! -f "$OVSDIR/vswitchd/bridge.c"; then
> +      AC_ERROR([$OVSDIR is not an OVS source directory])
> +    fi
>    else
> -    AC_ERROR([OVS source dir path needs to be specified])
> +    AC_ERROR([OVS source dir path needs to be specified (use
> --with-ovs-source)])
>    fi
>
> -  OVSDIR=`eval echo "$OVSDIR"`
>    AC_MSG_RESULT([$OVSDIR])
>    AC_SUBST(OVSDIR)
>
>    AC_MSG_CHECKING([for OVS build directory])
>    if test X"$with_ovs_build" != X; then
> -    OVSBUILDDIR=$with_ovs_build
> +    OVSBUILDDIR=`eval echo "$with_ovs_build"`
>      case $OVSBUILDDIR in
>        /*) ;;
> -      *) OVSBUILDDIR=$ac_abs_confdir/$OVSBUILDDIR ;;
> +      *) OVSBUILDDIR=`pwd`/$OVSBUILDDIR ;;
>      esac
> -  else
> +    if test ! -f "$OVSBUILDDIR/config.h"; then
> +      AC_ERROR([$OVSBUILDDIR is not a configured OVS build directory])
> +    fi
> +  elif test -f "$OVSDIR/config.h"; then
>      # If separate build dir is not specified, use src dir.
>      OVSBUILDDIR=$OVSDIR
> +  else
> +    AC_ERROR([OVS source dir $OVSDIR is not configured as a build
> directory (either run configure there or use --with-ovs-build to point to
> the build directory)])
>    fi
> -
> -  OVSBUILDDIR=`eval echo "$OVSBUILDDIR"`
>    AC_MSG_RESULT([$OVSBUILDDIR])
>    AC_SUBST(OVSBUILDDIR)
>  ])
> --
> 2.21.0
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Ben Pfaff Sept. 26, 2019, 3:50 p.m. UTC | #2
On Thu, Sep 26, 2019 at 12:07:52PM +0530, Numan Siddique wrote:
> On Thu, Sep 26, 2019 at 12:04 AM Ben Pfaff <blp@ovn.org> wrote:
> 
> > Until now, "configure" was willing to accept anything as the OVS source
> > and build directory, but obviously only an actual OVS source or build
> > directory will actually work.  This commit adds some basic checking.
> >
> > In addition, this changes relative paths so that they are relative to
> > the current working directory when "configure" is invoked, instead of
> > relative to the location of the "configure" script.  This is less
> > surprising.
> >
> > Finally, this moves the `eval echo "$dir"` lines up higher so that they
> > do their intended job of expanding ~ in the right place.  That has to
> > happen early, otherwise, ~/foo will effectively end up as $PWD/\~/foo.
> >
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> >
> 
> Please consider this Ack for the whole series.
> 
> Acked-by: Numan Siddique <nusiddiq@redhat.com>

Thanks!  I applied this to master.

Patch
diff mbox series

diff --git a/acinclude.m4 b/acinclude.m4
index 31e4f0b5413f..9dfed9034910 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1220,32 +1220,37 @@  AC_DEFUN([OVN_CHECK_OVS], [
 
   AC_MSG_CHECKING([for OVS source directory])
   if test X"$with_ovs_source" != X; then
-    OVSDIR=$with_ovs_source
+    OVSDIR=`eval echo "$with_ovs_source"`
     case $OVSDIR in
       /*) ;;
-      *) OVSDIR=$ac_abs_confdir/$OVSDIR ;;
+      *) OVSDIR=`pwd`/$OVSDIR ;;
     esac
+    if test ! -f "$OVSDIR/vswitchd/bridge.c"; then
+      AC_ERROR([$OVSDIR is not an OVS source directory])
+    fi
   else
-    AC_ERROR([OVS source dir path needs to be specified])
+    AC_ERROR([OVS source dir path needs to be specified (use --with-ovs-source)])
   fi
 
-  OVSDIR=`eval echo "$OVSDIR"`
   AC_MSG_RESULT([$OVSDIR])
   AC_SUBST(OVSDIR)
 
   AC_MSG_CHECKING([for OVS build directory])
   if test X"$with_ovs_build" != X; then
-    OVSBUILDDIR=$with_ovs_build
+    OVSBUILDDIR=`eval echo "$with_ovs_build"`
     case $OVSBUILDDIR in
       /*) ;;
-      *) OVSBUILDDIR=$ac_abs_confdir/$OVSBUILDDIR ;;
+      *) OVSBUILDDIR=`pwd`/$OVSBUILDDIR ;;
     esac
-  else
+    if test ! -f "$OVSBUILDDIR/config.h"; then
+      AC_ERROR([$OVSBUILDDIR is not a configured OVS build directory])
+    fi
+  elif test -f "$OVSDIR/config.h"; then
     # If separate build dir is not specified, use src dir.
     OVSBUILDDIR=$OVSDIR
+  else
+    AC_ERROR([OVS source dir $OVSDIR is not configured as a build directory (either run configure there or use --with-ovs-build to point to the build directory)])
   fi
-
-  OVSBUILDDIR=`eval echo "$OVSBUILDDIR"`
   AC_MSG_RESULT([$OVSBUILDDIR])
   AC_SUBST(OVSBUILDDIR)
 ])