Based on this stackoverflow response, I've created a Makefile that compiles all .c files into separate executables. I've added a clean
section that removes all programs. It now looks like:
CFLAGS=-Wall -g
SRCS = $(wildcard *.c)
PROGS = $(patsubst %.c,%,$(SRCS))
all: $(PROGS)
clean:
rm -f $(PROGS)
%: %.c
$(CC) $(CFLAGS) -o $@ $<
My questions are:
- How would you have Makefile read additional command line arguments so that it can clean just the programs specified?