diff mbox series

[3/4] Check that keyutils.h has valid C++ syntax at build time

Message ID 20200702085723.7026-4-cvubrugier@fastmail.fm (mailing list archive)
State New
Headers show
Series keyutils: fix compilation error with C++ | expand

Commit Message

Christophe Vu-Brugier July 2, 2020, 8:57 a.m. UTC
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
---
 Makefile | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 6f79446..949ad7c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@ 
 CPPFLAGS	:= -I.
 CFLAGS		:= -g -Wall -Werror
+CXXFLAGS	:= -g -Wall -Werror
 INSTALL		:= install
 DESTDIR		:=
 SPECFILE	:= keyutils.spec
@@ -99,7 +100,7 @@  endif
 # Normal build rule
 #
 ###############################################################################
-all: keyctl request-key key.dns_resolver
+all: keyctl request-key key.dns_resolver cxx
 
 ###############################################################################
 #
@@ -163,6 +164,18 @@  key.dns_resolver: key.dns_resolver.o dns.afsdb.o $(LIB_DEPENDENCY)
 key.dns_resolver.o: key.dns_resolver.c key.dns.h
 dns.afsdb.o: dns.afsdb.c key.dns.h
 
+###############################################################################
+#
+# Check that the header file has valid C++ syntax
+#
+###############################################################################
+cxx.stamp: keyutils.h Makefile
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -x c++-header -fsyntax-only $<
+	touch $@
+
+cxx: cxx.stamp
+.PHONY: cxx
+
 ###############################################################################
 #
 # Install everything
@@ -244,6 +257,7 @@  clean:
 	$(RM) keyctl request-key key.dns_resolver
 	$(RM) *.o *.os *~
 	$(RM) debugfiles.list debugsources.list
+	$(RM) cxx.stamp
 
 distclean: clean
 	$(RM) -r rpmbuild $(TARBALL)