Skip to main content
GameDev.net gamedev.net
🔒 Locked

[GNU make] makefile includes

Started by cpp forever Jul 3, 2007 at 1:23 AM 2 replies 1k views
Original Post
cpp forever
cpp forever
How can I include found files in makefile? Currently I'm having in my makefile: include "makefile1.mk" include "makefile2.mk" include "makefile3.mk" But I want to rewrite this in the following way: include find *.mk But it doesn't work. Is it possible, anybody knows how?
ai-blog.org: AI is discussed here.
let_bound
let_bound
$ cat MakefileMAKEFILES = $(shell find -maxdepth 1 -type f -name '*.mk')include $(MAKEFILES)all:  @echo $(VAL_A)  @echo $(VAL_B)  @echo $(VAL_C)$ echo 'VAL_A = "a.mk"' > a.mk$ echo 'VAL_B = "b.mk"' > b.mk$ echo 'VAL_C = "c.mk"' > c.mk$ makea.mkb.mkc.mk


Maxdepth is there to ensure that only the current directory is searched for the files. Remove it if you want find to recursively crawl subdirectories, or increase the limit (eg -maxdepth 3) to limit the search depth.

The quotes around *.mk are necessary.

Hope this helps.
cpp forever
cpp forever
Yes, it does work. Thanks. Sepcifying MAKEFILES variable is great idea.
ai-blog.org: AI is discussed here.
haegarr
haegarr
Should also be possible without executing find in a shell:

include $(wildcard makefile*.mk)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.