Reputation: 535
I would like to store all paths to headers in separate file. I'm going to generate file with paths dynamically, to avoid re-creating Makefile whenever paths change. Is that possible?
Upvotes: 2
Views: 810
Reputation: 25483
paths_mk := paths.mk
-include $(paths_mk)
$(paths_mk) :
# Rule to generate paths.mk
include_flags = $(include_paths:%=-I%)
CPPFLAGS += $(include_flags)
%.o : %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
# Auto-generated file.
include_paths := ...
Upvotes: 2
Reputation: 26164
Yes, you can generate the file, let's call it paths.inc
, so it looks like, for example:
INCLUDEPATH=path1:path2
and then include the file in your main Makefile
include paths.inc
and use the variable defined in it: ${INCLUDEPATH}
Upvotes: 3