help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: followup to previous question


From: John Graham-Cumming
Subject: Re: followup to previous question
Date: Thu, 23 Jun 2005 16:44:09 -0400

On Thu, 2005-06-23 at 13:33 -0400, Robert P. J. Day wrote:
>   there's a top-level VERSION file, whose contents will be something
> like "3.2.2".  so, for now, i can use:
> 
> SRCDIR = [top of source tree]
> FULL_VERSION := $(shell cat ${SRCDIR}/VERSION)
> $(warning Full version is ${FULL_VERSION}.)
> 
> MAJOR_VERSION := $(shell expr ${FULL_VERSION} : "\([0-9]*\)")
> $(warning version is ${MAJOR_VERSION}.)
>
>   even though the above works, i'm just betting there's a more natural
> way to do either of:
> 
> 1) get the contents of a one-line text file
> 2) extract the leading fully-numeric substring of a string

That seems reasonable, but you could avoid the call out to 'expr':

    FULL_VERSION := $(shell cat $(SRCDIR)/VERSION)
    VERSION_LIST := $(call split,.,$(FULL_VERSION))
    MAJOR_VERSION := $(word 1,$(VERSION_LIST))

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]