Add gflags ports

This is a prerequisite of some of the grpc tests

Review URL: https://codereview.chromium.org/1651613002
diff --git a/docs/port_list.md b/docs/port_list.md
index 3b49173..5131151 100644
--- a/docs/port_list.md
+++ b/docs/port_list.md
@@ -106,6 +106,7 @@
 | [gdk-pixbuf]              | 2.30.8          | [gdk-pixbuf-2.30.8.tar.xz][gdk-pixbuf_upstream] |                      | [] | [] |
 | [gegl]                    | 0.2.0           | [gegl-0.2.0.tar.bz2][gegl_upstream]           |                      | [] | [] |
 | [gettext]                 | 0.19.2          | [gettext-0.19.2.tar.xz][gettext_upstream]     | [4 KiB][gettext_patch] | [] | [] |
+| [gflags]                  | 2.1.2           | [gflags-2.1.2.tar.gz][gflags_upstream]        | [583 B][gflags_patch] | [] | [] |
 | [gforth]                  | 0.7.2           | [gforth-0.7.2.tar.gz][gforth_upstream]        | [9 KiB][gforth_patch] | [] | [] |
 | [giflib]                  | 4.2.1           | [giflib-4.2.1.tar.bz2][giflib_upstream]       |                      | [] | [] |
 | [gimp]                    | 2.8.14          | [gimp-2.8.14.tar.bz2][gimp_upstream]          | [937 B][gimp_patch]  | [] | [] |
@@ -311,7 +312,7 @@
 | [zeromq]                  | 4.0.3           | [zeromq-4.0.3.tar.gz][zeromq_upstream]        | [4 KiB][zeromq_patch] | [] | [] |
 | [zlib]                    | 1.2.8           | [zlib-1.2.8.tar.gz][zlib_upstream]            | [592 B][zlib_patch]  | [] | [] |
 
-_Total = 321_
+_Total = 322_
 
 # Local Ports (not based on upstream sources) =
 
@@ -582,6 +583,9 @@
 [gettext_patch]: https://chromium.googlesource.com/webports/+/master/ports/gettext/nacl.patch
 [gettext_upstream]: http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.2.tar.xz
 [geturl]: https://chromium.googlesource.com/webports/+/master/ports/geturl
+[gflags]: https://chromium.googlesource.com/webports/+/master/ports/gflags
+[gflags_patch]: https://chromium.googlesource.com/webports/+/master/ports/gflags/nacl.patch
+[gflags_upstream]: https://github.com/gflags/gflags/archive/v2.1.2/gflags-2.1.2.tar.gz
 [gforth]: https://chromium.googlesource.com/webports/+/master/ports/gforth
 [gforth_patch]: https://chromium.googlesource.com/webports/+/master/ports/gforth/nacl.patch
 [gforth_upstream]: http://www.complang.tuwien.ac.at/forth/gforth/gforth-0.7.2.tar.gz
diff --git a/ports/gflags/build.sh b/ports/gflags/build.sh
new file mode 100644
index 0000000..ae8247f
--- /dev/null
+++ b/ports/gflags/build.sh
@@ -0,0 +1,7 @@
+# Copyright 2016 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if [[ $TOOLCHAIN == emscripten ]]; then
+  EXTRA_CMAKE_ARGS+=" -DBUILD_gflags_LIB=OFF"
+fi
diff --git a/ports/gflags/nacl.patch b/ports/gflags/nacl.patch
new file mode 100644
index 0000000..e40f93f
--- /dev/null
+++ b/ports/gflags/nacl.patch
@@ -0,0 +1,12 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -293,7 +293,7 @@ foreach (TYPE IN ITEMS STATIC SHARED)
+       if (BUILD_gflags${opts}_LIB)
+         add_library (gflags${opts}-${type} ${TYPE} ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
+         if (opts MATCHES "nothreads")
+-          set (defines "GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL};NOTHREADS")
++          set (defines "GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL};NO_THREADS")
+         else ()
+           set (defines "GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL}")
+           if (CMAKE_USE_PTHREADS_INIT)
diff --git a/ports/gflags/pkg_info b/ports/gflags/pkg_info
new file mode 100644
index 0000000..b13a56b
--- /dev/null
+++ b/ports/gflags/pkg_info
@@ -0,0 +1,7 @@
+NAME=gflags
+VERSION=2.1.2
+URL=https://github.com/gflags/gflags/archive/v2.1.2/gflags-2.1.2.tar.gz
+LICENSE=BSD
+SHA1=8bdbade9d041339dc14b4ab426e2354a5af38478
+# https://bugs.chromium.org/p/naclports/issues/detail?id=243
+DISABLED_TOOLCHAIN=(emscripten)