apache hawq make dbcommon univplan storage
diff --git a/GNUmakefile.in b/GNUmakefile.in
index e6d01d0..d23cdee 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -13,6 +13,9 @@
 	$(MAKE) -C depends/thirdparty/googletest $@
 	$(MAKE) -C depends/libhdfs3 $@
 	$(MAKE) -C depends/libyarn $@
+	$(MAKE) -C depends/dbcommon $@
+	$(MAKE) -C depends/univplan $@
+	$(MAKE) -C depends/storage $@
 	$(MAKE) -C src $@
 	$(MAKE) -C config $@
 	$(MAKE) -C contrib $@
@@ -25,6 +28,9 @@
 	$(MAKE) -C depends/thirdparty/googletest $@ 
 	$(MAKE) -C depends/libhdfs3 $@
 	$(MAKE) -C depends/libyarn $@
+	$(MAKE) -C depends/dbcommon $@
+	$(MAKE) -C depends/univplan $@
+	$(MAKE) -C depends/storage $@
 	$(MAKE) -C src $@
 	$(MAKE) -C config $@
 	$(MAKE) -C contrib $@
@@ -66,6 +72,9 @@
 	-$(MAKE) -C depends/thirdparty/googletest $@ 
 	-$(MAKE) -C depends/libhdfs3 $@
 	-$(MAKE) -C depends/libyarn $@
+	-$(MAKE) -C depends/dbcommon $@
+	-$(MAKE) -C depends/univplan $@
+	-$(MAKE) -C depends/storage $@
 	$(MAKE) -C src $@
 	$(MAKE) -C config $@
 	$(MAKE) -C contrib $@
@@ -85,6 +94,9 @@
 	-$(MAKE) -C depends/thirdparty/googletest $@ 
 	-$(MAKE) -C depends/libhdfs3 $@
 	-$(MAKE) -C depends/libyarn $@
+	-$(MAKE) -C depends/dbcommon $@
+	-$(MAKE) -C depends/univplan $@
+	-$(MAKE) -C depends/storage $@
 	-$(MAKE) -C config $@
 	-$(MAKE) -C tools $@
 	-$(MAKE) -C src feature-test-clean
diff --git a/configure b/configure
index 2a442c4..3ca66a6 100755
--- a/configure
+++ b/configure
@@ -723,6 +723,9 @@
 with_system_tzdata
 with_libhdfs3
 with_libyarn
+with_dbcommon
+with_univplan
+with_storage
 with_openssl
 with_bonjour
 with_ldap
@@ -872,6 +875,9 @@
 with_readline
 with_libyarn
 with_libhdfs3
+with_dbcommon
+with_univplan
+with_storage
 with_libedit_preferred
 with_system_tzdata
 with_zlib
@@ -1563,6 +1569,9 @@
   --without-readline      do not use GNU Readline nor BSD Libedit for editing
   --without-libyarn       do not build libyarn
   --without-libhdfs3      do not build libhdfs3
+  --without-dbcommon      do not build dbcommon
+  --without-univplan      do not build univplan
+  --without-storage       do not build storage
   --without-libedit-preferred  Don't prefer BSD Libedit over GNU Readline
   --with-system-tzdata=DIR  use system time zone data in DIR
   --without-zlib          do not use Zlib
@@ -6234,6 +6243,95 @@
 
 
 #
+# dbcommon
+#
+
+pgac_args="$pgac_args with_dbcommon"
+
+
+# Check whether --with-dbcommon was given.
+if test "${with_dbcommon+set}" = set; then :
+  withval=$with_dbcommon;
+  case $withval in
+    yes)
+      :
+      ;;
+    no)
+      :
+      ;;
+    *)
+      as_fn_error $? "no argument expected for --with-dbcommon option" "$LINENO" 5
+      ;;
+  esac
+
+else
+  with_dbcommon=yes
+
+fi
+
+
+
+
+#
+# univplan
+#
+
+pgac_args="$pgac_args with_univplan"
+
+
+# Check whether --with-univplan was given.
+if test "${with_univplan+set}" = set; then :
+  withval=$with_univplan;
+  case $withval in
+    yes)
+      :
+      ;;
+    no)
+      :
+      ;;
+    *)
+      as_fn_error $? "no argument expected for --with-univplan option" "$LINENO" 5
+      ;;
+  esac
+
+else
+  with_univplan=yes
+
+fi
+
+
+
+
+#
+# storage
+#
+
+pgac_args="$pgac_args with_storage"
+
+
+# Check whether --with-storage was given.
+if test "${with_storage+set}" = set; then :
+  withval=$with_storage;
+  case $withval in
+    yes)
+      :
+      ;;
+    no)
+      :
+      ;;
+    *)
+      as_fn_error $? "no argument expected for --with-storage option" "$LINENO" 5
+      ;;
+  esac
+
+else
+  with_storage=yes
+
+fi
+
+
+
+#
 # Prefer libedit
 #
 # In GPDB we want the default to be yes, because we don't want to link with GPL code.
@@ -16837,7 +16935,7 @@
 fi
 
 
-ac_config_files="$ac_config_files GNUmakefile src/VERSIONS.mk depends/thirdparty/googletest/Makefile.global depends/libhdfs3/Makefile.global depends/libyarn/Makefile.global src/Makefile.global src/pl/pljava/src/java/Makefile.global ranger-plugin/Makefile.global"
+ac_config_files="$ac_config_files GNUmakefile src/VERSIONS.mk depends/thirdparty/googletest/Makefile.global depends/libhdfs3/Makefile.global depends/libyarn/Makefile.global depends/dbcommon/Makefile.global depends/univplan/Makefile.global depends/storage/Makefile.global src/Makefile.global src/pl/pljava/src/java/Makefile.global ranger-plugin/Makefile.global"
 
 
 ac_config_links="$ac_config_links src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
@@ -16848,9 +16946,12 @@
 
 fi
 
-# Remove build_timestamp file to make sure rebuild depends lib: libhdfs & libyarn
+# Remove build_timestamp file to make sure rebuild depends lib: libhdfs & libyarn & dbcommon & univplan & storage
 rm -f depends/libhdfs3/build/libhdfs3_build_timestamp
 rm -f depends/libyarn/build/libyarn_build_timestamp
+rm -f depends/dbcommon/build/dbcommon_build_timestamp
+rm -f depends/univplan/build/univplan_build_timestamp
+rm -f depends/storage/build/storage_build_timestamp
 rm -f depends/thirdparty/gporca_build_timestamp
 rm -f depends/thirdparty/gpos_build_timestamp
 rm -f depends/thirdparty/gp-xerces_build_timestamp
@@ -17568,6 +17669,9 @@
     "depends/thirdparty/googletest/Makefile.global") CONFIG_FILES="$CONFIG_FILES depends/thirdparty/googletest/Makefile.global" ;;
     "depends/libhdfs3/Makefile.global") CONFIG_FILES="$CONFIG_FILES depends/libhdfs3/Makefile.global" ;;
     "depends/libyarn/Makefile.global") CONFIG_FILES="$CONFIG_FILES depends/libyarn/Makefile.global" ;;
