Cómo forzar un error en un archivo gnumake


Quiero detectar una condición en mi makefile donde una herramienta es la versión incorrecta y forzar que la marca falle con un mensaje de error que indica que el elemento no es la versión correcta.

¿Puede alguien dar un ejemplo de hacer esto?

He intentado lo siguiente, pero no es la sintaxis correcta:

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

Gracias.

Author: WilliamKF, 2009-12-08

3 answers

Del manual :

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

Esto resultará make en un error fatal:

$ make
Makefile:2: *** Bad svn version v1.4, please install v1.6.  Stop.
 60
Author: LiraNuna,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-12-08 03:36:00

While While (error... funciona, a veces es más fácil usar una regla que falla

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

Entonces haces test_svn_version un prerrequisito de tu objetivo de nivel superior.

 7
Author: Chris Dodd,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-12-09 03:17:58

El condicional también necesita atención.

ifeq ($(shell svnversion --version | sed s/[^0-9\.]*://), 1.4) 
    $(error Bad svnversion v1.4, please install v1.6)
endif 
 4
Author: Beta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-12-08 03:51:05