I have this makefile (I cut out the irrelevant parts):
CC = gcc
EXEC = mtm_cm
LIB = -L. -lmtm
DEBUG = -g
CFLAGS = -std=c99 -Wall -Werror -pedantic-errors -DNDEBUG $(DEBUG)
OBJS = command_parser.o course_manager.o grade_data.o student.o \
grade_sheet_data.o print_utilities.o semester.o string_utilities.o
$(EXEC): $(OBJS) main.o
$(CC) $(DEBUG) $(OBJS) main.o $(LIB) -o $@
... here the $(OBJS) targets are found ...
tests: $(OBJS) student_test grade_data_test
grade_data_test: tests/grade_data_test.o
$(CC) $(DEBUG) $(OBJS) tests/$@.o $(LIB) -o $@
student_test: tests/student_test.o
$(CC) $(DEBUG) $(OBJS) tests/$@.o $(LIB) -o $@
tests/student_test.o: tests/student_test.c tests/new_test_utilities.h \
student.h list.h grade_sheet_data.h
tests/grade_data_test.o: tests/grade_data_test.c tests/new_test_utilities.h \
grade_data.h grade_sheet_data.h list.h
Everything works normally, except the grade_data part.
That is, if I call make
, the executable mtm_cm
is created, and if I call make tests
, then student_test
is created, but not grade_data_test
.
Instead, I get an error:
... former successful compilations ...
gcc -g command_parser.o course_manager.o grade_data.o student.o grade_sheet_data.o print_utilities.o semester.o string_utilities.o tests/grade_data_test.o -L. -lmtm -o grade_data_test
gcc: tests/grade_data_test.o: No such file or directory
But it did not merely skip the dependency of the target grade_data_test
. Instead, let us run make tests/grade_data_test.o --debug=v
, and get the output:
...
Finished prerequisites of target file `tests/grade_data_test.o'.
Must remake target `tests/grade_data_test.o'.
Successfully remade target file `tests/grade_data_test.o'.
make: `tests/grade_data_test.o' is up to date.
But the file does not exist. The directories have enough permission, and I don't have directories with the same name as files.
Can you help me find out the solution?