From 491570184e984e809bbd3258d9c4261be3a3b1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vasseur?= Date: Mon, 11 Dec 2017 16:55:01 +0000 Subject: [PATCH] Use make check instead of headers_test.sh --- .gitignore | 1 + Makefile | 24 ++++++++++++++++++++++-- headers_test.sh | 33 --------------------------------- 3 files changed, 23 insertions(+), 35 deletions(-) delete mode 100755 headers_test.sh diff --git a/.gitignore b/.gitignore index bd794c8..4011583 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/bitstream /bitstream.pc /examples/dvb_ecmg /examples/dvb_ecmg_test diff --git a/Makefile b/Makefile index dba840d..50303b9 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,27 @@ dist: bzip2 -9 > bitstream-$(VERSION).tar.bz2 clean: - $(RM) bitstream.pc + $(RM) bitstream bitstream.pc $(MAKE) -C examples clean -.PHONY: all install uninstall dist clean +# if you want to check only particular headers, +# use make check HEADER_LIST="dvb/sim.h ietf/rtp.h" + +HEADER_LIST = $$(find * -name '*.h') + +FLAGS = -I. -Werror -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wformat=2 + +compiler_c = $(CC) $(FLAGS) $(CFLAGS) +compiler_c++ = $(CXX) $(FLAGS) $(CXXFLAGS) +compile = $(compiler_$1) -include "$$header" -c -x $1 /dev/null -o /dev/null + +check: + @ln -nsf . bitstream + @for header in $(HEADER_LIST); do \ + $(if $(V),set -x;) \ + $(call compile,c) || exit 1; \ + $(call compile,c++) || exit 1; \ + echo "PASS: $$header"; \ + done + +.PHONY: all install uninstall dist clean check diff --git a/headers_test.sh b/headers_test.sh deleted file mode 100755 index 8ee4fdc..0000000 --- a/headers_test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Test if each header can be used standalone -# Copyright (C) 2011 Unix Solutions Ltd. -# -# License: MIT -# Authors: Georgi Chorbadzhiyski -# - -HEADER_LIST="dvb/sim.h ietf/rtp.h" -# Find is used in such a way in order to work on OS X as well as Linux -# If you want to test only particular headers comment the line bellow -HEADER_LIST=$(find * | grep \\.h$ | sort | sed -e 's|^\./||') - -for suffix in "c" "cpp" -do - case $suffix in - "cpp") - compiler="g++" - ;; - *) - compiler="gcc" - ;; - esac - for HDR in $HEADER_LIST - do - test_file=$(echo $HDR | sed -e 's|/|_|g;s|\.h$||') - echo "Testing ($compiler): $HDR" - printf "#include \"$HDR\"\n\nint main(void) { return 0; }\n" > $test_file.$suffix - $compiler -I.. -Werror -Wall -Wextra -Wno-unused -Wno-sign-compare -Wformat-security $test_file.$suffix -o $test_file - [ $? != 0 ] && exit 1 - rm $test_file $test_file.$suffix - done -done