gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Setting makefile to scan directories recursively

#167830 - Echo49 - Mon Mar 30, 2009 11:02 am

At the moment, my makefile is full of this:
Code:
SOURCES   := \
            source            \
            source/Libraries   \
            source/System      \
            source/Graphics      \
            source/Helpers      \
            source/GameplayElements

etc., etc.

Similarly with my data directory. Is there a way to just specify "source" and have it check every subdirectory within it?

#167831 - kusma - Mon Mar 30, 2009 12:45 pm

Echo49 wrote:
Similarly with my data directory. Is there a way to just specify "source" and have it check every subdirectory within it?

Sure, "find <folder> -type d" is what you need for this. If you're not that good at make, here's the syntax:
Code:
SOURCES := $(shell find source -type d)

However, once projects grow in complexity, automatic inclusion of source files has a chance of becoming a major head-ache. Just be warned :)

#167840 - Echo49 - Mon Mar 30, 2009 7:29 pm

Thank you for that.

Another thing: yesterday I created a further subdirectory within my folder, so there are source files located at source/dir1/dir2/source.cpp. Naturally, I included that folder in the sources list in the makefile. Suddenly, compiling took a lot longer. I wonder if this had anything to do with it, or was it just something I changed in my code? I'm sure I don't include any code in header files.