'make' does not recompile when source file has been edited

前端 未结 3 546
栀梦
栀梦 2021-01-19 13:31

I\'m writing a little implementation of Conway\'s Game of Life in C. The source code is split in three files: main.c and functions.c/function

3条回答
  •  无人共我
    2021-01-19 14:18

    If you're using GCC (well, you are), then it can be solved generically by passing -MD option to the compiler, GCC will generate a file containing Make dependencies on included headers:

    CC = gcc
    OBJECTS = main.o functions.o
    
    %.o : %.c
        $(CC) -MD -c $<
    
    -include $(OBJECTS:.o=.d)
    

    Some headers-related information can also be found in this question.

提交回复
热议问题