From ea21ca234c01be8fc95c1fed0a2ea264773208db Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Mon, 4 Jan 2016 12:34:29 -0800
Subject: [PATCH] Fix makefile, codegen bugs

---
 Makefile                                                     | 5 ++++-
 templates/Makefile.template                                  | 5 ++++-
 .../test/core/surface/public_headers_must_be_c89.c.template  | 3 ++-
 test/core/surface/public_headers_must_be_c89.c               | 2 --
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 2d560a7dce..3e17186952 100644
--- a/Makefile
+++ b/Makefile
@@ -11459,7 +11459,10 @@ $(BINDIR)/$(CONFIG)/public_headers_must_be_c89: $(PUBLIC_HEADERS_MUST_BE_C89_OBJ
 endif
 
 $(OBJDIR)/$(CONFIG)/test/core/surface/public_headers_must_be_c89.o:  $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
-$(OBJDIR)/$(CONFIG)/test/core/surface/public_headers_must_be_c89.o: CFLAGS := $(CFLAGS) -std=c89
+$(OBJDIR)/$(CONFIG)/test/core/surface/public_headers_must_be_c89.o : test/core/surface/public_headers_must_be_c89.c
+	$(E) "[C]       Compiling $<"
+	$(Q) mkdir -p `dirname $@`
+	$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
 
 deps_public_headers_must_be_c89: $(PUBLIC_HEADERS_MUST_BE_C89_OBJS:.o=.dep)
 
diff --git a/templates/Makefile.template b/templates/Makefile.template
index 435b4079cb..07dec93f38 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -1860,7 +1860,10 @@
 
   % if tgt.language == 'c89':
   % for src in tgt.src:
-  $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: CFLAGS := <%text>$(CFLAGS)</%text> -std=c89
+  $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
+  	$(E) "[C]       Compiling $<"
+  	$(Q) mkdir -p `dirname $@`
+  	$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
   % endfor
   % endif
 
diff --git a/templates/test/core/surface/public_headers_must_be_c89.c.template b/templates/test/core/surface/public_headers_must_be_c89.c.template
index 942e355313..aff4ac5bcc 100644
--- a/templates/test/core/surface/public_headers_must_be_c89.c.template
+++ b/templates/test/core/surface/public_headers_must_be_c89.c.template
@@ -35,7 +35,8 @@
 
   <%
   def is_platform_header(hdr):
-    for platform_identifier in ['_gcc', '_win32', '_pthread', '_zookeeper']:
+    for platform_identifier in ['_gcc', '_win32', '_pthread',
+                                '_zookeeper', '_msvc', '_posix']:
       if platform_identifier in hdr:
         return True
     return False
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index 7b7b68fb86..4a3ffbd09e 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -53,11 +53,9 @@
 #include <grpc/support/subprocess.h>
 #include <grpc/support/sync.h>
 #include <grpc/support/sync_generic.h>
-#include <grpc/support/sync_posix.h>
 #include <grpc/support/thd.h>
 #include <grpc/support/time.h>
 #include <grpc/support/tls.h>
-#include <grpc/support/tls_msvc.h>
 #include <grpc/support/useful.h>
 
 int main(int argc, char **argv) {
-- 
GitLab