Ruggero Turra
Ruggero Turra

Reputation: 17740

change variable for a target in a Makefile

In a Makefile I've a target called objects and if I run make objects it produces .o from every .cpp. Now I want to introduce a target check-syntax that call the target object but before change the variable CFLAGS from -Wall -O2 to -Wall -O0 -fsyntax-only.

How to do it?

Upvotes: 1

Views: 887

Answers (1)

Beta
Beta

Reputation: 99164

(IN GNUMake, anyway, and I'll assume you meant CFLAGS)

CFLAGS = -Wall -O2

objects: ...
    whatever

check-syntax: CFLAGS = -Wall -O0 -fsyntax-only

check-syntax: objects

Upvotes: 2

Related Questions