I'm trying to create targets that depend on a list of files in a directory with the name of the target:
bin/%.out: src/%/ $(shell find src/%/* -type f -iname '*.cpp' -o -iname '*.hpp')
# Build stuff here
However shell find src/%/* ...ends up expanding to shell find src//* .... At first I thought it's because I could only have 1 target wildcard but even after removing the src/%/dependency it ended up with this same problem.
Some more context: my directory contains a 'src' directory, which contains directories. Each sub-directory of 'src' I treat as a "project". When I build, all object files should go in out/src/projname. I'm attempting to use find to recursively get all source and header files per project. All binaries will go in bin/projname.out and as such, the main dependencies are .out files in bin that have the same names as their project name. (if src/abc exists, bin/abc.out is a dependency of all).
So for each sub-directory in src, all source files are compiled and the object files are moved to out/projname which eventually will be linked to bin/projname.out.
- src
- proj0
- cpp/hpp files
- proj1
- cpp/hpp files
- proj0
- out
- src
- proj0
- object files
- proj1
- object files
- proj0
- src
- bin
- proj0.out
- proj1.out
Currently getting the list of projects and list of output files as follows:
SRCS := $(shell find src/* -maxdepth 0 -type d)
SRCS_OUT := $(patsubst src/%,bin/%.out,$(SRCS))
...
all: out/ bin/ $(SRCS_OUT)
Projects can contain sub-directories and such, which is why I'm using find in the code at the very top.