I am trying to implement a makefile for my C project which has a directory structure as follows:PROJECT_FOLDER:    folder1    folder2    folder // n number of folders    main.cFOLDER1:    subfolder1    subfolder // n number of subfoldersAnd subfolder 1 can have further subfolders etc.. etc..I don't intend on being stupid with my directory structure, the deepest I may go is 1-2 MAYBE 3.Thus far I have:# A Makefile to build our First_Game_2 projectdirs = * */parsePROJECT =  mainHEADERS =  $(PROJECT).hOBJ     =  $(foreach dirz, $(dirs), \        \        $(patsubst %.c,%.o,$(wildcard $(dirz).c)) \        \    )C99     =  gcc -std=c99CFLAGS  =  -Wall -pedantic -Werror $(PROJECT) : $(OBJ)        $(C99) $(CFLAGS) -o $(PROJECT) $(OBJ)%.o : %.c $(HEADERS)        $(C99) $(CFLAGS) -c $<clean:        rm -f $(PROJECT) $(OBJ)My problem is if parse contains a subfolder, say test to give the structurePROJECT_FOLDER/parse/testIn such a case, nothing is returned from$(foreach dirz, $(dirs), \        \        $(patsubst %.c,%.o,$(wildcard $(dirz).c)) \        \    )I tested the output of the function with the following makefile# A Makefile to build our First_Game_2 projectdirs = * */parsePROJECT =  mainHEADERS =  $(PROJECT).hOBJ     =  C99     =  gcc -std=c99CFLAGS  =  -Wall -pedantic -Werror $(foreach dirz, $(dirs), \        \        $(patsubst %.c,%.o,$(wildcard $(dirz).c)) \        \    )Which, given a structure of:dirs = * */parse */parse/testProduces an output of:main.o parse/parse.oIgnoring */parse/testWhy is this the case, what can I do to fix my OBJ assignment to recognize */parse/test or otherwise?
Makefile $wildcard only matches top directory
directory;make;recursive
You have the wildcard in the dirs pattern backward.You wanted:dirs = * parse/* parse/test/*As written, your pattern above expanded to: *.c (good), */parse.c (lucky!), and */parse/test.c, which would have confused you even more if that file existed.The only reason it looked like it worked for the first level directory is because you used the same filename, 'parse', as the directory name.