configure文件如何配置加上debug的功能?

netxuning 2009-09-29 02:52:16
我正在编译一个软件,make的时候,gcc都没有加-g选项,所以gdb无法很好的调试!
以下是这个configure文件的内容,我需要如何编写能够像一般的然间那样
./configure --debug后便可在make过程中,所有的gcc命令都加上-g选项?


#!/bin/bash

# configure adns
(cd adns; ./configure)

#configure larbin itself
cat /dev/null > config.h
cat /dev/null > config.make

if [ -e /proc/self/status ]; then
echo "#define HAS_PROC_SELF_STATUS" >> config.h
fi

# find existing programs
function exists () {
command -v $1 2> /dev/null > /dev/null;
}

if exists gmake; then
echo "MAKE=gmake" >> config.make
export MAKE=gmake
else
echo "MAKE=make" >> config.make
export MAKE=make
fi

if exists gcc; then
echo "CC=gcc" >> config.make
export CC=gcc
fi

if exists g++; then
echo "CXX=g++" >> config.make
fi

#find libraries to use
echo "int main () { return 0; }" > test.c

function testlib () {
if $CC $1 -o test test.c 2> /dev/null > /dev/null; then
echo "LIBS +=" $1 >> config.make
fi
}

testlib -pthread
testlib -lpthread
testlib -lresolv
testlib -lsocket
testlib -lnsl

rm -f test test.c test.o

# run make dep
touch .depend
touch adns/.depend
touch src/.depend
touch src/fetch/.depend
touch src/interf/.depend
touch src/utils/.depend
$MAKE dep

...全文
2231 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wen287877566 2009-10-05
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 hulihong 的回复:]
可以修改Makefile文件,在其中加上这一句就可以了:CFLAGS = -Wall –g
[/Quote]
一般这样就可以很好的调试自己的代码,这个时候你还可以测试一下自己的程序的内存是不是有泄漏,用valgrind这个工具:
netxuning 2009-09-30
  • 打赏
  • 举报
回复
如果我想通过 ./configure --enable-debug这样很方便地加上-g

有什么技巧呢?
HULIHONG 2009-09-30
  • 打赏
  • 举报
回复
可以修改Makefile文件,在其中加上这一句就可以了:CFLAGS = -Wall –g
fantasy614 2009-09-30
  • 打赏
  • 举报
回复
这样是必须要在MAkefile文件里加入那个选项的
bourbaki 2009-09-29
  • 打赏
  • 举报
回复 1
一般情况都是这样
./configure --enable-debug
steptodream 2009-09-29
  • 打赏
  • 举报
回复
直接在Makefile文件的 CC=gcc -g 这样不行吗
luobinshan 2009-09-29
  • 打赏
  • 举报
回复
一般执行 ./configure --help
看看有没有debug选项以及如何开启这个选项

如果没找到, 可以直接在Makefile文件的 CC=gcc -g

23,216

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