makefile: generate depfiles for the correct object files

The depfiles were completely ineffective.

Now this is fixed.

The -MT argument sets the path for the dependenency root. By default it is set
only to a filename, and thus does not include the full path of the file.
This commit is contained in:
Khaïs COLIN 2025-04-15 10:29:30 +02:00
parent 9a58198303
commit e033909819
2 changed files with 2 additions and 2 deletions

View file

@ -117,7 +117,7 @@ $(LIBFT):
%.o: %.c
$(CC) -c $(CFLAGS) $(IFLAGS) -o $*.o $*.c
$(CC) -MM $(CFLAGS) $(IFLAGS) $*.c > $*.d
$(CC) -MM $(CFLAGS) $(IFLAGS) -MT $*.o $*.c > $*.d
clean:
+$(MAKE) -C $(LIBFTDIR) clean

View file

@ -44,7 +44,7 @@ run: $(run_tests)
%.o: %.c
$(CC) -c $(CFLAGS) $(IFLAGS) -o $*.o $*.c
$(CC) -MM $(CFLAGS) $(IFLAGS) $*.c > $*.d
$(CC) -MM $(CFLAGS) $(IFLAGS) -MT $*.o $*.c > $*.d
test_%: %.o $(objs)
$(CC) $(CFLAGS) -rdynamic -o $@ $*.o $(objs) $(LINCLUDE) $(LDLIBS)