From 08d55e3b9be86ee9719de0bee4be1c99e5a205a7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 24 Apr 2013 12:06:50 +0200 Subject: [PATCH] Add support for C++ examples For convenience, we link C examples using g++ as well, which should not cause any problems. --- defensive-coding/Makefile | 3 ++- defensive-coding/src/src.mk | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/defensive-coding/Makefile b/defensive-coding/Makefile index 63f819c..f982a32 100644 --- a/defensive-coding/Makefile +++ b/defensive-coding/Makefile @@ -8,7 +8,8 @@ build: build-src build-manual build-snippets: for p in en-US/* ; do test -d $$p && mkdir -p $$p/snippets; done - python scripts/split-snippets.py . src/*.c src/*.java src/*.py + python scripts/split-snippets.py . \ + src/*.c src/*.cpp src/*.java src/*.py build-manual: build-snippets publican build --format=html,epub,pdf --lang=en-US diff --git a/defensive-coding/src/src.mk b/defensive-coding/src/src.mk index 7987680..4212094 100644 --- a/defensive-coding/src/src.mk +++ b/defensive-coding/src/src.mk @@ -1,8 +1,12 @@ .PHONY: build-sources CC = gcc +CXX = g++ CWARNFLAGS = -Wall -W -Wno-unused-parameter -Werror=implicit-function-declaration +CXXWARNFLAGS = -Wall -W CFLAGS = -std=gnu99 -O2 $(CWARNFLAGS) -g +CXXFLAGS = -std=c++03 -O2 $(CXXWARNFLAGS) -g +LDFLAGS = -g # List files which should only be compiled for syntax checking. compile_only += C-Pointers-remaining @@ -42,11 +46,14 @@ clean-src: src/%.o: src/%.c $(CC) $(CFLAGS) $(DEFINES) $(CFLAGS_$(basename $(notdir $@))) -c $< -o $@ +src/%.o: src/%.cpp + $(CXX) $(CXXFLAGS) $(DEFINES) $(CFLAGS_$(basename $(notdir $@))) -c $< -o $@ + src/%.class: src/%.java javac -source 1.6 -target 1.6 -Xlint:all $^ src/%: src/%.o - $(CC) $^ -o $@ $(LIBS_$(notdir $@)) + $(CXX) $(LDFLAGS) $^ -o $@ $(LIBS_$(notdir $@)) src/TLS-Client-GNUTLS: src/tcp_connect.o src/TLS-Client-OpenSSL: src/tcp_connect.o src/x509_check_host.o