You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/04/26 02:59:22 UTC

git commit: Updated policy for building against system dependencies.

Repository: mesos
Updated Branches:
  refs/heads/master 66d0518b3 -> 77427c6d2


Updated policy for building against system dependencies.

Allows preventing the use of bundled libraries in favor of
preinstalled versions, where possible.

Using --disable-bundled generally switches from bundled to
preinstalled libraries.

If --disable-bundled is supplied or --with-leveldb[=DIR] was given but
the configuration phase could not locate the dependency, it stops with
an error.

If --disable-bundled is not supplied and no --with-leveldb[=DIR] was
given, the bundled library is built and used (DEFAULT).

NOTE:

1. This review only implements this preinstalled library usage on
LevelDB & ZooKeeper. Subsequent review requests for other bundled
libraries will follow as soon as this implementation has been
accepted.

2. This modification removed the old --without-installed-PACKAGE
semantics, as they conflict with well established --with-PACKAGE
semantics

Review: https://reviews.apache.org/r/20119


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/77427c6d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/77427c6d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/77427c6d

Branch: refs/heads/master
Commit: 77427c6d2a83dc7385d451504f0a52a2666143fe
Parents: 66d0518
Author: Timothy St. Clair <ts...@redhat.com>
Authored: Fri Apr 25 17:56:58 2014 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Fri Apr 25 17:59:03 2014 -0700

----------------------------------------------------------------------
 3rdparty/Makefile.am   |  34 +++++++------
 configure.ac           | 116 +++++++++++++++++++++++++++++++++++++++-----
 src/Makefile.am        |  21 +++++---
 src/python/setup.py.in |  23 ++++++++-
 4 files changed, 157 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/77427c6d/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index 23ff1fa..cfeaac7 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -56,37 +56,39 @@ CLEAN_EXTRACTED =	\
 	test ! -e $(srcdir)/$*.patch || patch -d $* -p1 <$(srcdir)/$*.patch
 	touch $@
 
+# Dependencies for all-local.
+ALL_LOCAL = # Initialize ALL_LOCAL so we can add to it.
 
 if HAS_PYTHON
-DISTRIBUTE_EGG = \
-  $(DISTRIBUTE)/dist/$(DISTRIBUTE)$(PYTHON_EGG_PUREPY_POSTFIX).egg
+  DISTRIBUTE_EGG = \
+    $(DISTRIBUTE)/dist/$(DISTRIBUTE)$(PYTHON_EGG_PUREPY_POSTFIX).egg
 
-$(DISTRIBUTE_EGG): $(DISTRIBUTE)-stamp
+  $(DISTRIBUTE_EGG): $(DISTRIBUTE)-stamp
 	cd $(DISTRIBUTE) && $(PYTHON) setup.py bdist_egg
+
+  ALL_LOCAL += $(DISTRIBUTE_EGG)
 endif
 
+if WITH_BUNDLED_LEVELDB
 
-# TODO(charles): Figure out PIC options in our configure.ac or create
-# a configure.ac for leveldb.
-$(LEVELDB)/libleveldb.a: $(LEVELDB)-stamp
+  # TODO(charles): Figure out PIC options in our configure.ac or create
+  # a configure.ac for leveldb.
+  $(LEVELDB)/libleveldb.a: $(LEVELDB)-stamp
 	cd $(LEVELDB) && \
           $(MAKE) $(AM_MAKEFLAGS) CC="$(CC)" CXX="$(CXX)" OPT="$(CXXFLAGS) -fPIC"
 
-$(ZOOKEEPER)/src/c/libzookeeper_mt.la: $(ZOOKEEPER)-stamp
-	cd $(ZOOKEEPER)/src/c && ./configure $(CONFIGURE_ARGS) && \
-          $(MAKE) $(AM_MAKEFLAGS)
+  ALL_LOCAL += $(LEVELDB)/libleveldb.a
+endif
 
-# Dependencies for all-local.
-ALL_LOCAL = $(LEVELDB)/libleveldb.a
+if WITH_BUNDLED_ZOOKEEPER
 
-if HAS_PYTHON
-  ALL_LOCAL += $(DISTRIBUTE_EGG)
-endif
+  $(ZOOKEEPER)/src/c/libzookeeper_mt.la: $(ZOOKEEPER)-stamp
+	cd $(ZOOKEEPER)/src/c && ./configure $(CONFIGURE_ARGS) && \
+	  $(MAKE) $(AM_MAKEFLAGS)
 