+    "depends/dbcommon/Makefile.global") CONFIG_FILES="$CONFIG_FILES depends/dbcommon/Makefile.global" ;;
+    "depends/univplan/Makefile.global") CONFIG_FILES="$CONFIG_FILES depends/univplan/Makefile.global" ;;
+    "depends/storage/Makefile.global") CONFIG_FILES="$CONFIG_FILES depends/storage/Makefile.global" ;;
     "src/Makefile.global") CONFIG_FILES="$CONFIG_FILES src/Makefile.global" ;;
     "src/pl/pljava/src/java/Makefile.global") CONFIG_FILES="$CONFIG_FILES src/pl/pljava/src/java/Makefile.global" ;;
     "ranger-plugin/Makefile.global") CONFIG_FILES="$CONFIG_FILES ranger-plugin/Makefile.global" ;;
diff --git a/configure.in b/configure.in
index 10024e4..b65bee5 100644
--- a/configure.in
+++ b/configure.in
@@ -843,6 +843,27 @@
 AC_SUBST(with_libhdfs3)
 
 #
+# dbcommon
+#
+PGAC_ARG_BOOL(with, dbcommon, yes,
+              [  --without-dbcommon      do not build dbcommon])
+AC_SUBST(with_dbcommon)
+
+#
+# univplan
+#
+PGAC_ARG_BOOL(with, univplan, yes,
+              [  --without-univplan      do not build univplan])
+AC_SUBST(with_univplan)
+
+#
+# storage
+#
+PGAC_ARG_BOOL(with, storage, yes,
+              [  --without-storage      do not build storage])
+AC_SUBST(with_storage)
+
+#
 # Prefer libedit
 #
 # In GPDB we want the default to be yes, because we don't want to link with GPL code.
@@ -2185,7 +2206,7 @@
 fi
 AC_SUBST(vpath_build)
 
-AC_CONFIG_FILES([GNUmakefile src/VERSIONS.mk depends/thirdparty/googletest/Makefile.global depends/libhdfs3/Makefile.global depends/libyarn/Makefile.global src/Makefile.global src/pl/pljava/src/java/Makefile.global ranger-plugin/Makefile.global])
+AC_CONFIG_FILES([GNUmakefile src/VERSIONS.mk depends/thirdparty/googletest/Makefile.global depends/libhdfs3/Makefile.global depends/libyarn/Makefile.global depends/dbcommon/Makefile.global depends/univplan/Makefile.global depends/storage/Makefile.global src/Makefile.global src/pl/pljava/src/java/Makefile.global ranger-plugin/Makefile.global])
 
 AC_CONFIG_LINKS([
   src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c
@@ -2208,9 +2229,12 @@
 ])
 fi
 
-# Remove build_timestamp file to make sure rebuild depends lib: libhdfs & libyarn 
+# Remove build_timestamp file to make sure rebuild depends lib: libhdfs & libyarn & dbcommon & univplan & storage
 rm -f depends/libhdfs3/build/libhdfs3_build_timestamp
 rm -f depends/libyarn/build/libyarn_build_timestamp
+rm -f depends/dbcommon/build/dbcommon_build_timestamp
+rm -f depends/univplan/build/univplan_build_timestamp
+rm -f depends/storage/build/storage_build_timestamp
 rm -f depends/thirdparty/gporca_build_timestamp
 rm -f depends/thirdparty/gpos_build_timestamp
 rm -f depends/thirdparty/gp-xerces_build_timestamp
diff --git a/depends/Makefile b/depends/Makefile
deleted file mode 100644
index 739e200..0000000
--- a/depends/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-.PHONY: release debug
-
-incremental:
-	./build-all.sh incremental
-
-release:
-	./build-all.sh release
-
-debug: 
-	./build-all.sh debug
-
-coverage:
-	./build-all.sh coverage
-
-noavx:
-	./build-all.sh noavx
diff --git a/depends/README b/depends/README
deleted file mode 100644
index e69de29..0000000
--- a/depends/README
+++ /dev/null
diff --git a/depends/bootstrap b/depends/bootstrap
deleted file mode 100755
index 1851fd2..0000000
--- a/depends/bootstrap
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash -e
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-source_dir=`cd "\`dirname \"$0\"\`";pwd`
-if [ $source_dir = `pwd` ]; then
-	echo 'Error: Don''t bootstrap in the source folder'
-	exit
-fi
-
-cp $source_dir/Makefile .
-cat $source_dir/build-all.sh| sed "s|../bootstrap|$source_dir/\$MODULE/bootstrap|g" > ./build-all.sh
-chmod +x ./build-all.sh
diff --git a/depends/build-all.sh b/depends/build-all.sh
deleted file mode 100755
index 29d7782..0000000
--- a/depends/build-all.sh
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/bash -e
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-PREFIX="/opt/dependency/package"
-export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
-export DYLD_FALLBACK_LIBRARY_PATH=$PREFIX/lib:$DYLD_FALLBACK_LIBRARY_PATH
-
-if [[ -z $RUN_UNITTEST ]]; then
-   RUN_UNITTEST=YES
-fi
-OPTION=""
-case $1 in
-    release)
-        echo "Build Release Version ..."
-        OPTION=""
-        ;;
-    debug)
-        echo "Build Debug Version ..."
-        OPTION="--enable-debug"
-        ;;
-    coverage)
-        echo "Build Coverage Version ..."
-        OPTION="--enable-coverage"
-        ;;
-    noavx)
-        echo "Build AVX Version ..."
-        OPTION="--enable-avx=OFF"
-        ;;
-    incremental)
-        echo "Build incremental ..."
-        OPTION="incremental"
-        ;;
-    *)
-        echo "Build Release Version ..."
-        OPTION="";
-        ;;
-esac
-
-function build() {
-  echo "Build $1 ..."
-  
-  MODULE=$1
-  MAGMA_OPTION=""
-  ###kv_client && kv_server#####
-  if [ $1 = "magma_client" ] ;then
-    MAGMA_OPTION="--enable-client"
-    MODULE=magma
-  fi
-  if [ $1 = "magma_server" ] ;then
-    MAGMA_OPTION="--enable-server"
-    MODULE=magma
-  fi
-   
-  if [ "$OPTION" != "incremental" ]; then
-    echo "rm $DIR/$MODULE/build"
-    rm -rf $DIR/$MODULE/build
-
-    mkdir -p $DIR/$MODULE/build
-    cd $DIR/$MODULE/build
-    echo "../bootstrap $OPTION $MAGMA_OPTION"
-    ../bootstrap $OPTION $MAGMA_OPTION
-    CMAKE_OPTION=$OPTION
-  else
-    if [ ! -d $DIR/$MODULE/build ]; then mkdir -p $DIR/$MODULE/build; fi
-    cd $DIR/$MODULE/build
-    CMAKE_OPTION=$(grep 'CMAKE_BUILD_TYPE:STRING=' CMakeCache.txt | cut -d'=' -f2)
-    case $CMAKE_OPTION in
-      Release)
-        CMAKE_OPTION=""
-        ;;
-      Debug)
-        CMAKE_OPTION="--enable-debug"
-        codecov=$(grep 'ENABLE_COVERAGE:BOOL=' CMakeCache.txt | cut -d'=' -f2)
-        if [ $codecov = 'ON' ]; then
-          CMAKE_OPTION="--enable-coverage"
-        fi
-        ;;
-      *)
-        CMAKE_OPTION="";
-        ;;
-      esac
-    echo "../bootstrap $CMAKE_OPTION $MAGMA_OPTION"
-    ../bootstrap $CMAKE_OPTION $MAGMA_OPTION
-  fi
-
-  if [[ $OPTION == "--enable-coverage" || $CMAKE_OPTION == "--enable-coverage" ]]
-  then
-    make coverage
-  else
-    make -j8 ;
-    if [[ $RUN_UNITTEST == "YES" ]]; then
-        echo "Run unittest ...."
-        make -j8 punittest
-    else
-        echo "Do not run unittest...."
-    fi
-  fi
-  make -j8 install
-
-  echo "Done."
-}
-echo "Delete headers in ${PREFIX}/include ..."
-rm -rf $PREFIX/include/dbcommon
-rm -rf $PREFIX/include/univplan
-rm -rf $PREFIX/include/storage
-echo "Done."
-
-echo "Delete libs in ${PREFIX}/lib ..."
-rm -rf $PREFIX/lib/libdbcommon*
-rm -rf $PREFIX/lib/libunivplan*
-rm -rf $PREFIX/lib/libstorage*
-echo "Done."
-
-build dbcommon
-build univplan
-build storage
diff --git a/depends/dbcommon/CMake/FindJSON.cmake b/depends/dbcommon/CMake/FindJSON.cmake
index a334948..ff5008b 100644
--- a/depends/dbcommon/CMake/FindJSON.cmake
+++ b/depends/dbcommon/CMake/FindJSON.cmake
@@ -20,7 +20,7 @@
 #  License text for the above reference.)
 
 # Look for the header file.
