Margaret Lewicka
2015-Feb-12 17:49 UTC
[Libguestfs] [PATCH] macosx: Darwin-specific autoconf macros
* Replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH for Darwin * Remove the -lcrypt flag for Darwin (unsupported) --- configure.ac | 13 +++++++++++++ run.in | 10 +++++----- v2v/link.sh.in | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index d68190a..295de11 100644 --- a/configure.ac +++ b/configure.ac @@ -582,6 +582,19 @@ fi AC_MSG_RESULT([$DISTRO]) AC_SUBST([DISTRO]) +AC_MSG_CHECKING([whether we're building on Mac OS X]) +if test "x$(uname)" = "xDarwin"; then + AC_MSG_RESULT([yes]) + LCRYPT_FLAG+ SHARED_LIBS_PATH="DYLD_LIBRARY_PATH" +else + AC_MSG_RESULT([no]) + LCRYPT_FLAG="-lcrypt" + SHARED_LIBS_PATH="LD_LIBRARY_PATH" +fi +AC_SUBST([LCRYPT_FLAG]) +AC_SUBST([SHARED_LIBS_PATH]) + dnl Add extra packages to the appliance. AC_ARG_WITH([extra-packages], [AS_HELP_STRING([--with-extra-packages="pkg1 pkg2 ..."], diff --git a/run.in b/run.in index a8c2904..4612e0e 100755 --- a/run.in +++ b/run.in @@ -77,13 +77,13 @@ fi PATH="$b/align:$b/builder:$b/cat:$b/customize:$b/df:$b/diff:$b/edit:$b/erlang:$b/fish:$b/format:$b/fuse:$b/inspector:$b/make-fs:$b/p2v:$b/rescue:$b/resize:$b/sparsify:$b/sysprep:$b/test-tool:$b/tools:$b/v2v:$PATH" export PATH -# Set LD_LIBRARY_PATH to contain library. -if [ -z "$LD_LIBRARY_PATH" ]; then - LD_LIBRARY_PATH="$b/src/.libs:$b/java/.libs:$b/gobject/.libs" +# Set @SHARED_LIBS_PATH@ to contain library. +if [ -z "$@SHARED_LIBS_PATH@" ]; then + @SHARED_LIBS_PATH@="$b/src/.libs:$b/java/.libs:$b/gobject/.libs" else - LD_LIBRARY_PATH="$b/src/.libs:$b/java/.libs:$b/gobject/.libs:$LD_LIBRARY_PATH" + @SHARED_LIBS_PATH@="$b/src/.libs:$b/java/.libs:$b/gobject/.libs:$@SHARED_LIBS_PATH@" fi -export LD_LIBRARY_PATH +export @SHARED_LIBS_PATH@ # Make virt-builder use the local website copy to avoid hitting # the network all the time. diff --git a/v2v/link.sh.in b/v2v/link.sh.in index 79dc847..3971d03 100644 --- a/v2v/link.sh.in +++ b/v2v/link.sh.in @@ -19,4 +19,4 @@ # Hack automake to link binary properly. There is no other way to add # the -cclib parameter to the end of the command line. -exec "$@" -linkpkg -cclib '-lutils @LIBTINFO_LIBS@ -lcrypt @LIBVIRT_LIBS@ @LIBXML2_LIBS@ @LIBINTL@ -lgnu' +exec "$@" -linkpkg -cclib '-lutils @LIBTINFO_LIBS@ @LCRYPT_FLAG@ @LIBVIRT_LIBS@ @LIBXML2_LIBS@ @LIBINTL@ -lgnu' -- 1.9.3
Pino Toscano
2015-Feb-12 18:42 UTC
Re: [Libguestfs] [PATCH] macosx: Darwin-specific autoconf macros
On Thursday 12 February 2015 17:49:55 Margaret Lewicka wrote:> * Replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH for Darwin > * Remove the -lcrypt flag for Darwin (unsupported) > --- > configure.ac | 13 +++++++++++++ > run.in | 10 +++++----- > v2v/link.sh.in | 2 +- > 3 files changed, 19 insertions(+), 6 deletions(-) > > diff --git a/configure.ac b/configure.ac > index d68190a..295de11 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -582,6 +582,19 @@ fi > AC_MSG_RESULT([$DISTRO]) > AC_SUBST([DISTRO]) > > +AC_MSG_CHECKING([whether we're building on Mac OS X]) > +if test "x$(uname)" = "xDarwin"; then > + AC_MSG_RESULT([yes]) > + LCRYPT_FLAG> + SHARED_LIBS_PATH="DYLD_LIBRARY_PATH" > +else > + AC_MSG_RESULT([no]) > + LCRYPT_FLAG="-lcrypt" > + SHARED_LIBS_PATH="LD_LIBRARY_PATH" > +fi > +AC_SUBST([LCRYPT_FLAG]) > +AC_SUBST([SHARED_LIBS_PATH])We link to libcrypt because it provides crypt(), at least on GNU libc and on the FreeBSD libc; it seems not the case on Mac OS X, looking at your patch. I'd say that this should turn into a proper configure check, trying to use crypt() without extra libraries and if not possible with libcrypt. Also (minor style detail) I'd call the variable name e.g. LIBCRYPT.> dnl Add extra packages to the appliance. > AC_ARG_WITH([extra-packages], > [AS_HELP_STRING([--with-extra-packages="pkg1 pkg2 ..."], > diff --git a/run.in b/run.in > index a8c2904..4612e0e 100755 > --- a/run.in > +++ b/run.in > @@ -77,13 +77,13 @@ fi > PATH="$b/align:$b/builder:$b/cat:$b/customize:$b/df:$b/diff:$b/edit:$b/erlang:$b/fish:$b/format:$b/fuse:$b/inspector:$b/make-fs:$b/p2v:$b/rescue:$b/resize:$b/sparsify:$b/sysprep:$b/test-tool:$b/tools:$b/v2v:$PATH" > export PATH > > -# Set LD_LIBRARY_PATH to contain library. > -if [ -z "$LD_LIBRARY_PATH" ]; then > - LD_LIBRARY_PATH="$b/src/.libs:$b/java/.libs:$b/gobject/.libs" > +# Set @SHARED_LIBS_PATH@ to contain library. > +if [ -z "$@SHARED_LIBS_PATH@" ]; then > + @SHARED_LIBS_PATH@="$b/src/.libs:$b/java/.libs:$b/gobject/.libs" > else > - LD_LIBRARY_PATH="$b/src/.libs:$b/java/.libs:$b/gobject/.libs:$LD_LIBRARY_PATH" > + @SHARED_LIBS_PATH@="$b/src/.libs:$b/java/.libs:$b/gobject/.libs:$@SHARED_LIBS_PATH@" > fi > -export LD_LIBRARY_PATH > +export @SHARED_LIBS_PATH@Is setting LD_LIBRARY_PATH somehow harmful/problematic on Mac OS X? If not, I'd say to use a variable for the library paths we want to add, then adding them to both LD_LIBRARY_PATH and DYLD_LIBRARY_PATH; something like libdirs="$b/src/.libs:...etc" # Set LD_LIBRARY_PATH to contain library. if [ -z "$LD_LIBRARY_PATH" ]; then LD_LIBRARY_PATH="$libdirs" else LD_LIBRARY_PATH="$libdirs:$LD_LIBRARY_PATH" fi export LD_LIBRARY_PATH # ditto for DYLD_LIBRARY_PATH Thanks, -- Pino Toscano
Margaret Lewicka
2015-Feb-12 18:54 UTC
Re: [Libguestfs] [PATCH] macosx: Darwin-specific autoconf macros
On 12 February 2015 at 18:42, Pino Toscano <ptoscano@redhat.com> wrote: [...]> We link to libcrypt because it provides crypt(), at least on GNU libc > and on the FreeBSD libc; it seems not the case on Mac OS X, looking > at your patch. > I'd say that this should turn into a proper configure check, trying to > use crypt() without extra libraries and if not possible with libcrypt.The crypt() thing is explained here: https://developer.apple.com/library/mac/documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html#//apple_ref/doc/uid/TP40002850-SW17 (Compiling... in OS X -> Other Porting Tips -> Functions -> crypt). (TL;DR: crypt() comes from unistd.h) [...]> Is setting LD_LIBRARY_PATH somehow harmful/problematic on Mac OS X? > If not, I'd say to use a variable for the library paths we want to add, > then adding them to both LD_LIBRARY_PATH and DYLD_LIBRARY_PATH; > something like > libdirs="$b/src/.libs:...etc" > # Set LD_LIBRARY_PATH to contain library. > if [ -z "$LD_LIBRARY_PATH" ]; then > LD_LIBRARY_PATH="$libdirs" > else > LD_LIBRARY_PATH="$libdirs:$LD_LIBRARY_PATH" > fi > export LD_LIBRARY_PATH > # ditto for DYLD_LIBRARY_PATHYou'll end up with two semi-identical blocks of code, though, because you'll have to perform the same -z check for DYLD_LIBRARY_PATH. (As far as I am aware, Darwin does not use LD_LIBRARY_PATH, hence the substitution.) -- M.
Maybe Matching Threads
- [PATCH] macosx: Darwin-specific autoconf macros
- Re: [PATCH] macosx: Darwin-specific autoconf macros
- [PATCH 1/2] run: Set DYLD_LIBRARY_PATH along with LD_LIBRARY_PATH
- [LLVMdev] [RFC] Progress report on CMake build system's ability to replace autoconf
- RAqua package installation on Panther