-if WITH_INCLUDED_ZOOKEEPER
   ALL_LOCAL += $(ZOOKEEPER)/src/c/libzookeeper_mt.la
 else
-  # Now matter what we need to extract ZooKeeper so that we can run
+  # No matter what, we need to extract ZooKeeper so that we can run
   # 'make check' (some of our tests need the ZooKeeper JAR).
   ALL_LOCAL += $(ZOOKEEPER)-stamp
 endif

http://git-wip-us.apache.org/repos/asf/mesos/blob/77427c6d/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index cbc8adf..01182b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,17 +138,28 @@ AC_ARG_ENABLE([optimize],
                              [don't try to compile with optimizations]),
               [], [enable_optimize=yes])
 
-AC_ARG_WITH([included-zookeeper],
-            AS_HELP_STRING([--without-included-zookeeper],
-                           [excludes building and using the included ZooKeeper
-                           package in lieu of a system installed version (note,
-                           however, that no attempt is made to find the package
-                           and explicitly setting CPPFLAGS and LDFLAGS as
-                           appropriate may be necessary)]),
-             [], [with_included_zookeeper=yes])
+AC_ARG_ENABLE([bundled],
+	      AS_HELP_STRING([--disable-bundled],
+			     [build against preinstalled dependencies instead
+			     of bundled libraries]),
+	      [enable_bundled=no], [enable_bundled=yes])
+
+AC_ARG_WITH([zookeeper],
+	    AS_HELP_STRING([--with-zookeeper@<:@=DIR@:>@],
+			   [excludes building and using the bundled ZooKeeper
+			   package in lieu of an installed version at a
+			   location prefixed by the given path]),
+	    [without_bundled_zookeeper=yes], [])
+
+AC_ARG_WITH([leveldb],
+	    AS_HELP_STRING([--with-leveldb@<:@=DIR@:>@],
+			   [excludes building and using the bundled LevelDB
+			   package in lieu of an installed version at a
+			   location prefixed by the given path]),
+	    [without_bundled_leveldb=yes], [])
 
 AC_ARG_WITH([cxx11],
-            AS_HELP_STRING([--without-cxx11],
+	    AS_HELP_STRING([--without-cxx11],
                            [builds Mesos without C++11 support (deprecated)]),
             [], [with_cxx11=yes])
 
@@ -200,6 +211,88 @@ if test "x$enable_optimize" = "xyes"; then
 fi
 
 
+# Attempt to use preinstalled dependencies instead of the bundled versions in
+# cases where the user specified their location (--with-XXX=DIR) or asked us
+# to attempt to detect them (--disable-bundled).
+
+# Check if LevelDB prefix path was supplied and if so, add it to
+# CPPFLAGS while extending it by /include and to LDFLAGS while
+# extending it by /lib.
+if test -n "`echo $with_leveldb`"; then
+    CPPFLAGS="$CPPFLAGS -I${with_leveldb}/include"
+    LDFLAGS="$LDFLAGS -L${with_leveldb}/lib"
+fi
+
+# Check if ZooKeeper prefix path was supplied and if so, add it to
+# CPPFLAGS while extending it by /include and to LDFLAGS while
+# extending it by /lib.
+if test -n "`echo $with_zookeeper`"; then
+    CPPFLAGS="$CPPFLAGS -I${with_zookeeper}/include"
+    LDFLAGS="$LDFLAGS -L${with_zookeeper}/lib"
+elif test "x$enable_bundled" = "xno"; then
+    CPPFLAGS="$CPPFLAGS -I/usr/include/zookeeper"
+fi
+
+# Check if user has asked us to use a preinstalled LevelDB, or if they asked
+# us to ignore all bundled libraries while compiling and linking.
+if test "x$without_bundled_leveldb" = "xyes" || \
+   test "x$enable_bundled" != "xyes"; then
+	# Check if headers and library were located.
+	AC_CHECK_HEADERS([leveldb/db.h],
+			[AC_CHECK_LIB([leveldb],
+				      [leveldb_open],
+				      [found_leveldb=yes])])
+	if test "x$found_leveldb" = "xyes"; then
+		with_bundled_leveldb=no
+	else
+		AC_MSG_ERROR([cannot find LevelDB
+-------------------------------------------------------------------
+You have requested the use of a non-bundled LevelDB but no suitable
+LevelDB could be found.
+
+You may want specify the location of LevelDB by providing a prefix
+path via --with-leveldb=DIR, or check that the path you provided is
+correct if you're already doing this.
+-------------------------------------------------------------------
+])
+	fi
+else
+    with_bundled_leveldb=yes
+fi
+
+AM_CONDITIONAL([WITH_BUNDLED_LEVELDB],
+	       [test "x$with_bundled_leveldb" = "xyes"])
+
+# Check if user has asked us to use a preinstalled ZooKeeper or if they asked
+# us to ignore all bundled libraries while compiling and linking.
+if test "x$without_bundled_zookeeper" = "xyes" || \
+   test "x$enable_bundled" != "xyes"; then
+	# Check if headers and library were located.
+	AC_CHECK_HEADERS([zookeeper.h],
+			[AC_CHECK_LIB([zookeeper_mt],
+				      [zookeeper_init],
+				      [found_zookeeper=yes])])
+	if test "x$found_zookeeper" = "xyes"; then
+		with_bundled_zookeeper=no
+	else
+		AC_MSG_ERROR([cannot find ZooKeeper
+-------------------------------------------------------------------
+You have requested the use of a non-bundled ZooKeeper but no suitable
+ZooKeeper could be found.
+
+You may want specify the location of ZooKeeper by providing a prefix
+path via --with-zookeeper=DIR, or check that the path you provided is
+correct if you're already doing this
+-------------------------------------------------------------------
+])
+	fi
+else
+    with_bundled_zookeeper=yes
+fi
+
+AM_CONDITIONAL([WITH_BUNDLED_ZOOKEEPER],
+	   [test "x$with_bundled_zookeeper" = "xyes"])
+
 # Check if we're using clang.
 AC_MSG_CHECKING([if compiling with clang])
 
@@ -605,6 +698,7 @@ There are two possible workarounds for this issue:
   # TODO(tillt): Remove this once Apple distributed an updated Python.
   PYTHON_CFLAGS="$CFLAGS"
   PYTHON_CPPFLAGS="$CPPFLAGS"
+  PYTHON_LDFLAGS="$LDFLAGS"
 
   AS_IF([test "x$CLANG" = "xyes"],
 	[PYTHON_CFLAGS="$PYTHON_CFLAGS -Qunused-arguments"
@@ -644,10 +738,6 @@ libcurl is required for mesos to build.
 ])])
 
 
