CUR_DIR = $(shell pwd) CFLAGS = -g -Wall
GCC = gcc
GXX = g++ TARGET = exe.out SRC_FILES += $(shell find $(CUR_DIR) -name *.cc) \
+= $(shell find $(CUR_DIR) -name *.cpp) OBJS = fatal-impl.o log.o INCLUDE += -I.
RM = rm -f LINK =
CFLAGS = -DNS3_LOG_ENABLE -g -Wall -O0 all: $(OBJS) test.o
$(GXX) $(CFLAGS) $^ -o $(TARGET) $(LINK) test.o: test.cpp
$(GXX) -c $(CFLAGS) $^ -o $@ $(OBJS): %.o : %.cc
$(GCC) -c $(CFLAGS) $(INCLUDE) $< -o $@ .PHONY : clean
clean:
$(RM) $(OBJS)
$(RM) $(TARGET)
上面-D选项放在-c选项前宏定义不起作用,修改放在-c选项后面后ok,
相当于在需要编译的文件最开始位置添加#define xxx