⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 Linux下编译及调用库文件的方法
💻
字号:
# Makefile
#
# ============================================================================
# Copyright (c) Cbus Inc 2009
#
# Use of this software is controlled by the terms and conditions found in the
# license agreement under which this software has been supplied or provided.
# ============================================================================

#在此输入需要添加的LIB库的名称LIB = -ltestROOTDIR = ./
TARGET = $(notdir $(CURDIR))

#include $(ROOTDIR)/Rules.make


C_FLAGS += -Wall
LD_FLAGS += -lpthread -L. $(LIB)

DBGTARGET = debug/$(TARGET)d
RELTARGET = release/$(TARGET)

#DBGCFLAGS = -g -D__DEBUGDBGCFLAGS = -g
RELCFLAGS = -O2 -fno-strict-aliasing

SOURCES = $(wildcard *.cpp)
HEADERS = $(wildcard *.h)
DBGOBJFILES = $(SOURCES:%.cpp=debug/%.o)
RELOBJFILES = $(SOURCES:%.cpp=release/%.o)
#COMPILE.cpp = $(CROSS_COMPILE)g++ $(C_FLAGS) $(CPP_FLAGS) -c
#LINK.cpp = $(CROSS_COMPILE)g++ $(LD_FLAGS)
COMPILE.cpp = g++ $(C_FLAGS) $(CPP_FLAGS) -c
LINK.cpp = g++ $(LD_FLAGS)
.PHONY: clean debug release install

all:	debug release

install:
	install -d $(EXEC_DIR)	install $(DBGTARGET) $(EXEC_DIR)	
	install $(RELTARGET) $(EXEC_DIR)
#	install -m 444 $(TARGET).txt $(EXEC_DIR)

release:	$(RELTARGET)

debug:		$(DBGTARGET)

$(RELTARGET):	$(RELOBJFILES)                     
	$(LINK.cpp) -o $@ $^ $(RELLDFLAGS)                             
                                                               
$(DBGTARGET):	$(DBGOBJFILES)                     
	$(LINK.cpp) -o $@ $^ $(DBGLDFLAGS)                             
                                                               
$(RELOBJFILES):	release/%.o: %.cpp $(HEADERS)     
	@mkdir -p release                                            
	$(COMPILE.cpp) $(RELCFLAGS) -o $@ $<
                                                               
$(DBGOBJFILES):	debug/%.o: %.cpp $(HEADERS) $(XDC_CFLAGS)        
	@mkdir -p debug                                              
	$(COMPILE.cpp) $(DBGCFLAGS) -o $@ $<


clean:
	-$(RM) -rf release debug *~ *.d .dep


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -