From patchwork Thu Sep 14 18:45:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 9953703 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 16A2E6024A for ; Thu, 14 Sep 2017 18:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FB0029219 for ; Thu, 14 Sep 2017 18:45:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0464C2921E; Thu, 14 Sep 2017 18:45:48 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 6AE2629219 for ; Thu, 14 Sep 2017 18:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751671AbdINSpq (ORCPT ); Thu, 14 Sep 2017 14:45:46 -0400 Received: from arcturus.kleine-koenig.org ([78.47.169.190]:48609 "EHLO arcturus.kleine-koenig.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbdINSpq (ORCPT ); Thu, 14 Sep 2017 14:45:46 -0400 Received: by arcturus.kleine-koenig.org (Postfix, from userid 1000) id 5798B1B2179; Thu, 14 Sep 2017 20:45:45 +0200 (CEST) From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: linux-sparse@vger.kernel.org Subject: [PATCH] build: only generate version.h when needed and remove it in clean target Date: Thu, 14 Sep 2017 20:45:40 +0200 Message-Id: <20170914184540.26650-1-uwe@kleine-koenig.org> X-Mailer: git-send-email 2.14.1 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 This way version.h isn't generated when running $(make clean) but only when lib.c is about to be compiled. This simplifies packaging for Debian because the package building programs abort when there are additional files after $(make clean). --- Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a4653aa1b747..13b0f97f146e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,6 @@ VERSION=0.5.1 -# Generating file version.h if current version has changed SPARSE_VERSION:=$(shell git describe 2>/dev/null || echo '$(VERSION)') -VERSION_H := $(shell cat version.h 2>/dev/null) -ifneq ($(lastword $(VERSION_H)),"$(SPARSE_VERSION)") -$(info $(shell echo ' GEN 'version.h)) -$(shell echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h) -endif OS = linux @@ -215,6 +209,18 @@ pre-process.sc: CHECKER_FLAGS += -Wno-vla %.o: %.c $(LIB_H) $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +version.h: FORCE + $(QUIET_GEN)echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h.tmp; \ + if cmp -s version.h version.h.tmp; then \ + rm version.h.tmp; \ + else \ + mv version.h.tmp version.h; \ + fi + +.PHONY: FORCE + +lib.o: version.h + %.sc: %.c sparse $(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(ALL_CFLAGS) $< @@ -223,7 +229,7 @@ selfcheck: $(ALL_OBJS:.o=.sc) clean: clean-check - rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc + rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc version.h dist: @if test "$(SPARSE_VERSION)" != "v$(VERSION)" ; then \