Index: Makefile
--- Makefile.orig	2016-08-11 16:33:30.000000000 +0200
+++ Makefile	2016-08-11 22:53:16.412084862 +0200
@@ -59,8 +59,8 @@
 	doc/bench/db_bench_sqlite3 \
 	doc/bench/db_bench_tree_db
 
-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
-CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
+CFLAGS += -I. -I./include $(CPPFLAGS) $(PLATFORM_CCFLAGS) $(OPT)
+CXXFLAGS += -I. -I./include $(CPPFLAGS) $(PLATFORM_CXXFLAGS) $(OPT)
 
 LDFLAGS += $(PLATFORM_LDFLAGS)
 LIBS += $(PLATFORM_LIBS)
@@ -138,7 +138,7 @@
 
 endif  # PLATFORM_SHARED_EXT
 
-all: $(SHARED_LIBS) $(SHARED_PROGRAMS) $(STATIC_OUTDIR)/libleveldb.a $(STATIC_OUTDIR)/libmemenv.a $(STATIC_PROGRAMS)
+all: $(STATIC_OUTDIR)/libleveldb.a $(STATIC_OUTDIR)/libmemenv.a $(STATIC_PROGRAMS)
 
 check: $(STATIC_PROGRAMS)
 	for t in $(notdir $(TESTS)); do echo "***** Running $$t"; $(STATIC_OUTDIR)/$$t || exit 1; done
Index: build_detect_platform
--- build_detect_platform.orig	2016-08-11 16:33:30.000000000 +0200
+++ build_detect_platform	2016-08-11 22:52:04.042104180 +0200
@@ -179,7 +179,7 @@
 
     # If -std=c++0x works, use <atomic> as fallback for when memory barriers
     # are not available.
-    $CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null  <<EOF
+    $CXX $CXXFLAGS $CPPFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null  <<EOF
       #include <atomic>
       int main() {}
 EOF
@@ -192,7 +192,7 @@
 
     # Test whether Snappy library is installed
     # http://code.google.com/p/snappy/
-    $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT 2>/dev/null  <<EOF
+    $CXX $CXXFLAGS $CPPFLAGS -x c++ - -o $CXXOUTPUT 2>/dev/null  <<EOF
       #include <snappy.h>
       int main() {}
 EOF
@@ -202,7 +202,7 @@
     fi
 
     # Test whether tcmalloc is available
-    $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null  <<EOF
+    $CXX $CXXFLAGS $CPPFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null  <<EOF
       int main() {}
 EOF
     if [ "$?" = 0 ]; then
