View Antoni Milton's profile on LinkedIn

Tuesday, March 9, 2010

How to pass arguments for make file?

we can pass the arguments to makefile like below,

make -f Makefile HOST_OS="Linux"

in Makefile,we can use HOST_OS macro as usual.

example:

in main_folder make file,

HOST_OS = "SunOS"

all:
cd Sub_folder && make -f Makefile HOST_OS=$(HOST_OS)

in Sub_folder make file,

all:
ifeq ($(HOST_OS),Linux)
[ tab] g++ main.cpp
else
[tab] cc main.cpp
endif

No comments: