linux下使用objcopy与-g进行编译的方法

ifeq ($(debug), 0)
DEBUG_FLAG = -O2 -g
OBJ_DIR = release
BUILD_CONFIG = RELEASE
DBG_CONFIG = -DRWDEBUG=0 -D_RWCONFIG=m
else
DEBUG_FLAG = -g
OBJ_DIR = debug
BUILD_CONFIG = DEBUG
DBG_CONFIG = -D_DEBUG -DRWDEBUG=1 -D_RWCONFIG=md
endif

$(MOD_BIN):$(MOD_OBJ)
@mkdir -p $(dir $(MOD_BIN)) $(DBG_PATH)
@if [ -h "$(LibDir)/$(notdir $(MOD_BIN) )" ]; then rm -f "$(LibDir)/$(notdir $(MOD_BIN) )"; fi
$(CXX) -o $(MOD_BIN) $(MOD_OBJ) $(DEBUG_FLAG) $(LD_SO_FLAGS) $(LINKFLAGS) 2>>errlog
@objcopy --only-keep-debug $(MOD_BIN) $(DBG_PATH)/$(basename $(notdir $@)).dbg
@objcopy --strip-debug $(MOD_BIN)
@objcopy --add-gnu-debuglink=$(DBG_PATH)/$(basename $(notdir $@)).dbg $(MOD_BIN)
@if [ ! -h "$(LibDir)/$(notdir $(MOD_BIN) )" ]; then cp $(shell cd $(dir $(MOD_BIN));pwd)/$(notdir $(MOD_BIN)) $(LibDir)/$(notdir $(MOD_BIN) ); fi

你可能感兴趣的:(linux)