How to get gnumake file error

I want to detect a condition in my makefile where the tool is the wrong version and make make fail with an error message indicating that the item is not the correct version.

Can someone give an example of this?

I tried the following, but this is not the correct syntax:

ifeq "$(shell svnversion --version | sed s/[^0-9\.]*://)" "1.4" $error("Bad svnversion v1.4, please install v1.6") endif 

Thank.

+43
makefile gnu-make
Dec 08 '09 at 3:31
source share
3 answers

From manual :

 $(error Bad svn version v1.4, please install v1.6) 

This will make a fatal error:

 $ make Makefile:2: *** Bad svn version v1.4, please install v1.6. Stop. 
+52
Dec 08 '09 at 3:36
source share

While $ (error ... works, sometimes it’s easier to use a rule that fails

 test_svn_version: @if [ $$(svn --version --quiet | \ perl -ne '@a=split(/\./); \ print $$a[0]*10000 + $$a[1]*100 + $$a[2]') \ -lt 10600 ]; \ then \ echo >&2 "Svn version $$(svn --version --quiet) too old; upgrade to v1.6"; false; \ fi 

Then you make test_svn_version the premise of your top level target level.

+6
Dec 08 '09 at 4:24
source share

Conditional also require attention.

 ifeq ($ (shell svnversion --version | sed s / [^ 0-9 \.] *: //), 1.4) 
     $ (error Bad svnversion v1.4, please install v1.6)
 endif 
+3
Dec 08 '09 at 3:43
source share



All Articles