-find_path(JSON_INCLUDE_DIR NAMES json/json.h)
+find_path(JSON_INCLUDE_DIR NAMES json-c/json.h)
 mark_as_advanced(JSON_INCLUDE_DIR)
 
 # Look for the library (sorted from most current/relevant entry to least).
diff --git a/depends/dbcommon/CMake/Options.cmake b/depends/dbcommon/CMake/Options.cmake
index 36841ea..8be997e 100644
--- a/depends/dbcommon/CMake/Options.cmake
+++ b/depends/dbcommon/CMake/Options.cmake
@@ -5,7 +5,8 @@
 ##############################################################################
 # Setup build and dependencies information 
 ##############################################################################
-SET(DEPENDENCY_INSTALL_PREFIX "/opt/dependency")
+#SET(DEPENDENCY_INSTALL_PREFIX "/opt/dependency")
+SET(DEPENDENCY_INSTALL_PREFIX "/usr/local/hawq")
 IF($ENV{DEPENDENCY_INSTALL_PREFIX})
 	SET(DEPENDENCY_INSTALL_PREFIX $ENV{DEPENDENCY_INSTALL_PREFIX})
 ENDIF()
@@ -19,8 +20,10 @@
 SET(CMAKE_PREFIX_PATH "${DEPENDENCY_INSTALL_PREFIX}/package" ${CMAKE_PREFIX_PATH})
 SET(CMAKE_PREFIX_PATH "${DEPENDENCY_INSTALL_PREFIX}/tools" ${CMAKE_PREFIX_PATH})
 
-SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib:${DEPENDENCY_LIBRARY_PATH}")
-SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib64:${DEPENDENCY_LIBRARY_PATH}")
+#SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib:${DEPENDENCY_LIBRARY_PATH}")
+#SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib64:${DEPENDENCY_LIBRARY_PATH}")
+SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/lib:${DEPENDENCY_LIBRARY_PATH}")
+SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/lib64:${DEPENDENCY_LIBRARY_PATH}")
 
 ##############################################################################
 # Setup build flags
diff --git a/depends/dbcommon/CMakeLists.txt b/depends/dbcommon/CMakeLists.txt
index dd15bfc..67ef822 100644
--- a/depends/dbcommon/CMakeLists.txt
+++ b/depends/dbcommon/CMakeLists.txt
@@ -1,10 +1,13 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 PROJECT(dbcommon)
 
+SET(CMAKE_VERBOSE_MAKEFILE ON CACHE STRING "Verbose build." FORCE)
+
 ##############################################################################
 # General CMake initialization
 ##############################################################################
 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
+SET(DOXYFILE_PATH ${CMAKE_SOURCE_DIR}/docs)
 SET(CMAKE_VERBOSE_MAKEFILE OFF CACHE STRING "Verbose build." FORCE)
 
 IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
diff --git a/depends/dbcommon/Makefile b/depends/dbcommon/Makefile
new file mode 100644
index 0000000..dd89703
--- /dev/null
+++ b/depends/dbcommon/Makefile
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+subdir = depends/dbcommon
+top_builddir = ../../
+include Makefile.global
+
+PRE_CFG_ARG =
+# get argument for running ../boostrap
+ifeq ($(enable_debug), yes)
+	PRE_CFG_ARG += --enable-debug
+endif # enable_debug
+
+ifeq ($(enable_coverage), yes)
+	PRE_CFG_ARG += --enable-coverage
+endif # enable_coverage
+
+##########################################################################
+#
+
+.PHONY: build all install distclean maintainer-clean clean pre-config
+
+ifeq ($(with_dbcommon), yes)
+
+# We will need to install it temporarily under build/install for hawq building.
+all: build
+	cd $(top_builddir)/$(subdir)/build; mkdir -p install; \
+	$(MAKE) DESTDIR=$(abs_top_builddir)/$(subdir)/build/install install
+
+install: build
+	cd $(top_builddir)/$(subdir)/build && $(MAKE) install
+
+distclean:
+	rm -rf $(top_builddir)/$(subdir)/build
+
+maintainer-clean: distclean
+
+clean:
+	if [ -d $(top_builddir)/$(subdir)/build ]; then \
+		cd $(top_builddir)/$(subdir)/build && $(MAKE) clean && rm -f dbcommon_build_timestamp; \
+	fi
+
+build: pre-config
+	cd $(top_builddir)/$(subdir)/build && $(MAKE)
+
+# trigger bootstrap only once.
+pre-config:
+	cd $(top_builddir)/$(subdir)/; \
+	mkdir -p build; \
+	cd build; \
+	if [ ! -f dbcommon_build_timestamp ]; then \
+		$(abs_top_srcdir)/$(subdir)/bootstrap --prefix=$(prefix) $(PRE_CFG_ARG) && touch dbcommon_build_timestamp; \
+	fi
+
+else
+all install distclean maintainer-clean clean pre-config:
+
+endif
diff --git a/depends/dbcommon/Makefile.global b/depends/dbcommon/Makefile.global
new file mode 100644
index 0000000..de78d01
--- /dev/null
+++ b/depends/dbcommon/Makefile.global
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+
+prefix := /usr/local/hawq
+enable_debug    = no
+enable_coverage = no
+with_dbcommon = yes
+
+# Support for VPATH builds
+vpath_build = no
+abs_top_srcdir = /Users/tuyu/hawq
+abs_top_builddir = /Users/tuyu/hawq
+
+ifneq ($(vpath_build),yes)
+top_srcdir = $(top_builddir)
+srcdir = .
+else # vpath_build = yes
+top_srcdir = $(abs_top_srcdir)
+srcdir = $(top_srcdir)/$(subdir)
+
+endif
diff --git a/depends/dbcommon/Makefile.global.in b/depends/dbcommon/Makefile.global.in
new file mode 100644
index 0000000..2d45b54
--- /dev/null
+++ b/depends/dbcommon/Makefile.global.in
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+
+prefix := @prefix@
+enable_debug    = @enable_debug@
+enable_coverage = @enable_coverage@
+with_dbcommon = @with_dbcommon@
+
+# Support for VPATH builds
+vpath_build = @vpath_build@
+abs_top_srcdir = @abs_top_srcdir@
+abs_top_builddir = @abs_top_builddir@
+
+ifneq ($(vpath_build),yes)
+top_srcdir = $(top_builddir)
+srcdir = .
+else # vpath_build = yes
+top_srcdir = $(abs_top_srcdir)
+srcdir = $(top_srcdir)/$(subdir)
+VPATH = $(srcdir)
+endif
diff --git a/depends/dbcommon/README b/depends/dbcommon/README
index 207ecb0..25582c5 100644
--- a/depends/dbcommon/README
+++ b/depends/dbcommon/README
@@ -3,7 +3,7 @@
     cd dbcommon
     mkdir build
     cd build
-    ../bootstrap --prefix=/opt/dependency/package (default)
+    ../bootstrap --prefix=/usr/local/hawq (default)
 
 ## Build
 
diff --git a/depends/dbcommon/bootstrap b/depends/dbcommon/bootstrap
index 1554c7b..51a8a24 100755
--- a/depends/dbcommon/bootstrap
+++ b/depends/dbcommon/bootstrap
@@ -1,20 +1,45 @@
-#!/bin/sh
-
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
 die() {
     echo "$@" 1>&2 ; exit 1
 }
 
-arg ()
-{
-    echo "$1" | sed "s/^${2-[^=]*=}//"
+arg () {
+    echo "$1" | sed "s/^${2-[^=]*=}//" | sed "s/:/;/g"
 }
 
+export CMAKE_INCLUDE_PATH=/usr/local/include
+export CMAKE_LIBRARY_PATH=/usr/local/lib
+
 # Detect directory information.
 source_dir=`cd "\`dirname \"$0\"\`";pwd`
 binary_dir=`pwd`
 
 # Choose the default install prefix.
-default_prefix="/opt/dependency/package"
+default_prefix=${source_dir}/dist
+
+# Choose the default dependency install prefix
+default_dependency=${DEPENDENCY_INSTALL_PREFIX}
+
+if [ x"${default_dependency}" = x"" ]; then
+    default_dependency="/opt/dependency"
+fi
 
 # Display bootstrap usage
 usage() {
@@ -25,27 +50,52 @@
     --help                          print this message
     --prefix=PREFIX                 install files in tree rooted at PREFIX
                                     ['"${default_prefix}"']
-    --enable-coverage               enable code coverage, must be used together with --enable-debug
+    --dependency=DIRs               specify the dependencies at DIRs, separated by colon
+                                    ['"${default_dependency}"']
     --enable-debug                  enable debug build
-    --enable-avx                    enable avx for vector instruction optimization
+    --enable-boost                  force to enable boost
+    --enable-coverage               enable build with code coverage support
+    --enable-libc++                 using libc++ instead of libstdc++, only valid for clang compiler
+
+Dependencies:
+    c/c++ compiler
+    GNU make
+    cmake           http://www.cmake.org/
+    protobuf        https://code.google.com/p/protobuf/
+    kerberos        http://web.mit.edu/kerberos/
+    libgsasl        http://www.gnu.org/software/gsasl/
+    libxml2         http://xmlsoft.org/
+    libuuid         http://sourceforge.net/projects/libuuid/
+    boost 1.53+     http://www.boost.org/
+                    [boost is not required if c++ compiler is g++ 4.6.0+ or clang++ with stdc++]
+
+Example:
+    mkdir build
+    cd build
+    ../bootstrap --prefix=/path/to/install --dependency=/path/to/protobuf:/path/to/kerberos/:path/to/others
+    make
+    make install
 '
     exit 10
 }
 
 # Parse arguments
-prefix_dir="${default_prefix}"
+prefix_dirs="${default_prefix}"
+dependency_dir="${default_dependency}"
 build_type="Release"
+enable_boost="OFF"
 enable_coverage="OFF"
-enable_avx="ON"
+enable_clang_lib="OFF"
 while test $# != 0; do
     case "$1" in
     --prefix=*) dir=`arg "$1"`
-                prefix_dir="$dir";;
-	--enable-coverage) enable_coverage="ON"
-                       build_type="Debug";;
-    --enable-debug) build_type="Debug";;
-    --enable-avx=*) avx=`arg "$1"`
-                    enable_avx="$avx";;
+                prefix_dirs="$dir";;
+    --dependency=*) dir=`arg "$1"`
+                dependency_dir="$dir";;
+    --enable-debug) enable_build="ON";;
+    --enable-boost) enable_boost="ON";;
+    --enable-coverage) enable_coverage="ON";;
+    --enable-libc++) enable_clang_lib="ON";;
     --help) usage ;;
     *) die "Unknown option: $1" ;;
     esac
@@ -53,12 +103,7 @@
 done
 
 if [ ${source_dir} = ${binary_dir} ]; then
-	die "cannot build the project in the source directory! Out-of-source build is enforced!"
-fi
-
-enable_avx_upper=`echo "${enable_avx}" | tr [a-z] [A-Z]`
-if [ ${enable_avx_upper} != "ON" ] && [ ${enable_avx_upper} != "OFF" ]; then
-    die "unknown value for option enable-avx: ${enable_avx}, valid options are: on and off"
+    die "cannot build the project in the source directory! Out-of-source build is enforced!"
 fi
 
 # Check clang compiler
@@ -74,19 +119,23 @@
 cxx_compiler=`which ${CXX}`
 cmake=`which cmake`
 
-if [ ! -x ${c_compiler} ]; then
+if [[ ! -x ${c_compiler} ]]; then
     die "cannot found c compiler"
 fi
 
-if [ ! -x ${cxx_compiler} ]; then
-    die "cannot found c++ compiler"
+if [[ ! -x ${cxx_compiler} ]]; then
+    die "cannot found cplusplus compiler"
 fi
 
-if [ ! -x ${cmake} ]; then
+if [[ ! -x ${cmake} ]]; then
     die "cannot found cmake"
 fi
 
 # Configure 
-${cmake} -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_INSTALL_PREFIX=${prefix_dir} -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} -DENABLE_COVERAGE=${enable_coverage} -DENABLE_AVX=${enable_avx_upper} ${source_dir} || die "failed to configure the project"
+${cmake} -DENABLE_DEBUG=${enable_build} -DCMAKE_INSTALL_PREFIX=${prefix_dirs} \
+    -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} \
+    -DCMAKE_PREFIX_PATH=${dependency_dir} -DENABLE_BOOST=${enable_boost} \
+    -DENABLE_COVERAGE=${enable_coverage} -DENABLE_LIBCPP=${enable_clang_lib} ${source_dir} \
+    || die "failed to configure the project"
 
 echo 'bootstrap success. Run "make" to build.'
diff --git a/depends/dbcommon/src/CMakeLists.txt b/depends/dbcommon/src/CMakeLists.txt
index d322580..67a1b57 100644
--- a/depends/dbcommon/src/CMakeLists.txt
+++ b/depends/dbcommon/src/CMakeLists.txt
@@ -107,10 +107,11 @@
 INCLUDE_DIRECTORIES(${dbcommon_ROOT_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/codegen/src)
 INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
+INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/include)
 INCLUDE_DIRECTORIES(/usr/local/include)
-LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/lib)
 LINK_DIRECTORIES(/usr/local/lib)
+LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../libhdfs3/build/install/usr/local/hawq/lib)
 
 ADD_LIBRARY(dbcommon-shared SHARED
         ${TEMPLATE_GENERATED_HEADERS}
diff --git a/depends/dbcommon/test/CMakeLists.txt b/depends/dbcommon/test/CMakeLists.txt
index 6552ff9..54d7599 100644
--- a/depends/dbcommon/test/CMakeLists.txt
+++ b/depends/dbcommon/test/CMakeLists.txt
@@ -8,10 +8,10 @@
 INCLUDE_DIRECTORIES(${dbcommon_ROOT_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/codegen/src)
 INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
+INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/include)
 
 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
-LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/lib)
 
 ADD_SUBDIRECTORY(unit)
 
diff --git a/depends/storage/CMake/FindJSON.cmake b/depends/storage/CMake/FindJSON.cmake
index a334948..ff5008b 100644
--- a/depends/storage/CMake/FindJSON.cmake
+++ b/depends/storage/CMake/FindJSON.cmake
@@ -20,7 +20,7 @@
 #  License text for the above reference.)
 
 # Look for the header file.
-find_path(JSON_INCLUDE_DIR NAMES json/json.h)
+find_path(JSON_INCLUDE_DIR NAMES json-c/json.h)
 mark_as_advanced(JSON_INCLUDE_DIR)
 
 # Look for the library (sorted from most current/relevant entry to least).
diff --git a/depends/storage/CMake/Options.cmake b/depends/storage/CMake/Options.cmake
index 36841ea..8be997e 100644
--- a/depends/storage/CMake/Options.cmake
+++ b/depends/storage/CMake/Options.cmake
@@ -5,7 +5,8 @@
 ##############################################################################
 # Setup build and dependencies information 
 ##############################################################################
-SET(DEPENDENCY_INSTALL_PREFIX "/opt/dependency")
+#SET(DEPENDENCY_INSTALL_PREFIX "/opt/dependency")
+SET(DEPENDENCY_INSTALL_PREFIX "/usr/local/hawq")
 IF($ENV{DEPENDENCY_INSTALL_PREFIX})
 	SET(DEPENDENCY_INSTALL_PREFIX $ENV{DEPENDENCY_INSTALL_PREFIX})
 ENDIF()
@@ -19,8 +20,10 @@
 SET(CMAKE_PREFIX_PATH "${DEPENDENCY_INSTALL_PREFIX}/package" ${CMAKE_PREFIX_PATH})
 SET(CMAKE_PREFIX_PATH "${DEPENDENCY_INSTALL_PREFIX}/tools" ${CMAKE_PREFIX_PATH})
 
-SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib:${DEPENDENCY_LIBRARY_PATH}")
-SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib64:${DEPENDENCY_LIBRARY_PATH}")
+#SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib:${DEPENDENCY_LIBRARY_PATH}")
+#SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib64:${DEPENDENCY_LIBRARY_PATH}")
+SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/lib:${DEPENDENCY_LIBRARY_PATH}")
+SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/lib64:${DEPENDENCY_LIBRARY_PATH}")
 
 ##############################################################################
 # Setup build flags
diff --git a/depends/storage/CMakeLists.txt b/depends/storage/CMakeLists.txt
index d2a64c6..e8eb968 100644
--- a/depends/storage/CMakeLists.txt
+++ b/depends/storage/CMakeLists.txt
@@ -1,10 +1,13 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 PROJECT(storage)
 
+SET(CMAKE_VERBOSE_MAKEFILE ON CACHE STRING "Verbose build." FORCE)
+
 ##############################################################################
 # General CMake initialization
 ##############################################################################
 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
+SET(DOXYFILE_PATH ${CMAKE_SOURCE_DIR}/docs)
 SET(CMAKE_VERBOSE_MAKEFILE OFF CACHE STRING "Verbose build." FORCE)
 
 IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
diff --git a/depends/storage/Makefile b/depends/storage/Makefile
new file mode 100644
index 0000000..3a2508e
--- /dev/null
+++ b/depends/storage/Makefile
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+subdir = depends/storage
+top_builddir = ../../
+include Makefile.global
+
+PRE_CFG_ARG =
+# get argument for running ../boostrap
+ifeq ($(enable_debug), yes)
+	PRE_CFG_ARG += --enable-debug
+endif # enable_debug
+
+ifeq ($(enable_coverage), yes)
+	PRE_CFG_ARG += --enable-coverage
+endif # enable_coverage
+
+##########################################################################
+#
+.PHONY: build all install distclean maintainer-clean clean pre-config
+
+ifeq ($(with_storage), yes)
+
+# We will need to install it temporarily under build/install for hawq building.
+all: build
+	cd $(top_builddir)/$(subdir)/build; mkdir -p install; \
+	$(MAKE) DESTDIR=$(abs_top_builddir)/$(subdir)/build/install install
+
+install: build
+	cd $(top_builddir)/$(subdir)/build && $(MAKE) install
+
+distclean:
+	rm -rf $(top_builddir)/$(subdir)/build
+
+maintainer-clean: distclean
+
+clean:
+	if [ -d $(top_builddir)/$(subdir)/build ]; then \
+		cd $(top_builddir)/$(subdir)/build && $(MAKE) clean && rm -f storage_build_timestamp; \
+	fi
+
+build: pre-config
+	cd $(top_builddir)/$(subdir)/build && $(MAKE)
+
+# trigger bootstrap only once.
+pre-config:
+	cd $(top_builddir)/$(subdir)/; \
+	mkdir -p build; \
+	cd build; \
+	if [ ! -f storage_build_timestamp ]; then \
+		$(abs_top_srcdir)/$(subdir)/bootstrap --prefix=$(prefix) $(PRE_CFG_ARG) && touch storage_build_timestamp; \
+	fi
+
+else
+
+all install distclean maintainer-clean clean pre-config:
+
+endif
diff --git a/depends/storage/Makefile.global b/depends/storage/Makefile.global
new file mode 100644
index 0000000..a2e43f1
--- /dev/null
+++ b/depends/storage/Makefile.global
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+
+prefix := /usr/local/hawq
+enable_debug    = no
+enable_coverage = no
+with_storage = yes
+
+# Support for VPATH builds
+vpath_build = no
+abs_top_srcdir = /Users/tuyu/hawq
+abs_top_builddir = /Users/tuyu/hawq
+
+ifneq ($(vpath_build),yes)
+top_srcdir = $(top_builddir)
+srcdir = .
+else # vpath_build = yes
+top_srcdir = $(abs_top_srcdir)
+srcdir = $(top_srcdir)/$(subdir)
+
+endif
diff --git a/depends/storage/Makefile.global.in b/depends/storage/Makefile.global.in
new file mode 100644
index 0000000..96791c3
--- /dev/null
+++ b/depends/storage/Makefile.global.in
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+
+prefix := @prefix@
+enable_debug    = @enable_debug@
+enable_coverage = @enable_coverage@
+with_storage = @with_storage@
+
+# Support for VPATH builds
+vpath_build = @vpath_build@
+abs_top_srcdir = @abs_top_srcdir@
+abs_top_builddir = @abs_top_builddir@
+
+ifneq ($(vpath_build),yes)
+top_srcdir = $(top_builddir)
+srcdir = .
+else # vpath_build = yes
+top_srcdir = $(abs_top_srcdir)
+srcdir = $(top_srcdir)/$(subdir)
+VPATH = $(srcdir)
+endif
diff --git a/depends/storage/README b/depends/storage/README
index f67eafe..86c7984 100644
--- a/depends/storage/README
+++ b/depends/storage/README
@@ -4,7 +4,7 @@
     cd storage
     mkdir build
     cd build
