[iperf] Enable building iperf3 on Linux host.

This ensures we have iperf3 available on host for end-to-end tests.

Change-Id: Id8da2507c189bd5c7d44f789666710f450973db0
diff --git a/BUILD.gn b/BUILD.gn
index 29779e6..3fe3ca8 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -27,9 +27,22 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import("//build/host.gni")
 import("//build/package.gni")
 
-package("iperf") {
+group("iperf") {
+  deps = [ ":iperf3" ]
+  # TODO(https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=48350):
+  # Enable host build for non-linux hosts as well.
+  #
+  # Note that for convenience, on Linux host, we are compiling iperf3 with
+  # src/iperf_config.h used in Fuchsia build.
+  if (host_os == "linux") {
+    deps += [ ":host_tools" ]
+  }
+}
+
+package("iperf3") {
   meta = [
     {
       path = "meta/iperf3.cmx"
@@ -37,7 +50,7 @@
     },
   ]
 
-  deps = [ ":iperf3" ]
+  deps = [ ":bin" ]
 
   binaries = [
     {
@@ -57,7 +70,8 @@
   public_deps = [ "//zircon/public/lib/fdio" ]
 }
 
-executable("iperf3") {
+executable("bin") {
+  output_name = "iperf3"
   sources = [
     "src/cjson.c",
     "src/dscp.c",
@@ -88,6 +102,14 @@
     "-Wno-pointer-sign",
     "-Wno-sign-compare",
   ]
-  libs = [ "zircon" ]
-  deps = [ ":fuchsia-compat" ]
+  if (is_fuchsia) {
+    libs = [ "zircon" ]
+    deps = [ ":fuchsia-compat" ]
+  }
+}
+
+install_host_tools("host_tools") {
+  deps = [ ":bin" ]
+
+  outputs = [ "iperf3" ]
 }