我正在开发一个使用 makefile 来制作目标的项目。在这里,我很困惑 makefile 如何从 .cpp 文件生成 .o 文件。
像文件 clientthread_level1_unix.o 必须从 clientthread_level1_unix.cpp 文件生成。但是没有指定使用 *.cpp 文件的地方。
EXTRALIBS = -pthread -lz -ldl -lm
OPENGLLIBS =
LDFLAGS_GL =
LDLIBS = ${APPEXTRALIBS} ${top_builddir}/lib/libwx_based-2.6.a ${EXTRALIBS}
# Compiler used
CXX = c++
CC = gcc
CANALOBJS = ../../common/listenthread_unix.o ../../common/clientthread_level1_unix.o ../../common/devicethread_unix.o \
../../common/canalshmem_level1_unix.o ../../common/clientlist.o ../../common/controlobject.o \
../../common/devicelist.o ../../common/udpreceivethread_unix.o ../../../vscp/common/vscp.o \
../../common/clientthread_level2_unix.o ../../common/canalshmem_level2_unix.o \
../../common/tcplistenthread.o
CANALHDRS = ../../common/clientlist.h ../../common/controlobject.h ../../common/devicelist.h \
../../common/canal.h ../../common/canaldlldef.h \
../../common/version.h ../../common/canal_unix_ipc.h ../../common/CanalShMem_level1_unix.h \
../../common/CanalShMem_level2_unix.h ../../common/clientthread_level1_unix.h ../../common/clientthread_level2_unix.h
PROJOBJS = ../../../common/dllist.o ../../../common/configfile.o ../../../common/crc.o
PROJHDRS = ../../../common/dllist.h ../../../common/configfile.h
OBJS = canald.o
HDRS = canald.h
all: canald
# Build the Linux executable
canald: $(OBJS) $(HDRS) $(CANALOBJS) $(CANALHDR) $(PROJOBJS) $(PROJHDRS)
$(CXX) $(OBJS) $(CANALOBJS) $(PROJOBJS) -o canald $(LIBS) $(LDLIBS)
如果我们也使用隐式规则,那么canald目标也不是这样。 http://www.gnu.org/software/make/manual/make.html#make-Deduces http://www.gnu.org/software/make/manual/make.html#Implicit-Rules
请问这条生产线是如何生产运河的?
$(CXX) $(OBJS) $(CANALOBJS) $(PROJOBJS) -o canald $(LIBS) $(LDLIBS)