-AM_CONDITIONAL([WITH_INCLUDED_ZOOKEEPER],
-               [test "x$with_included_zookeeper" = "xyes"])
-
-
 # Check if we should/can build with C++11.
 if test "x$with_cxx11" = "xyes"; then
   AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])

http://git-wip-us.apache.org/repos/asf/mesos/blob/77427c6d/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index e13a0f6..c2029c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,14 +85,16 @@ MESOS_CPPFLAGS += -I../$(BOOST)
 MESOS_CPPFLAGS += -I../$(PROTOBUF)/src
 MESOS_CPPFLAGS += -I../$(PICOJSON)
 MESOS_CPPFLAGS += -I../$(GLOG)/src
-MESOS_CPPFLAGS += -I../$(LEVELDB)/include
 
-if WITH_INCLUDED_ZOOKEEPER
+if WITH_BUNDLED_LEVELDB
+  MESOS_CPPFLAGS += -I../$(LEVELDB)/include
+endif
+
+if WITH_BUNDLED_ZOOKEEPER
   MESOS_CPPFLAGS += -I../$(ZOOKEEPER)/include
   MESOS_CPPFLAGS += -I../$(ZOOKEEPER)/generated
 endif
 
-
 # README: we build the Mesos library out of a collection of
 # convenience libraries (that is, libraries that do not get installed
 # but we can use as building blocks to vary compile flags as necessary
@@ -428,18 +430,24 @@ libmesos_la_LIBADD = libmesos_no_3rdparty.la
 libmesos_la_LIBADD += ../$(PROTOBUF)/src/libprotobuf.la
 libmesos_la_LIBADD += ../$(GLOG)/libglog.la
 
