我想在单个 Makefile 中使用宏来编译两个程序。当我运行 make 时,它会产生以下输出:
Makefile:27: warning: overriding commands for target `compose'
Makefile:24: warning: ignoring old commands for target `compose'
g++ -g `Magick++-config --cppflags` -c alphamask.cpp
g++ -g `Magick++-config --ldflags` -o alphamask alphamask.o -L /usr/lib64/ -lglut -lGL -lGLU -lMagick++ -lm
它只编译第二个程序。有没有办法让宏编译两个程序?这是我当前的 Makefile:
CC = g++
C = cpp
CFLAGS = -g `Magick++-config --cppflags`
LFLAGS = -g `Magick++-config --ldflags`
ifeq ("$(shell uname)", "Darwin")
LDFLAGS = -framework Foundation -framework GLUT -framework OpenGL -lMagick++ -lm
else
ifeq ("$(shell uname)", "Linux")
LDFLAGS = -L /usr/lib64/ -lglut -lGL -lGLU -lMagick++ -lm
endif
endif
ALPHA = alphamask
COMP = compose
${ALPHA}: ${ALPHA}.o
${CC} ${LFLAGS} -o ${ALPHA} ${ALPHA}.o ${LDFLAGS}
${ALPHA}.o: ${ALPHA}.${C}
${CC} ${CFLAGS} -c ${ALPHA}.${C}
${COMP}: ${COMP}.o
${CC} ${LFLAGS} -o ${COMP} ${COMP}.o ${LDFLAGS}
${COMP}.o: ${COMP}.${C}
${CC} ${CFLAGS} -c ${COMP}.${C}
run:
./alphamask dhouse.png
./compose alphamask.png
clean:
rm -f core.* *.o *~ ${ALPHA} ${COMP}