sk0102 sk0102 - 1 year ago 107
Linux Question

Dynamic get C file in Makefile

I'am trying to create a Makefile that has a target in src folder, but my target .c file is generated by script.

I am trying to use wildcard or %.c to get all generated .c file, but it always return empty string.

obj: GEN_C
$(CC) -c $(wildcard src/*.c)


I get to know other project makefile that get dynamic file use $($(CC_FILES).c=.o), but in this case i don't know which name .c will be generated.


Answer Source

Why do you use the wildcard function?

Delay the evaluation by using the wildcard in the shell.

obj: GEN_C
    $(CC) -c src/*.c

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download