Обсуждение: Support building in a different directory on Solaris

Поиск
Список
Период
Сортировка

Support building in a different directory on Solaris

От
Ian Lance Taylor
Дата:
I routinely build tools in a directory other than the source
directory.  This works in 7.1 on Linux and probably many other
systems, but it doesn't work on Solaris.  There are two problems.  The
first is the test built in to /bin/sh does not support -ef, although
/usr/bin/test does support it.  The second is that /bin/find requires
an explicit -print when -o is used.

Here are a couple of patches to fix these problems.  I've tested these
patches on Linux as well.  They should work on all systems.

I did not include a patch to rebuild configure itself.  You must run
autoconf after applying these patches.

Ian

Index: configure.in
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/configure.in,v
retrieving revision 1.132
diff -u -r1.132 configure.in
--- configure.in    2001/08/01 23:52:50    1.132
+++ configure.in    2001/08/10 20:37:16
@@ -1178,6 +1178,10 @@
 # check whether 'test -ef' works
 if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
   test_ef_works=yes
+  ef_test=test
+elif (/usr/bin/test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
+  test_ef_works=yes
+  ef_test=/usr/bin/test
 else
   test_ef_works=no
 fi
@@ -1187,7 +1191,7 @@

 if test "$test_ef_works" = yes ; then
 # prepare build tree if outside source tree
-  if test "$srcdir" -ef . ; then : ; else
+  if $ef_test "$srcdir" -ef . ; then : ; else
     abs_top_srcdir=`cd $srcdir && pwd`
     echo $ac_n "preparing build tree... $ac_c" 1>&6
     /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
Index: config/prep_buildtree
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/config/prep_buildtree,v
retrieving revision 1.3
diff -u -r1.3 prep_buildtree
--- config/prep_buildtree    2001/03/03 15:53:41    1.3
+++ config/prep_buildtree    2001/08/10 20:38:38
@@ -29,7 +29,7 @@
     fi
 done

-for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
+for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
     subdir=`expr "$item" : "$sourcetree\(.*\)"`
     if test ! -f "${item}.in"; then
         ln -fs "$item" "$buildtree/$subdir" || exit 1

Re: Support building in a different directory on Solaris

От
Tom Lane
Дата:
Ian Lance Taylor <ian@airs.com> writes:
> the test built in to /bin/sh does not support -ef, although
> /usr/bin/test does support it.

Rather than assuming a test with -ef is available, ISTM the portable
answer is not to depend on it at all.  Why not forget the whole thing
and use something like

  if [ `cd "$srcdir" ; /bin/pwd` = `/bin/pwd` ] ; then : ; else

> The second is that /bin/find requires
> an explicit -print when -o is used.

This is a good change.  A lot of older "find"s don't provide a default
-print action at all (-o or no -o), so writing -print is the portable
way to use it.  I don't think you need two of them though.

            regards, tom lane

Re: Support building in a different directory on Solaris

От
Ian Lance Taylor
Дата:
Tom Lane <tgl@sss.pgh.pa.us> writes:

> > The second is that /bin/find requires
> > an explicit -print when -o is used.
>
> This is a good change.  A lot of older "find"s don't provide a default
> -print action at all (-o or no -o), so writing -print is the portable
> way to use it.  I don't think you need two of them though.

Actually, you do, because of the -o.  The -print is an action which is
applied to files which match up to that point.  Actions are not
carried across -o, and actions found after a -o are not applied to
files matched before the -o.

If you have access to a Solaris system, try it.

Ian

Re: Support building in a different directory on Solaris

От
Tom Lane
Дата:
Ian Lance Taylor <ian@airs.com> writes:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>> I don't think you need two of them though.

> Actually, you do, because of the -o.

You're right of course --- never mind ...

            regards, tom lane

Re: Support building in a different directory on Solaris

От
Peter Eisentraut
Дата:
Tom Lane writes:

> Ian Lance Taylor <ian@airs.com> writes:
> > the test built in to /bin/sh does not support -ef, although
> > /usr/bin/test does support it.
>
> Rather than assuming a test with -ef is available, ISTM the portable
> answer is not to depend on it at all.  Why not forget the whole thing
> and use something like
>
>   if [ `cd "$srcdir" ; /bin/pwd` = `/bin/pwd` ] ; then : ; else

That doesn't work in some setups; that's why we have what we have now.
The problem is that this test would actually evaluate to "not equal" and
the prep_buildtree would run on top of the source tree.  Ugh.

Another way to find out if you're in the source tree might be to use
something like

    test -f configure

but that's of course less than 100% positive.  Ian, you seem to use this a
lot; any ideas?

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


Re: Support building in a different directory on Solaris

От
Ian Lance Taylor
Дата:
Peter Eisentraut <peter_e@gmx.net> writes:

> Tom Lane writes:
>
> > Ian Lance Taylor <ian@airs.com> writes:
> > > the test built in to /bin/sh does not support -ef, although
> > > /usr/bin/test does support it.
> >
> > Rather than assuming a test with -ef is available, ISTM the portable
> > answer is not to depend on it at all.  Why not forget the whole thing
> > and use something like
> >
> >   if [ `cd "$srcdir" ; /bin/pwd` = `/bin/pwd` ] ; then : ; else
>
> That doesn't work in some setups; that's why we have what we have now.
> The problem is that this test would actually evaluate to "not equal" and
> the prep_buildtree would run on top of the source tree.  Ugh.
>
> Another way to find out if you're in the source tree might be to use
> something like
>
>     test -f configure
>
> but that's of course less than 100% positive.  Ian, you seem to use this a
> lot; any ideas?

I normally use the full-fledged autoconf approach, in which you have a
Makefile.in in each source directory, and you list them all in
AC_OUTPUT.  Then configure will build the directory tree for you, and
you don't need prep_buildtree.

You're trying to avoid running prep_buildtree when the build is done
in the source directory.  One thing to do would be to make
prep_buildtree harmless when it is run in the source directory, and
switch to the test Tom suggests.  Tom's test will work in most cases,
so this will only be inefficient in the relatively unusual cases where
it does not work.

For example, perhaps something this would work, although I haven't
tested it:

     if test ! -f "${item}.in"; then
-        ln -fs "$item" "$buildtree/$subdir" || exit 1
+        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
+            ln -fs "$item" "$buildtree/$subdir" || exit 1
+        fi

Ian

Re: Support building in a different directory on Solaris

От
Tom Lane
Дата:
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> if [ `cd "$srcdir" ; /bin/pwd` = `/bin/pwd` ] ; then : ; else

> That doesn't work in some setups; that's why we have what we have now.
> The problem is that this test would actually evaluate to "not equal" and
> the prep_buildtree would run on top of the source tree.  Ugh.

Hmm.  Well, there's always the direct-experiment approach to finding out
whether two directories are the same.  How about some variant of

    touch ./funkyFileName
    if [ -f "$srcdir/funkyFileName" ]
        -- $srcdir is .
    else
        -- $srcdir is not .
    fi
    rm ./funkyFileName

            regards, tom lane

Re: Support building in a different directory on Solaris

От
Bruce Momjian
Дата:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> I routinely build tools in a directory other than the source
> directory.  This works in 7.1 on Linux and probably many other
> systems, but it doesn't work on Solaris.  There are two problems.  The
> first is the test built in to /bin/sh does not support -ef, although
> /usr/bin/test does support it.  The second is that /bin/find requires
> an explicit -print when -o is used.
>
> Here are a couple of patches to fix these problems.  I've tested these
> patches on Linux as well.  They should work on all systems.
>
> I did not include a patch to rebuild configure itself.  You must run
> autoconf after applying these patches.
>
> Ian
>
> Index: configure.in
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/configure.in,v
> retrieving revision 1.132
> diff -u -r1.132 configure.in
> --- configure.in    2001/08/01 23:52:50    1.132
> +++ configure.in    2001/08/10 20:37:16
> @@ -1178,6 +1178,10 @@
>  # check whether 'test -ef' works
>  if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
>    test_ef_works=yes
> +  ef_test=test
> +elif (/usr/bin/test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
> +  test_ef_works=yes
> +  ef_test=/usr/bin/test
>  else
>    test_ef_works=no
>  fi
> @@ -1187,7 +1191,7 @@
>
>  if test "$test_ef_works" = yes ; then
>  # prepare build tree if outside source tree
> -  if test "$srcdir" -ef . ; then : ; else
> +  if $ef_test "$srcdir" -ef . ; then : ; else
>      abs_top_srcdir=`cd $srcdir && pwd`
>      echo $ac_n "preparing build tree... $ac_c" 1>&6
>      /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> Index: config/prep_buildtree
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/config/prep_buildtree,v
> retrieving revision 1.3
> diff -u -r1.3 prep_buildtree
> --- config/prep_buildtree    2001/03/03 15:53:41    1.3
> +++ config/prep_buildtree    2001/08/10 20:38:38
> @@ -29,7 +29,7 @@
>      fi
>  done
>
> -for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
> +for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
>      subdir=`expr "$item" : "$sourcetree\(.*\)"`
>      if test ! -f "${item}.in"; then
>          ln -fs "$item" "$buildtree/$subdir" || exit 1
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Support building in a different directory on Solaris

От
Ian Lance Taylor
Дата:
Bruce Momjian <pgman@candle.pha.pa.us> writes:

> Your patch has been added to the PostgreSQL unapplied patches list at:
>
>     http://candle.pha.pa.us/cgi-bin/pgpatches
>
> I will try to apply it within the next 48 hours.

Thanks.  There was some discussion of a slightly different patch to
address this by removing the requirement for test -ef.  I've appended
a patch for that; it has not been tested as well as my previous patch.
I'm agnostic as to which one is used.

Ian

Index: configure.in
===================================================================
RCS file: /projects/cvsroot/pgsql/configure.in,v
retrieving revision 1.136
diff -u -r1.136 configure.in
--- configure.in    2001/09/06 03:23:38    1.136
+++ configure.in    2001/09/07 04:58:47
@@ -1216,25 +1216,18 @@
   AC_CHECK_PROGS(SGMLSPL, sgmlspl)
 fi

-# check whether 'test -ef' works
-if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
-  test_ef_works=yes
-else
-  test_ef_works=no
-fi
-
 abs_top_srcdir=
 AC_SUBST(abs_top_srcdir)

-if test "$test_ef_works" = yes ; then
 # prepare build tree if outside source tree
-  if test "$srcdir" -ef . ; then : ; else
-    abs_top_srcdir=`cd $srcdir && pwd`
-    echo $ac_n "preparing build tree... $ac_c" 1>&6
-    /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
-      || AC_MSG_ERROR(failed)
-    AC_MSG_RESULT(done)
-  fi
+if test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
+  :
+else
+  abs_top_srcdir=`cd $srcdir && pwd`
+  echo $ac_n "preparing build tree... $ac_c" 1>&6
+  /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
+    || AC_MSG_ERROR(failed)
+  AC_MSG_RESULT(done)
 fi

 AC_OUTPUT(
Index: prep_buildtree
===================================================================
RCS file: /projects/cvsroot/pgsql/config/prep_buildtree,v
retrieving revision 1.3
diff -u -r1.3 prep_buildtree
--- prep_buildtree    2001/03/03 15:53:41    1.3
+++ prep_buildtree    2001/09/07 04:59:01
@@ -29,10 +29,12 @@
     fi
 done

-for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
+for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
     subdir=`expr "$item" : "$sourcetree\(.*\)"`
     if test ! -f "${item}.in"; then
-        ln -fs "$item" "$buildtree/$subdir" || exit 1
+        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
+            ln -fs "$item" "$buildtree/$subdir" || exit 1
+        fi
     fi
 done


Re: Support building in a different directory on Solaris

От
Bruce Momjian
Дата:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>
> > Your patch has been added to the PostgreSQL unapplied patches list at:
> >
> >     http://candle.pha.pa.us/cgi-bin/pgpatches
> >
> > I will try to apply it within the next 48 hours.
>
> Thanks.  There was some discussion of a slightly different patch to
> address this by removing the requirement for test -ef.  I've appended
> a patch for that; it has not been tested as well as my previous patch.
> I'm agnostic as to which one is used.
>
> Ian
>
> Index: configure.in
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/configure.in,v
> retrieving revision 1.136
> diff -u -r1.136 configure.in
> --- configure.in    2001/09/06 03:23:38    1.136
> +++ configure.in    2001/09/07 04:58:47
> @@ -1216,25 +1216,18 @@
>    AC_CHECK_PROGS(SGMLSPL, sgmlspl)
>  fi
>
> -# check whether 'test -ef' works
> -if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
> -  test_ef_works=yes
> -else
> -  test_ef_works=no
> -fi
> -
>  abs_top_srcdir=
>  AC_SUBST(abs_top_srcdir)
>
> -if test "$test_ef_works" = yes ; then
>  # prepare build tree if outside source tree
> -  if test "$srcdir" -ef . ; then : ; else
> -    abs_top_srcdir=`cd $srcdir && pwd`
> -    echo $ac_n "preparing build tree... $ac_c" 1>&6
> -    /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> -      || AC_MSG_ERROR(failed)
> -    AC_MSG_RESULT(done)
> -  fi
> +if test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
> +  :
> +else
> +  abs_top_srcdir=`cd $srcdir && pwd`
> +  echo $ac_n "preparing build tree... $ac_c" 1>&6
> +  /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> +    || AC_MSG_ERROR(failed)
> +  AC_MSG_RESULT(done)
>  fi
>
>  AC_OUTPUT(
> Index: prep_buildtree
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/config/prep_buildtree,v
> retrieving revision 1.3
> diff -u -r1.3 prep_buildtree
> --- prep_buildtree    2001/03/03 15:53:41    1.3
> +++ prep_buildtree    2001/09/07 04:59:01
> @@ -29,10 +29,12 @@
>      fi
>  done
>
> -for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
> +for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
>      subdir=`expr "$item" : "$sourcetree\(.*\)"`
>      if test ! -f "${item}.in"; then
> -        ln -fs "$item" "$buildtree/$subdir" || exit 1
> +        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
> +            ln -fs "$item" "$buildtree/$subdir" || exit 1
> +        fi
>      fi
>  done
>
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Support building in a different directory on Solaris

От
Peter Eisentraut
Дата:
Bruce Momjian writes:

> Your patch has been added to the PostgreSQL unapplied patches list at:
>
>     http://candle.pha.pa.us/cgi-bin/pgpatches
>
> I will try to apply it within the next 48 hours.

No way.  We should not run prep_buildtree on top of the source tree.
There were a number of better solutions proposed.

> > Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >
> > > Your patch has been added to the PostgreSQL unapplied patches list at:
> > >
> > >     http://candle.pha.pa.us/cgi-bin/pgpatches
> > >
> > > I will try to apply it within the next 48 hours.
> >
> > Thanks.  There was some discussion of a slightly different patch to
> > address this by removing the requirement for test -ef.  I've appended
> > a patch for that; it has not been tested as well as my previous patch.
> > I'm agnostic as to which one is used.
> >
> > Ian
> >
> > Index: configure.in
> > ===================================================================
> > RCS file: /projects/cvsroot/pgsql/configure.in,v
> > retrieving revision 1.136
> > diff -u -r1.136 configure.in
> > --- configure.in    2001/09/06 03:23:38    1.136
> > +++ configure.in    2001/09/07 04:58:47
> > @@ -1216,25 +1216,18 @@
> >    AC_CHECK_PROGS(SGMLSPL, sgmlspl)
> >  fi
> >
> > -# check whether 'test -ef' works
> > -if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
> > -  test_ef_works=yes
> > -else
> > -  test_ef_works=no
> > -fi
> > -
> >  abs_top_srcdir=
> >  AC_SUBST(abs_top_srcdir)
> >
> > -if test "$test_ef_works" = yes ; then
> >  # prepare build tree if outside source tree
> > -  if test "$srcdir" -ef . ; then : ; else
> > -    abs_top_srcdir=`cd $srcdir && pwd`
> > -    echo $ac_n "preparing build tree... $ac_c" 1>&6
> > -    /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> > -      || AC_MSG_ERROR(failed)
> > -    AC_MSG_RESULT(done)
> > -  fi
> > +if test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
> > +  :
> > +else
> > +  abs_top_srcdir=`cd $srcdir && pwd`
> > +  echo $ac_n "preparing build tree... $ac_c" 1>&6
> > +  /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> > +    || AC_MSG_ERROR(failed)
> > +  AC_MSG_RESULT(done)
> >  fi
> >
> >  AC_OUTPUT(
> > Index: prep_buildtree
> > ===================================================================
> > RCS file: /projects/cvsroot/pgsql/config/prep_buildtree,v
> > retrieving revision 1.3
> > diff -u -r1.3 prep_buildtree
> > --- prep_buildtree    2001/03/03 15:53:41    1.3
> > +++ prep_buildtree    2001/09/07 04:59:01
> > @@ -29,10 +29,12 @@
> >      fi
> >  done
> >
> > -for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
> > +for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
> >      subdir=`expr "$item" : "$sourcetree\(.*\)"`
> >      if test ! -f "${item}.in"; then
> > -        ln -fs "$item" "$buildtree/$subdir" || exit 1
> > +        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
> > +            ln -fs "$item" "$buildtree/$subdir" || exit 1
> > +        fi
> >      fi
> >  done
> >
> >
>
>

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



Re: Support building in a different directory on Solaris

От
Bruce Momjian
Дата:
Patch removed per request from Peter E.

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>
> > Your patch has been added to the PostgreSQL unapplied patches list at:
> >
> >     http://candle.pha.pa.us/cgi-bin/pgpatches
> >
> > I will try to apply it within the next 48 hours.
>
> Thanks.  There was some discussion of a slightly different patch to
> address this by removing the requirement for test -ef.  I've appended
> a patch for that; it has not been tested as well as my previous patch.
> I'm agnostic as to which one is used.
>
> Ian
>
> Index: configure.in
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/configure.in,v
> retrieving revision 1.136
> diff -u -r1.136 configure.in
> --- configure.in    2001/09/06 03:23:38    1.136
> +++ configure.in    2001/09/07 04:58:47
> @@ -1216,25 +1216,18 @@
>    AC_CHECK_PROGS(SGMLSPL, sgmlspl)
>  fi
>
> -# check whether 'test -ef' works
> -if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
> -  test_ef_works=yes
> -else
> -  test_ef_works=no
> -fi
> -
>  abs_top_srcdir=
>  AC_SUBST(abs_top_srcdir)
>
> -if test "$test_ef_works" = yes ; then
>  # prepare build tree if outside source tree
> -  if test "$srcdir" -ef . ; then : ; else
> -    abs_top_srcdir=`cd $srcdir && pwd`
> -    echo $ac_n "preparing build tree... $ac_c" 1>&6
> -    /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> -      || AC_MSG_ERROR(failed)
> -    AC_MSG_RESULT(done)
> -  fi
> +if test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
> +  :
> +else
> +  abs_top_srcdir=`cd $srcdir && pwd`
> +  echo $ac_n "preparing build tree... $ac_c" 1>&6
> +  /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> +    || AC_MSG_ERROR(failed)
> +  AC_MSG_RESULT(done)
>  fi
>
>  AC_OUTPUT(
> Index: prep_buildtree
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/config/prep_buildtree,v
> retrieving revision 1.3
> diff -u -r1.3 prep_buildtree
> --- prep_buildtree    2001/03/03 15:53:41    1.3
> +++ prep_buildtree    2001/09/07 04:59:01
> @@ -29,10 +29,12 @@
>      fi
>  done
>
> -for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
> +for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
>      subdir=`expr "$item" : "$sourcetree\(.*\)"`
>      if test ! -f "${item}.in"; then
> -        ln -fs "$item" "$buildtree/$subdir" || exit 1
> +        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
> +            ln -fs "$item" "$buildtree/$subdir" || exit 1
> +        fi
>      fi
>  done
>
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Support building in a different directory on Solaris

От
Ian Lance Taylor
Дата:
Bruce Momjian <pgman@candle.pha.pa.us> writes:

> Patch removed per request from Peter E.

OK, then, I recommend you apply my earlier patch, subject to Peter E's
approval.

Ian

> > Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >
> > > Your patch has been added to the PostgreSQL unapplied patches list at:
> > >
> > >     http://candle.pha.pa.us/cgi-bin/pgpatches
> > >
> > > I will try to apply it within the next 48 hours.
> >
> > Thanks.  There was some discussion of a slightly different patch to
> > address this by removing the requirement for test -ef.  I've appended
> > a patch for that; it has not been tested as well as my previous patch.
> > I'm agnostic as to which one is used.
> >
> > Ian
> >
> > Index: configure.in
> > ===================================================================
> > RCS file: /projects/cvsroot/pgsql/configure.in,v
> > retrieving revision 1.136
> > diff -u -r1.136 configure.in
> > --- configure.in    2001/09/06 03:23:38    1.136
> > +++ configure.in    2001/09/07 04:58:47
> > @@ -1216,25 +1216,18 @@
> >    AC_CHECK_PROGS(SGMLSPL, sgmlspl)
> >  fi
> >
> > -# check whether 'test -ef' works
> > -if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
> > -  test_ef_works=yes
> > -else
> > -  test_ef_works=no
> > -fi
> > -
> >  abs_top_srcdir=
> >  AC_SUBST(abs_top_srcdir)
> >
> > -if test "$test_ef_works" = yes ; then
> >  # prepare build tree if outside source tree
> > -  if test "$srcdir" -ef . ; then : ; else
> > -    abs_top_srcdir=`cd $srcdir && pwd`
> > -    echo $ac_n "preparing build tree... $ac_c" 1>&6
> > -    /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> > -      || AC_MSG_ERROR(failed)
> > -    AC_MSG_RESULT(done)
> > -  fi
> > +if test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
> > +  :
> > +else
> > +  abs_top_srcdir=`cd $srcdir && pwd`
> > +  echo $ac_n "preparing build tree... $ac_c" 1>&6
> > +  /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> > +    || AC_MSG_ERROR(failed)
> > +  AC_MSG_RESULT(done)
> >  fi
> >
> >  AC_OUTPUT(
> > Index: prep_buildtree
> > ===================================================================
> > RCS file: /projects/cvsroot/pgsql/config/prep_buildtree,v
> > retrieving revision 1.3
> > diff -u -r1.3 prep_buildtree
> > --- prep_buildtree    2001/03/03 15:53:41    1.3
> > +++ prep_buildtree    2001/09/07 04:59:01
> > @@ -29,10 +29,12 @@
> >      fi
> >  done
> >
> > -for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
> > +for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
> >      subdir=`expr "$item" : "$sourcetree\(.*\)"`
> >      if test ! -f "${item}.in"; then
> > -        ln -fs "$item" "$buildtree/$subdir" || exit 1
> > +        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
> > +            ln -fs "$item" "$buildtree/$subdir" || exit 1
> > +        fi
> >      fi
> >  done
> >
> >
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Support building in a different directory on Solaris

От
Ian Lance Taylor
Дата:
Peter Eisentraut <peter_e@gmx.net> writes:

> Bruce Momjian writes:
>
> > Your patch has been added to the PostgreSQL unapplied patches list at:
> >
> >     http://candle.pha.pa.us/cgi-bin/pgpatches
> >
> > I will try to apply it within the next 48 hours.
>
> No way.  We should not run prep_buildtree on top of the source tree.
> There were a number of better solutions proposed.

Note that this patch normally will not run prep_buildtree on top of
the source tree.  That would only happen in exceptional circumstances
in which /bin/pwd did not return the same string in the same
directory.  I wrote the patch to address Tom Lane's suggestion of not
requiring test to support the relatively new -ef option.

But, as I said, I don't really care which patch is used.

Ian

> > > Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > >
> > > > Your patch has been added to the PostgreSQL unapplied patches list at:
> > > >
> > > >     http://candle.pha.pa.us/cgi-bin/pgpatches
> > > >
> > > > I will try to apply it within the next 48 hours.
> > >
> > > Thanks.  There was some discussion of a slightly different patch to
> > > address this by removing the requirement for test -ef.  I've appended
> > > a patch for that; it has not been tested as well as my previous patch.
> > > I'm agnostic as to which one is used.
> > >
> > > Ian
> > >
> > > Index: configure.in
> > > ===================================================================
> > > RCS file: /projects/cvsroot/pgsql/configure.in,v
> > > retrieving revision 1.136
> > > diff -u -r1.136 configure.in
> > > --- configure.in    2001/09/06 03:23:38    1.136
> > > +++ configure.in    2001/09/07 04:58:47
> > > @@ -1216,25 +1216,18 @@
> > >    AC_CHECK_PROGS(SGMLSPL, sgmlspl)
> > >  fi
> > >
> > > -# check whether 'test -ef' works
> > > -if (test "$srcdir" -ef "$srcdir") >/dev/null 2>&1 ; then
> > > -  test_ef_works=yes
> > > -else
> > > -  test_ef_works=no
> > > -fi
> > > -
> > >  abs_top_srcdir=
> > >  AC_SUBST(abs_top_srcdir)
> > >
> > > -if test "$test_ef_works" = yes ; then
> > >  # prepare build tree if outside source tree
> > > -  if test "$srcdir" -ef . ; then : ; else
> > > -    abs_top_srcdir=`cd $srcdir && pwd`
> > > -    echo $ac_n "preparing build tree... $ac_c" 1>&6
> > > -    /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> > > -      || AC_MSG_ERROR(failed)
> > > -    AC_MSG_RESULT(done)
> > > -  fi
> > > +if test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
> > > +  :
> > > +else
> > > +  abs_top_srcdir=`cd $srcdir && pwd`
> > > +  echo $ac_n "preparing build tree... $ac_c" 1>&6
> > > +  /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
> > > +    || AC_MSG_ERROR(failed)
> > > +  AC_MSG_RESULT(done)
> > >  fi
> > >
> > >  AC_OUTPUT(
> > > Index: prep_buildtree
> > > ===================================================================
> > > RCS file: /projects/cvsroot/pgsql/config/prep_buildtree,v
> > > retrieving revision 1.3
> > > diff -u -r1.3 prep_buildtree
> > > --- prep_buildtree    2001/03/03 15:53:41    1.3
> > > +++ prep_buildtree    2001/09/07 04:59:01
> > > @@ -29,10 +29,12 @@
> > >      fi
> > >  done
> > >
> > > -for item in `find "$sourcetree" -name Makefile -o -name GNUmakefile`; do
> > > +for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
> > >      subdir=`expr "$item" : "$sourcetree\(.*\)"`
> > >      if test ! -f "${item}.in"; then
> > > -        ln -fs "$item" "$buildtree/$subdir" || exit 1
> > > +        if cmp "$item" "$buildtree/subdir" >/dev/null 2>&1; then : ; else
> > > +            ln -fs "$item" "$buildtree/$subdir" || exit 1
> > > +        fi
> > >      fi
> > >  done
> > >
> > >
> >
> >
>
> --
> Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter

Re: Support building in a different directory on Solaris

От
Peter Eisentraut
Дата:
Ian Lance Taylor writes:

> But, as I said, I don't really care which patch is used.

I'll make sure something is done about this.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


Re: Support building in a different directory on Solaris

От
Peter Eisentraut
Дата:
Ian Lance Taylor writes:

> Note that this patch normally will not run prep_buildtree on top of
> the source tree.  That would only happen in exceptional circumstances
> in which /bin/pwd did not return the same string in the same
> directory.  I wrote the patch to address Tom Lane's suggestion of not
> requiring test to support the relatively new -ef option.

I've thought hard about this and the solution that satisfied me most was
that

    test $srcdir -ef . || test `cd $srcdir && /bin/pwd` = `/bin/pwd`

(properly quoted etc.) means srcdir == builddir.  That means on Solaris
you will invoke the second part, as you suggested in your patch, whereas
if test -ef works you'll get the safer alternative.

I've also installed your prep_buildtree patch to be on the safe side.

One of my concerns is that prep_buildtree isn't super-portable by design
(using 'find'), but we'll just have to cross our fingers that nobody
exercises all these unlikely cases.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter