rawtests = \ metacharacters \ tests = $(addprefix test_,$(rawtests)) test_objs = $(addsuffix .o,$(tests)) objs := $(addprefix ../,$(objs)) .PHONY: run %.o: %.c $(CC) -c $(CFLAGS) $(LDFLAGS) -o $*.o $*.c $(CC) -MM $(CFLAGS) $(LDFLAGS) $*.c > $*.d test_%: %.o $(objs) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.o $(objs) $(LDLIBS) run: $(tests) $(addprefix ./,$(addsuffix &&,$(tests))) echo "Finished running C tests" fclean: rm -f $(tests)