dimanche 26 août 2018

Makefile: Conditional Not Working

I'm trying to store the 2nd argument passed in command line (i.e the argument after 'make') in a variable called NAME, and then use it to do stuff. If there is no 2nd argument then by default NAME = a .

Why doesn't it work ?


Makefile

NAME = a

ifneq ($(strip $(NAME)),)
    $(NAME) = $(shell $2)
endif

$(NAME): $(NAME).c
    @$(CC) $(CFLAGS) $< -o $@ && ./$(NAME)


# ... and do other things with NAME

Aucun commentaire:

Enregistrer un commentaire