From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07125C433E6 for ; Fri, 5 Feb 2021 10:44:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B497664E39 for ; Fri, 5 Feb 2021 10:44:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbhBEKoZ (ORCPT ); Fri, 5 Feb 2021 05:44:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20974 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbhBEKmB (ORCPT ); Fri, 5 Feb 2021 05:42:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612521634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=W6jBem4kZByMthisphHJewkWb84OmU3PnI0wLH3ysj4=; b=QEo88EKMBpmI6hC9sqEJ97tMjw88B38OOi6Zin4YIF2WXttRE60JvToLQBJZFPucBqN6G+ nUBxFX5zV2eZwjnYfKf/lBk7+PZc4M1RiwA0pM1KW+qyEn+9KB5kiNZly+85Y0iP2kyAEq zYfugDWmToPvKlFU6hONPnNSCQ+zk6c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-0pyJ_b4eMACpynE11xphbw-1; Fri, 05 Feb 2021 05:40:30 -0500 X-MC-Unique: 0pyJ_b4eMACpynE11xphbw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B68D1005501; Fri, 5 Feb 2021 10:40:28 +0000 (UTC) Received: from krava (unknown [10.40.195.59]) by smtp.corp.redhat.com (Postfix) with SMTP id 8CA3D5C233; Fri, 5 Feb 2021 10:40:25 +0000 (UTC) Date: Fri, 5 Feb 2021 11:40:24 +0100 From: Jiri Olsa To: Andrii Nakryiko Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Masahiro Yamada , Michal Marek , Linux Kbuild mailing list Subject: Re: [PATCH bpf-next 2/4] tools/resolve_btfids: Check objects before removing Message-ID: References: <20210129134855.195810-1-jolsa@redhat.com> <20210204211825.588160-1-jolsa@kernel.org> <20210204211825.588160-3-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Feb 04, 2021 at 04:42:41PM -0800, Andrii Nakryiko wrote: > On Thu, Feb 4, 2021 at 1:20 PM Jiri Olsa wrote: > > > > We want this clean to be called from tree's root clean > > and that one is silent if there's nothing to clean. > > > > Adding check for all object to clean and display CLEAN > > messages only if there are objects to remove. > > > > Signed-off-by: Jiri Olsa > > --- > > tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++----- > > 1 file changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile > > index b780b3a9fb07..3007cfabf5e6 100644 > > --- a/tools/bpf/resolve_btfids/Makefile > > +++ b/tools/bpf/resolve_btfids/Makefile > > @@ -64,13 +64,20 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) > > $(call msg,LINK,$@) > > $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS) > > > > +clean_objects := $(wildcard $(OUTPUT)/*.o \ > > + $(OUTPUT)/.*.o.cmd \ > > + $(OUTPUT)/.*.o.d \ > > + $(OUTPUT)/libbpf \ > > + $(OUTPUT)/libsubcmd \ > > + $(OUTPUT)/resolve_btfids) > > + > > +clean: > > + > > +ifneq ($(clean_objects),) > > clean: fixdep-clean > > this looks a bit weird, declaring clean twice. Wouldn't moving ifneq > inside the clean work just fine? it has the fixdep-clean dependency we don't want to run if clean_objects is not defined.. I could move the empty clean to the the else path jirka --- diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 1d46a247ec95..be09ec4f03ff 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -64,13 +64,20 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) $(call msg,LINK,$@) $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS) +clean_objects := $(wildcard $(OUTPUT)/*.o \ + $(OUTPUT)/.*.o.cmd \ + $(OUTPUT)/.*.o.d \ + $(OUTPUT)/libbpf \ + $(OUTPUT)/libsubcmd \ + $(OUTPUT)/resolve_btfids) + +ifneq ($(clean_objects),) clean: fixdep-clean $(call msg,CLEAN,$(BINARY)) - $(Q)$(RM) -f $(BINARY); \ - $(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \ - $(RM) -rf $(OUTPUT)/libbpf; \ - $(RM) -rf $(OUTPUT)/libsubcmd; \ - find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) + $(Q)$(RM) -rf $(clean_objects) +else +clean: +endif tags: $(call msg,GEN,,tags)