gnu autotools:调试/释放目标? [英] gnu autotools: Debug/Release targets?

查看:132
本文介绍了gnu autotools:调试/释放目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一段时间:我目前正在将一个中型程序转换为autotools,来自基于eclipse的方法(使用makefiles)



我总是习惯于使用具有所有调试符号和无优化的调试版本,以及没有调试符号和最佳优化的发布版本。



现在我想用autotools以某种方式复制这个,所以我可以(可能)做类似的操作:

  ./ configure 
make debug

这将有所有调试符号和没有优化,其中:

  ./ configure 
make

会导致release版本(默认)



PS:我已经阅读过--enable -debug标志/功能,但在我目前的(简单)设置​​中,使用配置 c

configure.in configure.ac 文件中添加一个子句; / p>

  AC_ARG_ENABLE(debug,
AS_HELP_STRING([ - enable-debug],
[enable debugging,default :no]),
[case$ {enableval}in
yes)debug = true ;;
no)debug = false ;;
*)AC_MSG_ERROR([bad value $ {enableval} for --enable-debug]);;
esac],
[debug = false])

AM_CONDITIONAL(DEBUG,test x$ debug= xtrue)

现在在 Makefile.in Makefile.am ;

 如果DEBUG 
AM_CFLAGS = -g3 -O0
AM_CXXFLAGS = g3 -O0
else
AM_CFLAGS = -O2
AM_CXXFLAGS = -O2
endif

因此,当启用 debug 时,您可以修改 {C / CXX} FLAGS 启用调试信息。


I've been looking for this for a while: I'm currently converting a medium-size program to autotools, coming from an eclipse-based method (with makefiles)

I'm always used to having a "debug" build, with all debug symbols and no optimizations, and a "release" build, without debug symbols and best optimizations.

Now I'm trying to replicate this in some way with autotools, so I can (perhaps) do something like:

./configure
make debug

Which would have all debug symbols and no optimizations, and where:

./configure
make

Would result in the "release" version (default)

PS: I've read about the --enable-debug flag/feature, but in my current (simple) setup, using that is unrecognized by configure

解决方案

Add a clause to your configure.in or configure.ac file;

AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
               [enable debugging, default: no]),
[case "${enableval}" in
             yes) debug=true ;;
             no)  debug=false ;;
             *)   AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],
[debug=false])

AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")

Now in your Makefile.inor Makefile.am;

if DEBUG
AM_CFLAGS = -g3 -O0
AM_CXXFLAGS = -g3 -O0
else
AM_CFLAGS = -O2
AM_CXXFLAGS = -O2
endif

So when debugis enabled you can modify your {C/CXX}FLAGSto enable debug information.

这篇关于gnu autotools:调试/释放目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