define variable preprocessor (CPPFLAGS) in make comand line

stoikos
Posts: 31
Joined: Mon Aug 06, 2018 4:38 am

define variable preprocessor (CPPFLAGS) in make comand line

Postby stoikos » Mon Nov 19, 2018 8:10 pm

Hi,
I would like to be able to #define variables from the make command line. I tried

Code: Select all

make -j12 CPPFLAGS+='-Dvar' all


and other combinations (CPPFLAGS='-Dvar', etc )and it seems that although the #define succeeds, it doesnt pick up other #defines that exist in the makefile and the compilation fails completely or I get some weird messages such as

Code: Select all

esp_http_client.c:(.text+0x1a96): dangerous relocation: call8: call target out of range: esp_log_timestamp

What is the correct way to #define a variable in the make command line?

stoikos
Posts: 31
Joined: Mon Aug 06, 2018 4:38 am

[SOLVED] Re: define variable preprocessor (CPPFLAGS) in make comand line

Postby stoikos » Mon Nov 19, 2018 11:11 pm

C++ uses CXXFLAGS while C uses CPPFLAGS

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: define variable preprocessor (CPPFLAGS) in make comand line

Postby ESP_igrr » Mon Nov 19, 2018 11:58 pm

On Make command line, or in the project makefile, you can use EXTRA_CPPFLAGS — these will be appended to CPPFLAGS without replacing anything.

stoikos
Posts: 31
Joined: Mon Aug 06, 2018 4:38 am

Re: define variable preprocessor (CPPFLAGS) in make comand line

Postby stoikos » Tue Nov 20, 2018 12:57 am

so for C++ I need to add EXTRA_CXXFLAGS?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: define variable preprocessor (CPPFLAGS) in make comand line

Postby ESP_igrr » Tue Nov 20, 2018 1:23 am

CPPFLAGS are preprocessor flags, then apply both to C and C++. CFLAGS apply to C. CXXFLAGS apply to C++. Same with EXTRA_...

stoikos
Posts: 31
Joined: Mon Aug 06, 2018 4:38 am

Re: define variable preprocessor (CPPFLAGS) in make comand line

Postby stoikos » Tue Nov 20, 2018 5:40 am

it worked ! thank you!

Who is online

Users browsing this forum: No registered users and 106 guests