Reputation: 1871
Normally I use GCC's I-flag to include folders in this way:
gcc main.c -IfolderA -IfolderB
Well I need to reorganize my makefiels structure and I'm thinking about to have an environment variable which is defined as this:
INCLUDES="folderA folderB"
How could I use GCC's I-flag to include both folders?
I thought about something (but it does not work) like this:
gcc main.c -I($(INCLUDES))
Upvotes: 1
Views: 1707
Reputation:
You could also use the addprefix
function -- although it's designed to work on filenames, it can still be used here:
gcc main.c $(addprefix -I,$(INCLUDES))
Upvotes: 1
Reputation: 409442
You need to add the -I
flag to all the "elements" of your INCLUDES
variable. Perhaps through something like this:
gcc main.c $(foreach dir,$(INCLUDES),-I$(dir))
Upvotes: 2