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/




_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to