Get exit code 1 in Makefile if statement

I am trying to get the exit code in the ifdef statement if the statement is not true, but I tried using exit 1 and $ (call exit 1)

when using the first in the following code, I get "Makefile: 11: * missing separator. Stop."

...

ifdef PACKAGE
    PACKAGEDIR = $(HOME)/$(PACKAGE)
else
    exit 1
endif

...

Using $(call exit 1), I am not getting errors, but the makefile still continues to execute. What I'm trying to do is exit the Makefile on else with error code 1

thank

+3
source share
2 answers

, exit 1 make . Make , . , .

GNU make, $(error ...), :

ifdef PACKAGE
    PACKAGEDIR = $(HOME)/$(PACKAGE)
else
    $(error You must define the PACKAGE variable)
endif

, ifdef true, , . :

ifneq ($(PACKAGE),)
    PACKAGEDIR = $(HOME)/$(PACKAGE)
else
    $(error You must define the PACKAGE variable)
endif

, ​​ .

, , GNU make , $(error ...), .

+4

, - Makefile; (, exit 1) - .

$(error) . , , else, , exit 1 ;

PACKAGEDIR := $(if $(flavor PACKAGE),undefined,$(error PACKAGE must be defined!),$(HOME)/$(PACKAGE))
0

All Articles