Makefile处理头文件 [英] Makefile dealing with header files
本文介绍了Makefile处理头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的makefile:
The following is my makefile:
CC=gcc
CFLAGS=-Wall -O3
SRCS = $(wildcard *.c)
EXES = $(patsubst %.c,%,$(SRCS))
.c.o:
$(CC) $(CFLAGS) -c $<
SRC_CODE=\
file1.c\
file2.c\
file.h
SOFI2D_OBJ=$(SRC_CODE:%.c=%.o)
sofi2D: $(SOFI2D_OBJ)
$(CC) $^ -o $@
clean:
rm -rf *.o *.o* *~ $(EXES)
all: clean sofi2D
我想知道头文件(.h)在编译中如何发挥作用?因为所有操作都在.c文件上...
I wonder how the header file (.h) plays a role in the compilation? Because all the operations are on .c files...
推荐答案
头文件由C编译器使用,而不是make.
The header file is used by the C compiler, not make.
如果要更改file.h
时重建.c文件,则需要更改SRC_CODE
的定义:
If you want the .c files to be rebuilt if file.h
changes, then you need to change the definition of SRC_CODE
:
SRC_CODE = file1.c file2.c
$(SRC_CODE): file.h
这篇关于Makefile处理头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文