I have multiple source files (let's call them file1.c, file2.c, etc.) that I would like compile into individual executables. Relevant part of the makefile:
file%.x: file%.o
$(CC) $(CFLAGS) $< -o $@
file%.o: file%.c
$(CC) $(CFLAGS) -c $< -o $@
I can make them individually fine with make file1.x
, make file2.x
, etc. I'd like to have a target in the makefile that builds all of the files. I tried a few things, but they didn't work:
all: file*.x
and
all: file%.x
Is there an easy way to do this? Thanks in advance.