-    ../bootstrap --prefix=/opt/dependency/package (default)
+	../bootstrap --prefix=/usr/local/hawq (default)
 
 ## Build
 
diff --git a/depends/storage/bootstrap b/depends/storage/bootstrap
index 36fd66c..51a8a24 100755
--- a/depends/storage/bootstrap
+++ b/depends/storage/bootstrap
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,22 +16,30 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-
 die() {
     echo "$@" 1>&2 ; exit 1
 }
 
-arg ()
-{
-    echo "$1" | sed "s/^${2-[^=]*=}//"
+arg () {
+    echo "$1" | sed "s/^${2-[^=]*=}//" | sed "s/:/;/g"
 }
 
+export CMAKE_INCLUDE_PATH=/usr/local/include
+export CMAKE_LIBRARY_PATH=/usr/local/lib
+
 # Detect directory information.
 source_dir=`cd "\`dirname \"$0\"\`";pwd`
 binary_dir=`pwd`
 
 # Choose the default install prefix.
-default_prefix="/opt/dependency/package"
+default_prefix=${source_dir}/dist
+
+# Choose the default dependency install prefix
+default_dependency=${DEPENDENCY_INSTALL_PREFIX}
+
+if [ x"${default_dependency}" = x"" ]; then
+    default_dependency="/opt/dependency"
+fi
 
 # Display bootstrap usage
 usage() {
@@ -42,27 +50,52 @@
     --help                          print this message
     --prefix=PREFIX                 install files in tree rooted at PREFIX
                                     ['"${default_prefix}"']
-    --enable-coverage               enable code coverage, must be used together with --enable-debug
+    --dependency=DIRs               specify the dependencies at DIRs, separated by colon
+                                    ['"${default_dependency}"']
     --enable-debug                  enable debug build
-    --enable-avx                    enable avx for vector instruction optimization
+    --enable-boost                  force to enable boost
+    --enable-coverage               enable build with code coverage support
+    --enable-libc++                 using libc++ instead of libstdc++, only valid for clang compiler
+
+Dependencies:
+    c/c++ compiler
+    GNU make
+    cmake           http://www.cmake.org/
+    protobuf        https://code.google.com/p/protobuf/
+    kerberos        http://web.mit.edu/kerberos/
+    libgsasl        http://www.gnu.org/software/gsasl/
+    libxml2         http://xmlsoft.org/
+    libuuid         http://sourceforge.net/projects/libuuid/
+    boost 1.53+     http://www.boost.org/
+                    [boost is not required if c++ compiler is g++ 4.6.0+ or clang++ with stdc++]
+
+Example:
+    mkdir build
+    cd build
+    ../bootstrap --prefix=/path/to/install --dependency=/path/to/protobuf:/path/to/kerberos/:path/to/others
+    make
+    make install
 '
     exit 10
 }
 
 # Parse arguments
-prefix_dir="${default_prefix}"
+prefix_dirs="${default_prefix}"
+dependency_dir="${default_dependency}"
 build_type="Release"
+enable_boost="OFF"
 enable_coverage="OFF"
-enable_avx="ON"
+enable_clang_lib="OFF"
 while test $# != 0; do
     case "$1" in
     --prefix=*) dir=`arg "$1"`
-                prefix_dir="$dir";;
-	--enable-coverage) enable_coverage="ON"
-                       build_type="Debug";;
-    --enable-debug) build_type="Debug";;
-    --enable-avx=*) avx=`arg "$1"`
-                    enable_avx="$avx";;
+                prefix_dirs="$dir";;
+    --dependency=*) dir=`arg "$1"`
+                dependency_dir="$dir";;
+    --enable-debug) enable_build="ON";;
+    --enable-boost) enable_boost="ON";;
+    --enable-coverage) enable_coverage="ON";;
+    --enable-libc++) enable_clang_lib="ON";;
     --help) usage ;;
     *) die "Unknown option: $1" ;;
     esac
@@ -70,12 +103,7 @@
 done
 
 if [ ${source_dir} = ${binary_dir} ]; then
-	die "cannot build the project in the source directory! Out-of-source build is enforced!"
-fi
-
-enable_avx_upper=`echo "${enable_avx}" | tr [a-z] [A-Z]`
-if [ ${enable_avx_upper} != "ON" ] && [ ${enable_avx_upper} != "OFF" ]; then
-    die "unknown value for option enable-avx: ${enable_avx}, valid options are: on and off"
+    die "cannot build the project in the source directory! Out-of-source build is enforced!"
 fi
 
 # Check clang compiler
@@ -91,19 +119,23 @@
 cxx_compiler=`which ${CXX}`
 cmake=`which cmake`
 
-if [ ! -x ${c_compiler} ]; then
+if [[ ! -x ${c_compiler} ]]; then
     die "cannot found c compiler"
 fi
 
-if [ ! -x ${cxx_compiler} ]; then
-    die "cannot found c++ compiler"
+if [[ ! -x ${cxx_compiler} ]]; then
+    die "cannot found cplusplus compiler"
 fi
 
-if [ ! -x ${cmake} ]; then
+if [[ ! -x ${cmake} ]]; then
     die "cannot found cmake"
 fi
 
 # Configure 
-${cmake} -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_INSTALL_PREFIX=${prefix_dir} -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} -DENABLE_COVERAGE=${enable_coverage} -DENABLE_AVX=${enable_avx_upper} ${source_dir} || die "failed to configure the project"
+${cmake} -DENABLE_DEBUG=${enable_build} -DCMAKE_INSTALL_PREFIX=${prefix_dirs} \
+    -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} \
+    -DCMAKE_PREFIX_PATH=${dependency_dir} -DENABLE_BOOST=${enable_boost} \
+    -DENABLE_COVERAGE=${enable_coverage} -DENABLE_LIBCPP=${enable_clang_lib} ${source_dir} \
+    || die "failed to configure the project"
 
 echo 'bootstrap success. Run "make" to build.'
diff --git a/depends/storage/src/CMakeLists.txt b/depends/storage/src/CMakeLists.txt
index dd7ed3b..dd6f1ac 100644
--- a/depends/storage/src/CMakeLists.txt
+++ b/depends/storage/src/CMakeLists.txt
@@ -42,11 +42,16 @@
 AUTO_SOURCES(testutil_HEADER "*.h" "${storage_SRC_DIR}/testutil")
 
 INCLUDE_DIRECTORIES(${storage_ROOT_DIR})
-INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
+#INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
+INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/include)
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
 INCLUDE_DIRECTORIES(/usr/local/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../univplan/build/install/usr/local/hawq/include)
 LINK_DIRECTORIES(/usr/local/lib)
-LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+#LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/lib)
+LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../libhdfs3/build/install/usr/local/hawq/lib)
+LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../univplan/build/install/usr/local/hawq/lib)
 
 
 ADD_LIBRARY(storage-shared SHARED ${storage_SOURCES} ${storage_PROTO_SRCS} ${storage_PROTO_HDRS})
