From patchwork Tue Jul 18 02:54:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 9846689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E7A560212 for ; Tue, 18 Jul 2017 02:54:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A101826256 for ; Tue, 18 Jul 2017 02:54:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92E0526E1A; Tue, 18 Jul 2017 02:54:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1AC226256 for ; Tue, 18 Jul 2017 02:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbdGRCyO (ORCPT ); Mon, 17 Jul 2017 22:54:14 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35071 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbdGRCyO (ORCPT ); Mon, 17 Jul 2017 22:54:14 -0400 Received: by mail-pg0-f65.google.com with SMTP id d193so1007695pgc.2 for ; Mon, 17 Jul 2017 19:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=nnXQHybOb47sJDUZfzd2cy2AlXX/ymCS5eLY9KM9RCE=; b=bt57Htu7A98zTjj8KSQ4gmscO/7/XK8dsQwaUMmW+MNQ2Yl0XWJ/E2fvWzDvoBS0Kb PzWzR7SSm1muUGvrkjcjwV2/cAqsTULIJvJJjKYRYt7Ip4nJbJMB7e3VUiEAXvpvhxRR XYHth/ogwkscebpBTQv0MTmxXXZTsEamYos60z43XbPb2cOpkDjPPwdjiS/aM5UGUbao S8lOP4EOFi58MDCK+PQbvYqLF76xnw6VnJ5yOoNWwNi2KqSx/2RDcWepdIn0vs8EEAOC 766ZQ8k0X8J3SdIju4hAnZ692pUqnk/P+pIZHeHubnqExXrtC1/mnYNWqH5tBoaLG7nA Z1yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=nnXQHybOb47sJDUZfzd2cy2AlXX/ymCS5eLY9KM9RCE=; b=RB5xUu5X7sGUrK998jyzWhxsU+Tbq/LEW0GIFu1rC4Rab8L6Yf/VtkMN+A0BfsBVqg pH9Dv20skAHOsADBHEWmyOd+epJyrHqb+LSWYX3XYYfkflxwrMtIwtskLMsrMP2S3IH1 uChLPmY0f6gm3GO1yjm4J4FFfDnxw3vMz5KItS/HOM0agAPmyOtWcJry+dpCgQfdEmVm zVwS5rroHRO6PL+KefIgydHp3nXuLmxwdDw1x7wKFdzDOSS+/KZYZrFQRgTgjLXXWZbH lwi2btwOipTRttJj4nmMTx9Jtn0xivs2LsdeAodDU5q6yagmeAf9CH/26ADIPDOaQfgq Lbog== X-Gm-Message-State: AIVw113voSQQCiSZb1bT1lkzr+g0vwdoEXRIeBD+ZUlDGPkmH1IyeQow 3HgMbWcYHjDknyA2tf8GfyER43rMSuDf X-Received: by 10.99.127.11 with SMTP id a11mr721158pgd.213.1500346453487; Mon, 17 Jul 2017 19:54:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.149.130 with HTTP; Mon, 17 Jul 2017 19:54:12 -0700 (PDT) From: Christopher Li Date: Mon, 17 Jul 2017 22:54:12 -0400 X-Google-Sender-Auth: AnfPS2X3-ECgweXWRD4INZ7CBzo Message-ID: Subject: [PATCH 2/4] V2 Makefile: add selfcheck target To: Linux-Sparse , Ramsay Jones Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "make selfcheck" will invoke sparse to check its own source code. It is different than the "make C=1" in linux kernel because sparse executable need to be compiled first. "make .sc" will invoke the sparse to check specific C source file .c For example: "make parse.sc" V2: As pointer out by Ramsay Jones, in cygwin the check need to be invoked by cgcc to have some platform specific macro defined. Change the checker program to control by $(CHECKER) Add $(PROGRAM)_EXTRA_DEPS into selfcheck Signed-off-By: Christopher Li --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9f62c61..9e9c939 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ LDFLAGS += -g LD = gcc AR = ar PKG_CONFIG = pkg-config +CHECKER = ./cgcc -no-compile ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) # @@ -73,7 +74,8 @@ GTK2_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0) PROGRAMS += test-inspect INST_PROGRAMS += test-inspect test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o -test-inspect.o $(test-inspect_EXTRA_DEPS): BASIC_CFLAGS += $(GTK2_CFLAGS) +test-inspect_OBJS := test-inspect.o $(test-inspect_EXTRA_DEPS) +$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): CFLAGS += $(GTK2_CFLAGS) test-inspect_EXTRA_OBJS := $(GTK2_LIBS) else $(warning Your system does not have libgtk2, disabling test-inspect) @@ -127,6 +129,7 @@ LIBS=$(LIB_FILE) V = @ Q = $(V:1=) QUIET_CC = $(Q:@=@echo ' CC '$@;) +QUIET_CHECK = $(Q:@=@echo ' CHECK '$<;) QUIET_AR = $(Q:@=@echo ' AR '$@;) QUIET_GEN = $(Q:@=@echo ' GEN '$@;) QUIET_LINK = $(Q:@=@echo ' LINK '$@;) @@ -193,11 +196,18 @@ ifneq ($(DEP_FILES),) include $(DEP_FILES) endif -c2xml.o: CFLAGS += $(LIBXML_CFLAGS) +c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS) %.o: %.c $(LIB_H) $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +%.sc: %.c sparse + $(QUIET_CHECK) $(CHECKER) -c $(ALL_CFLAGS) $< + +ALL_OBJS := $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)_EXTRA_DEPS)) +selfcheck: $(ALL_OBJS:.o=.sc) + + clean: clean-check rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc