Makefile
ifeq ($(wifiSim),1)
WIFISIM :=1
endif
all: test.cpp
test.cpp : test.o
./a.out
test.o :
c++ test.cpp
test.cpp
#include <iostream>
using namespace std;
int main()
{
#ifdef WIFISIM
cout << "Inside wifisim = 1" << endl;
#else
cout << "Outside wifisim = 1" << endl;
#endif
return 0;
}
I want to use the WIFISIM
in the test.cpp
.
I am running make wifiSim=1 all
But the else is being executed in test.cpp
Is there any way I can do it without doing any changes in the way the compilation for test.cpp
is done, because I need to use this flag WIFISIM in many files and I do not want to change the way compilation for them is being done.