From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f169.google.com (mail-we0-f169.google.com [74.125.82.169]) by dpdk.org (Postfix) with ESMTP id 65AE12E81 for ; Fri, 15 Nov 2013 15:38:03 +0100 (CET) Received: by mail-we0-f169.google.com with SMTP id q58so3670572wes.28 for ; Fri, 15 Nov 2013 06:38:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=XbwNmYKeDJ58pvjKGcWzB6BtW7JySbsqahAV6DeVv0Y=; b=kDXCDl5wI58cuU6mQvmTSyDBFJI76k08NwlVYNWHcGoqQMqFkHSLkZEU96fWRvlNz2 74SK3upcQzO2i7l3C2Rg5qDCmw0Ka6r/u2EYxfj3Jb4Nv7eRi2k/+SMgDpFB6bVijETs DZ9krInsL08TPAkaFumN9t+uuX9E/dJ3Rlee2+5pvYVnEIUsE2jxg28Abfz/I31jcRWa rrSC0d3YHr0eRQslCYlra19x/6lc/hpSreZl16BPct3RAS4DBFkfS7RH3x37D6trVOxs jqD0ZAlRtUV3qsvq9DaDSClMXUT2GxRRlHJf3VEZKchsR6jAdr8WwZ/VlPEr5bWHAmSH nE5A== X-Gm-Message-State: ALoCoQkC8gOKhh5cZch8FFU/sNsHxkyzt8Yh3ol+j8yYDNnx+7XCWBH/yd/KrY/KETDShodGxXhc X-Received: by 10.180.189.80 with SMTP id gg16mr7628320wic.32.1384526339794; Fri, 15 Nov 2013 06:38:59 -0800 (PST) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id s20sm63113wib.1.2013.11.15.06.38.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 15 Nov 2013 06:38:59 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 15 Nov 2013 15:38:52 +0100 Message-Id: <1384526332-24702-1-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 1.7.12 Subject: [dpdk-dev] [PATCH] mk: fix command-line dependency check for quoted strings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2013 14:38:03 -0000 Before recompiling a file, rte.compile-pre.mk checks whether the command line is different from the previous one. This is done by storing for each object file the entire command line in a kind of dependency file with a .cmd extension (see obj2cmd). If that file exists, the line is retrieved first and compared against $(C_TO_O_STR). The object file gets recompiled if the file doesn't exist or if the line is different. The problem is that sometimes, files are recompiled for no apparent reason. The check doesn't work properly when a command line contains double-quoted strings such as -DFOO='"bar"' because the shell interprets and strips them. This is fixed by protecting C_TO_O_CMD with simple quotes, knowing that such quotes are already escaped in C_TO_O_STR. Moreover, because simple quotes are escaped in C_TO_O_STR, the retrieved command should be compared against C_TO_O instead. Signed-off-by: Adrien Mazarguil --- mk/internal/rte.compile-pre.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mk/internal/rte.compile-pre.mk b/mk/internal/rte.compile-pre.mk index ab9a4a8..67454d6 100644 --- a/mk/internal/rte.compile-pre.mk +++ b/mk/internal/rte.compile-pre.mk @@ -84,7 +84,7 @@ C_TO_O = $(CC) -Wp,-MD,$(call obj2dep,$(@)).tmp $(CFLAGS) \ C_TO_O_STR = $(subst ','\'',$(C_TO_O)) #'# fix syntax highlight C_TO_O_DISP = $(if $(V),"$(C_TO_O_STR)"," CC $(@)") endif -C_TO_O_CMD = "cmd_$@ = $(C_TO_O_STR)" +C_TO_O_CMD = 'cmd_$@ = $(C_TO_O_STR)' C_TO_O_DO = @set -e; \ echo $(C_TO_O_DISP); \ $(C_TO_O) && \ @@ -99,7 +99,7 @@ compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1))) file_missing = $(call compare,$(wildcard $@),$@) # return a non-empty string if cmdline changed -cmdline_changed = $(call compare,$(cmd_$@),$(1)) +cmdline_changed = $(call compare,$(strip $(cmd_$@)),$(strip $(1))) # return a non-empty string if a dependency file does not exist depfile_missing = $(call compare,$(wildcard $(dep_$@)),$(dep_$@)) @@ -127,12 +127,12 @@ boolean = $(if $1,1,0) $(if $(D),\ @echo -n "$< -> $@ " ; \ echo -n "file_missing=$(call boolean,$(file_missing)) " ; \ - echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(C_TO_O_STR))) " ; \ + echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(C_TO_O))) " ; \ echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \ echo "depfile_newer=$(call boolean,$(depfile_newer))") $(if $(or \ $(file_missing),\ - $(call cmdline_changed,$(C_TO_O_STR)),\ + $(call cmdline_changed,$(C_TO_O)),\ $(depfile_missing),\ $(depfile_newer)),\ $(C_TO_O_DO)) -- 1.7.12