+if WITH_BUNDLED_LEVELDB
 # We need to directly include the leveldb library in order to avoid
 # the installed libmesos.la file to include leveldb in
 # 'dependency_libs' (via '-L../3rdparty/leveldb -lleveldb').
-libmesos_la_LIBADD += ../$(LEVELDB)/libleveldb.a
 
-if WITH_INCLUDED_ZOOKEEPER
+  libmesos_la_LIBADD += ../$(LEVELDB)/libleveldb.a
+else
+  libmesos_la_LIBADD += -lleveldb
+endif
+
+if WITH_BUNDLED_ZOOKEEPER
   libmesos_la_LIBADD += ../$(ZOOKEEPER)/libzookeeper_mt.la
+else
+  libmesos_la_LIBADD += -lzookeeper_mt
 endif
 
 libmesos_la_LIBADD += ../$(LIBPROCESS)/libprocess.la
 
-
 # Binaries.
 sbin_PROGRAMS += mesos-master
 mesos_master_SOURCES = master/main.cpp
@@ -803,6 +811,7 @@ $(MESOS_EGG): python/setup.py $(srcdir)/python/src/mesos.py		\
 	fi
 	@LIBS="$(LIBS)" CC="$(CC)" CXX="$(CXX)"				\
 	CFLAGS="$(PYTHON_CFLAGS)" CPPFLAGS="$(PYTHON_CPPFLAGS)"		\
+	LDFLAGS="$(PYTHON_LDFLAGS)"					\
 	PYTHONPATH=$(DISTRIBUTE_EGG) $(PYTHON) python/setup.py bdist_egg
 
 CLEANFILES += $(MESOS_EGG) python/build/temp.*/native/*.o python/build/lib.*/*

http://git-wip-us.apache.org/repos/asf/mesos/blob/77427c6d/src/python/setup.py.in
----------------------------------------------------------------------
diff --git a/src/python/setup.py.in b/src/python/setup.py.in
index 02f00ef..0c6e264 100644
--- a/src/python/setup.py.in
+++ b/src/python/setup.py.in
@@ -72,13 +72,27 @@ LIBRARY_DIRS = []
 EXTRA_OBJECTS = [
   os.path.join(abs_top_builddir, 'src', '.libs', 'libmesos_no_3rdparty.a'),
   os.path.join(abs_top_builddir, protobuf, 'src', '.libs', 'libprotobuf.a'),
-  os.path.join(abs_top_builddir, leveldb, 'libleveldb.a'),
-  os.path.join(abs_top_builddir, zookeeper, '.libs', 'libzookeeper_mt.a'),
   os.path.join(abs_top_builddir, libprocess, '.libs', 'libprocess.a'),
   os.path.join(abs_top_builddir, glog, '.libs', 'libglog.a'),
   os.path.join(abs_top_builddir, libev, '.libs', 'libev.a'),
 ]
 
+# For leveldb, we need to check for the presence of libleveldb.a, since
+# it is possible to disable leveldb inside mesos.
+libleveldb = os.path.join(abs_top_builddir, leveldb, 'libleveldb.a')
+libzookeeper = os.path.join(
+    abs_top_builddir, zookeeper, '.libs', 'libzookeeper_mt.a')
+
+if os.path.exists(libleveldb):
+  EXTRA_OBJECTS.append(libleveldb)
+else:
+  EXTRA_OBJECTS.append('-lleveldb')
+
+if os.path.exists(libzookeeper):
+  EXTRA_OBJECTS.append(libzookeeper)
+else:
+  EXTRA_OBJECTS.append('-lzookeeper_mt')
+
 # For gperftools, we need to check for the presence of libprofiler.a, since
 # it is possible to disable perftools inside libprocess.
 libprofiler = os.path.join(
@@ -89,6 +103,11 @@ if os.path.exists(libprofiler):
 
 EXTRA_LINK_ARGS = []
 
+# Add any flags from LDFLAGS.
+if 'LDFLAGS' in os.environ:
+  for flag in os.environ['LDFLAGS'].split():
+    EXTRA_LINK_ARGS.append(flag)
+
 # Add any libraries from LIBS.
 if 'LIBS' in os.environ:
   for library in os.environ['LIBS'].split():