Re: [PATCH 11/13] Makefile: auto-build C strings from make variables
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> 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?
Show 37 quoted lines
> +}
> +
> +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;