diff --git a/depends/storage/test/CMakeLists.txt b/depends/storage/test/CMakeLists.txt
index 2092b56..94b7b7e 100644
--- a/depends/storage/test/CMakeLists.txt
+++ b/depends/storage/test/CMakeLists.txt
@@ -7,7 +7,7 @@
 
 INCLUDE_DIRECTORIES(${storage_ROOT_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
-INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
+INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/include)
 INCLUDE_DIRECTORIES(/usr/local/include)
 LINK_DIRECTORIES(/usr/local/lib)
 
diff --git a/depends/storage/test/unit/CMakeLists.txt b/depends/storage/test/unit/CMakeLists.txt
index e57aaeb..f922dce 100644
--- a/depends/storage/test/unit/CMakeLists.txt
+++ b/depends/storage/test/unit/CMakeLists.txt
@@ -14,7 +14,7 @@
 INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
 
 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
-LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/lib)
 
 ADD_EXECUTABLE(unit EXCLUDE_FROM_ALL
     ${unit_SOURCES}
diff --git a/depends/univplan/CMake/FindJSON.cmake b/depends/univplan/CMake/FindJSON.cmake
index a334948..ff5008b 100644
--- a/depends/univplan/CMake/FindJSON.cmake
+++ b/depends/univplan/CMake/FindJSON.cmake
@@ -20,7 +20,7 @@
 #  License text for the above reference.)
 
 # Look for the header file.
-find_path(JSON_INCLUDE_DIR NAMES json/json.h)
+find_path(JSON_INCLUDE_DIR NAMES json-c/json.h)
 mark_as_advanced(JSON_INCLUDE_DIR)
 
 # Look for the library (sorted from most current/relevant entry to least).
diff --git a/depends/univplan/CMake/Options.cmake b/depends/univplan/CMake/Options.cmake
index 36841ea..8be997e 100644
--- a/depends/univplan/CMake/Options.cmake
+++ b/depends/univplan/CMake/Options.cmake
@@ -5,7 +5,8 @@
 ##############################################################################
 # Setup build and dependencies information 
 ##############################################################################
-SET(DEPENDENCY_INSTALL_PREFIX "/opt/dependency")
+#SET(DEPENDENCY_INSTALL_PREFIX "/opt/dependency")
+SET(DEPENDENCY_INSTALL_PREFIX "/usr/local/hawq")
 IF($ENV{DEPENDENCY_INSTALL_PREFIX})
 	SET(DEPENDENCY_INSTALL_PREFIX $ENV{DEPENDENCY_INSTALL_PREFIX})
 ENDIF()
@@ -19,8 +20,10 @@
 SET(CMAKE_PREFIX_PATH "${DEPENDENCY_INSTALL_PREFIX}/package" ${CMAKE_PREFIX_PATH})
 SET(CMAKE_PREFIX_PATH "${DEPENDENCY_INSTALL_PREFIX}/tools" ${CMAKE_PREFIX_PATH})
 
-SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib:${DEPENDENCY_LIBRARY_PATH}")
-SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib64:${DEPENDENCY_LIBRARY_PATH}")
+#SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib:${DEPENDENCY_LIBRARY_PATH}")
+#SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/package/lib64:${DEPENDENCY_LIBRARY_PATH}")
+SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/lib:${DEPENDENCY_LIBRARY_PATH}")
+SET(DEPENDENCY_LIBRARY_PATH "${DEPENDENCY_INSTALL_PREFIX}/lib64:${DEPENDENCY_LIBRARY_PATH}")
 
 ##############################################################################
 # Setup build flags
diff --git a/depends/univplan/CMakeLists.txt b/depends/univplan/CMakeLists.txt
index f25ad2c..789ec87 100644
--- a/depends/univplan/CMakeLists.txt
+++ b/depends/univplan/CMakeLists.txt
@@ -1,10 +1,13 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 PROJECT(univplan)
 
+SET(CMAKE_VERBOSE_MAKEFILE ON CACHE STRING "Verbose build." FORCE)
+
 ##############################################################################
 # General CMake initialization
 ##############################################################################
 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
+SET(DOXYFILE_PATH ${CMAKE_SOURCE_DIR}/docs)
 SET(CMAKE_VERBOSE_MAKEFILE OFF CACHE STRING "Verbose build." FORCE)
 
 IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
diff --git a/depends/univplan/Makefile b/depends/univplan/Makefile
new file mode 100644
index 0000000..b0c6f47
--- /dev/null
+++ b/depends/univplan/Makefile
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+subdir = depends/univplan
+top_builddir = ../../
+include Makefile.global
+
+PRE_CFG_ARG =
+# get argument for running ../boostrap
+ifeq ($(enable_debug), yes)
+	PRE_CFG_ARG += --enable-debug
+endif # enable_debug
+
+ifeq ($(enable_coverage), yes)
+	PRE_CFG_ARG += --enable-coverage
+endif # enable_coverage
+
+##########################################################################
+#
+.PHONY: build all install distclean maintainer-clean clean pre-config
+
+ifeq ($(with_univplan), yes)
+
+# We will need to install it temporarily under build/install for hawq building.
+all: build
+	cd $(top_builddir)/$(subdir)/build; mkdir -p install; \
+	$(MAKE) DESTDIR=$(abs_top_builddir)/$(subdir)/build/install install
+
+install: build
+	cd $(top_builddir)/$(subdir)/build && $(MAKE) install
+
+distclean:
+	rm -rf $(top_builddir)/$(subdir)/build
+
+maintainer-clean: distclean
+
+clean:
+	if [ -d $(top_builddir)/$(subdir)/build ]; then \
+		cd $(top_builddir)/$(subdir)/build && $(MAKE) clean && rm -f univplan_build_timestamp; \
+	fi
+
+build: pre-config
+	cd $(top_builddir)/$(subdir)/build && $(MAKE)
+
+# trigger bootstrap only once.
+pre-config:
+	cd $(top_builddir)/$(subdir)/; \
+	mkdir -p build; \
+	cd build; \
+	if [ ! -f univplan_build_timestamp ]; then \
+		$(abs_top_srcdir)/$(subdir)/bootstrap --prefix=$(prefix) $(PRE_CFG_ARG) && touch univplan_build_timestamp; \
+	fi
+
+else
+
+all install distclean maintainer-clean clean pre-config:
+
+endif
diff --git a/depends/univplan/Makefile.global b/depends/univplan/Makefile.global
new file mode 100644
index 0000000..a981862
--- /dev/null
+++ b/depends/univplan/Makefile.global
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+
+prefix := /usr/local/hawq
+enable_debug    = no
+enable_coverage = no
+with_univplan = yes
+
+# Support for VPATH builds
+vpath_build = no
+abs_top_srcdir = /Users/tuyu/hawq
+abs_top_builddir = /Users/tuyu/hawq
+
+ifneq ($(vpath_build),yes)
+top_srcdir = $(top_builddir)
+srcdir = .
+else # vpath_build = yes
+top_srcdir = $(abs_top_srcdir)
+srcdir = $(top_srcdir)/$(subdir)
+
+endif
diff --git a/depends/univplan/Makefile.global.in b/depends/univplan/Makefile.global.in
new file mode 100644
index 0000000..07bacea
--- /dev/null
+++ b/depends/univplan/Makefile.global.in
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -*-makefile-*-
+#------------------------------------------------------------------------------
+# A makefile that integrate building this module with hawq
+#------------------------------------------------------------------------------
+
+prefix := @prefix@
+enable_debug    = @enable_debug@
+enable_coverage = @enable_coverage@
+with_univplan = @with_univplan@
+
+# Support for VPATH builds
+vpath_build = @vpath_build@
+abs_top_srcdir = @abs_top_srcdir@
+abs_top_builddir = @abs_top_builddir@
+
+ifneq ($(vpath_build),yes)
+top_srcdir = $(top_builddir)
+srcdir = .
+else # vpath_build = yes
+top_srcdir = $(abs_top_srcdir)
+srcdir = $(top_srcdir)/$(subdir)
+VPATH = $(srcdir)
+endif
diff --git a/depends/univplan/bootstrap b/depends/univplan/bootstrap
index 36fd66c..51a8a24 100755
--- a/depends/univplan/bootstrap
+++ b/depends/univplan/bootstrap
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,22 +16,30 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-
 die() {
     echo "$@" 1>&2 ; exit 1
 }
 
-arg ()
-{
-    echo "$1" | sed "s/^${2-[^=]*=}//"
+arg () {
+    echo "$1" | sed "s/^${2-[^=]*=}//" | sed "s/:/;/g"
 }
 
+export CMAKE_INCLUDE_PATH=/usr/local/include
+export CMAKE_LIBRARY_PATH=/usr/local/lib
+
 # Detect directory information.
 source_dir=`cd "\`dirname \"$0\"\`";pwd`
 binary_dir=`pwd`
 
 # Choose the default install prefix.
-default_prefix="/opt/dependency/package"
+default_prefix=${source_dir}/dist
+
+# Choose the default dependency install prefix
+default_dependency=${DEPENDENCY_INSTALL_PREFIX}
+
+if [ x"${default_dependency}" = x"" ]; then
+    default_dependency="/opt/dependency"
+fi
 
 # Display bootstrap usage
 usage() {
@@ -42,27 +50,52 @@
     --help                          print this message
     --prefix=PREFIX                 install files in tree rooted at PREFIX
                                     ['"${default_prefix}"']
-    --enable-coverage               enable code coverage, must be used together with --enable-debug
+    --dependency=DIRs               specify the dependencies at DIRs, separated by colon
+                                    ['"${default_dependency}"']
     --enable-debug                  enable debug build
-    --enable-avx                    enable avx for vector instruction optimization
+    --enable-boost                  force to enable boost
+    --enable-coverage               enable build with code coverage support
+    --enable-libc++                 using libc++ instead of libstdc++, only valid for clang compiler
+
+Dependencies:
+    c/c++ compiler
+    GNU make
+    cmake           http://www.cmake.org/
+    protobuf        https://code.google.com/p/protobuf/
+    kerberos        http://web.mit.edu/kerberos/
+    libgsasl        http://www.gnu.org/software/gsasl/
+    libxml2         http://xmlsoft.org/
+    libuuid         http://sourceforge.net/projects/libuuid/
+    boost 1.53+     http://www.boost.org/
+                    [boost is not required if c++ compiler is g++ 4.6.0+ or clang++ with stdc++]
+
+Example:
+    mkdir build
+    cd build
+    ../bootstrap --prefix=/path/to/install --dependency=/path/to/protobuf:/path/to/kerberos/:path/to/others
+    make
+    make install
 '
     exit 10
 }
 
 # Parse arguments
-prefix_dir="${default_prefix}"
+prefix_dirs="${default_prefix}"
+dependency_dir="${default_dependency}"
 build_type="Release"
+enable_boost="OFF"
 enable_coverage="OFF"
-enable_avx="ON"
+enable_clang_lib="OFF"
 while test $# != 0; do
     case "$1" in
     --prefix=*) dir=`arg "$1"`
-                prefix_dir="$dir";;
-	--enable-coverage) enable_coverage="ON"
-                       build_type="Debug";;
-    --enable-debug) build_type="Debug";;
-    --enable-avx=*) avx=`arg "$1"`
-                    enable_avx="$avx";;
+                prefix_dirs="$dir";;
+    --dependency=*) dir=`arg "$1"`
+                dependency_dir="$dir";;
+    --enable-debug) enable_build="ON";;
+    --enable-boost) enable_boost="ON";;
+    --enable-coverage) enable_coverage="ON";;
+    --enable-libc++) enable_clang_lib="ON";;
     --help) usage ;;
     *) die "Unknown option: $1" ;;
     esac
