From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: Re: [PATCH 11/13] Makefile: auto-build C strings from make variables Date: Wed, 05 Feb 2014 11:17:13 -0800 Message-ID: References: <20140205174823.GA15070@sigill.intra.peff.net> <20140205180206.GK15218@sigill.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: git@vger.kernel.org To: Jeff King X-From: git-owner@vger.kernel.org Wed Feb 05 20:17:28 2014 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WB7yR-0007rc-P4 for gcvg-git-2@plane.gmane.org; Wed, 05 Feb 2014 20:17:28 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427AbaBETRX (ORCPT ); Wed, 5 Feb 2014 14:17:23 -0500 Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:62728 "EHLO smtp.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbaBETRX (ORCPT ); Wed, 5 Feb 2014 14:17:23 -0500 Received: from smtp.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id DA37B670FD; Wed, 5 Feb 2014 14:17:21 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=1rlo6Ch1blJcYWHUZDg6EvEZado=; b=vxkur4 NUYtFt152k8/uSU0AWULy0pueRTXIRhKTohSWhn1uPZ/SbanFJyvSMJfZZJ1PzOC oArb3Vy3lDrk65TBxZZyYGWm2oNfaXQpbatBgALRCspgxxofWJLIkYJuB+IBpxDa mcnINQ+qMFTDtRiVNolTAlIM7z+h0tyky9K4E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=KCE1EULR4L3sOTYcOD0GrUtdajYW4EiX F5OPSQtj77oi6v3nBi0rbj0iK1bnDJCGqet3FLxnDrvWH9JfV/FVRzoBIcyAHiHA SrEBJe2woevneq+lShTsKg7gDNsS/9qezT8tVeqXw+EGxwK4O/NXidkh8bRO8PK6 vA5vzLfK2oI= Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 46FD3670FA; Wed, 5 Feb 2014 14:17:21 -0500 (EST) Received: from pobox.com (unknown [72.14.226.9]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by b-sasl-quonix.pobox.com (Postfix) with ESMTPSA id B5224670E1; Wed, 5 Feb 2014 14:17:15 -0500 (EST) In-Reply-To: <20140205180206.GK15218@sigill.intra.peff.net> (Jeff King's message of "Wed, 5 Feb 2014 13:02:06 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: 1F99AAA2-8E9A-11E3-A102-1B26802839F8-77302942!b-pb-sasl-quonix.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Jeff King writes: > diff --git a/script/mkcstring b/script/mkcstring > new file mode 100644 > index 0000000..c01f430 > --- /dev/null > +++ b/script/mkcstring > @@ -0,0 +1,18 @@ > +#!/bin/sh > + > +name=$1; shift > + > +c_quote() { > + sed 's/\\/\\\\/g; s/"/\\"/' No 'g' for the second one? > +} > + > +cat <<-EOF > +#ifndef MAKE_${name}_H > +#define MAKE_${name}_H > + > +/* Auto-generated by mkcstring */ > + > +#define MAKE_${name} "$(c_quote)" > + > +#endif /* MAKE_${name}_H */ > +EOF > diff --git a/version.c b/version.c > index 6106a80..f68a93b 100644 > --- a/version.c > +++ b/version.c > @@ -1,8 +1,10 @@ > #include "git-compat-util.h" > #include "version.h" > #include "strbuf.h" > +#include "MAKE/USER-AGENT-string.h" > +#include "MAKE/VERSION-string.h" > > -const char git_version_string[] = GIT_VERSION; > +const char git_version_string[] = MAKE_VERSION; > > const char *git_user_agent(void) > { > @@ -11,7 +13,7 @@ const char *git_user_agent(void) > if (!agent) { > agent = getenv("GIT_USER_AGENT"); > if (!agent) > - agent = GIT_USER_AGENT; > + agent = MAKE_USER_AGENT; > } > > return agent;