Ik heb de volgende makefile:
Het gaat denk ik om:
Na elke make, worden alle files opnieuw gecompileerd. Ook als ik de .cpp files niet veranderd heb. Waarom gebeurt dit? De target is toch afhankelijk van de .cpp files, als die hetzelfde zijn moet het toch niet opnieuw gebeuren?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| CC = mpiCC
OUTPATH = ../../bin/
LIBPROJPATH = ../../src/lib/
PREPROJPATH = ../../src/preproc/
INCPATH = ../../include/
LIBPATH =
BIN = lib preproc
CFLAGS = -Wall -O3 -DNDEBUG -DPTRS_NO_OUTPUT
LIBS = m jpeg
LIBOBJECTS = compress configfiles dictionary gridcompressor image mappings \
memmap mesh preprocessor textureGenerator tinyxml tinyxmlerror tinyxmlparser \
unionfind visibility
PREOBJECTS = main
all: ${BIN}
@echo All done.
lib: ${LIBOBJECTS}
preproc: ${PREOBJECTS}
@echo Linking pre-processor
@${CC} ${PREOBJECTS:%=pre/%.o} -o ${OUTPATH}preproc ${CFLAGS} \
${LIBOBJECTS:%=lib/%.o} ${LIBPATH:%=-L%} ${LIBS:%=-l%}
${LIBOBJECTS}: %:$(LIBPROJPATH)%.cpp
@echo Building library file $@.cpp
@cd lib; ${CC} ${CFLAGS} -c ../$< ${INCPATH:%=-I../%}
${PREOBJECTS}: %:$(PREPROJPATH)%.cpp
@echo Building pre-processor file $@.cpp
@cd pre; ${CC} ${CFLAGS} -c ../$< ${INCPATH:%=-I../%}
clean:
rm -f ./lib/*.o ./pre/*.o
rm -f ${OUTPATH}preproc |
Het gaat denk ik om:
code:
1
2
3
| ${LIBOBJECTS}: %:$(LIBPROJPATH)%.cpp
@echo Building library file $@.cpp
@cd lib; ${CC} ${CFLAGS} -c ../$< ${INCPATH:%=-I../%} |
Na elke make, worden alle files opnieuw gecompileerd. Ook als ik de .cpp files niet veranderd heb. Waarom gebeurt dit? De target is toch afhankelijk van de .cpp files, als die hetzelfde zijn moet het toch niet opnieuw gebeuren?