@@ -70,12 +103,7 @@
 done
 
 if [ ${source_dir} = ${binary_dir} ]; then
-	die "cannot build the project in the source directory! Out-of-source build is enforced!"
-fi
-
-enable_avx_upper=`echo "${enable_avx}" | tr [a-z] [A-Z]`
-if [ ${enable_avx_upper} != "ON" ] && [ ${enable_avx_upper} != "OFF" ]; then
-    die "unknown value for option enable-avx: ${enable_avx}, valid options are: on and off"
+    die "cannot build the project in the source directory! Out-of-source build is enforced!"
 fi
 
 # Check clang compiler
@@ -91,19 +119,23 @@
 cxx_compiler=`which ${CXX}`
 cmake=`which cmake`
 
-if [ ! -x ${c_compiler} ]; then
+if [[ ! -x ${c_compiler} ]]; then
     die "cannot found c compiler"
 fi
 
-if [ ! -x ${cxx_compiler} ]; then
-    die "cannot found c++ compiler"
+if [[ ! -x ${cxx_compiler} ]]; then
+    die "cannot found cplusplus compiler"
 fi
 
-if [ ! -x ${cmake} ]; then
+if [[ ! -x ${cmake} ]]; then
     die "cannot found cmake"
 fi
 
 # Configure 
-${cmake} -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_INSTALL_PREFIX=${prefix_dir} -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} -DENABLE_COVERAGE=${enable_coverage} -DENABLE_AVX=${enable_avx_upper} ${source_dir} || die "failed to configure the project"
+${cmake} -DENABLE_DEBUG=${enable_build} -DCMAKE_INSTALL_PREFIX=${prefix_dirs} \
+    -DCMAKE_C_COMPILER=${c_compiler} -DCMAKE_CXX_COMPILER=${cxx_compiler} \
+    -DCMAKE_PREFIX_PATH=${dependency_dir} -DENABLE_BOOST=${enable_boost} \
+    -DENABLE_COVERAGE=${enable_coverage} -DENABLE_LIBCPP=${enable_clang_lib} ${source_dir} \
+    || die "failed to configure the project"
 
 echo 'bootstrap success. Run "make" to build.'
diff --git a/depends/univplan/src/CMakeLists.txt b/depends/univplan/src/CMakeLists.txt
index f53e3a7..ffc4380 100644
--- a/depends/univplan/src/CMakeLists.txt
+++ b/depends/univplan/src/CMakeLists.txt
@@ -44,9 +44,10 @@
 
 INCLUDE_DIRECTORIES(${univplan_ROOT_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
-INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
-
-LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/include)
+INCLUDE_DIRECTORIES(/usr/local/include)
+LINK_DIRECTORIES(/usr/local/lib)
+LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/lib)
 
 
 ADD_LIBRARY(univplan-shared SHARED
diff --git a/depends/univplan/test/CMakeLists.txt b/depends/univplan/test/CMakeLists.txt
index 088ab7f..a98bb5b 100644
--- a/depends/univplan/test/CMakeLists.txt
+++ b/depends/univplan/test/CMakeLists.txt
@@ -7,10 +7,10 @@
 
 INCLUDE_DIRECTORIES(${univplan_ROOT_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
-INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/include)
+INCLUDE_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/include)
 
 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
-LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/package/lib)
+LINK_DIRECTORIES(${DEPENDENCY_INSTALL_PREFIX}/lib)
 
 ADD_SUBDIRECTORY(unit)