Merge branch 'master' of github.com:grpc/grpc into freebsd
diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h
index 41185db..034de5b 100644
--- a/include/grpc/support/port_platform.h
+++ b/include/grpc/support/port_platform.h
@@ -152,6 +152,30 @@
 #else /* _LP64 */
 #define GPR_ARCH_32 1
 #endif /* _LP64 */
+#elif defined(__FreeBSD__)
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define GPR_CPU_POSIX 1
+#define GPR_GCC_ATOMIC 1
+#define GPR_POSIX_LOG 1
+#define GPR_POSIX_MULTIPOLL_WITH_POLL 1
+#define GPR_POSIX_WAKEUP_FD 1
+#define GPR_POSIX_NO_SPECIAL_WAKEUP_FD 1
+#define GPR_POSIX_SOCKET 1
+#define GPR_POSIX_SOCKETADDR 1
+#define GPR_POSIX_SOCKETUTILS 1
+#define GPR_POSIX_ENV 1
+#define GPR_POSIX_FILE 1
+#define GPR_POSIX_STRING 1
+#define GPR_POSIX_SYNC 1
+#define GPR_POSIX_TIME 1
+#define GPR_GETPID_IN_UNISTD_H 1
+#ifdef _LP64
+#define GPR_ARCH_64 1
+#else /* _LP64 */
+#define GPR_ARCH_32 1
+#endif /* _LP64 */
 #else
 #error Could not auto-detect platform
 #endif
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index 6b80ee1..1c02c4b 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -38,6 +38,7 @@
 #include <grpc/support/time.h>
 #include "test/core/util/test_config.h"
 
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <string.h>
 #include <unistd.h>
diff --git a/tools/buildgen/generate_projects.sh b/tools/buildgen/generate_projects.sh
index 7a12440..45f08df 100755
--- a/tools/buildgen/generate_projects.sh
+++ b/tools/buildgen/generate_projects.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Copyright 2015, Google Inc.
 # All rights reserved.
 #
@@ -31,7 +31,7 @@
 
 set -e
 
-if [ "x$TEST" == "x" ] ; then
+if [ "x$TEST" = "x" ] ; then
   TEST=false
 fi
 
@@ -61,12 +61,12 @@
     out=${out%.*}  # strip template extension
     json_files="build.json $end2end_test_build"
     data=`for i in $json_files; do echo -n "-d $i "; done`
-    if [ $TEST == true ] ; then
+    if [ "x$TEST" = "xtrue" ] ; then
       actual_out=$out
       out=`mktemp /tmp/gentXXXXXX`
     fi
     $mako_renderer $plugins $data -o $out $file
-    if [ $TEST == true ] ; then
+    if [ "x$TEST" = "xtrue" ] ; then
       diff -q $out $actual_out
       rm $out
     fi
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 3cf6ddf..14ee179 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.7
+#!/usr/bin/env python
 # Copyright 2015, Google Inc.
 # All rights reserved.
 #