GNU 自动工具:调试/发布目标? [英] GNU autotools: Debug/Release targets?

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

问题描述

我一直在寻找这个:我目前正在将一个中等大小的程序转换为 autotools,来自基于 Eclipse 的方法(带有 makefile)

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.

现在我正在尝试使用 autotools 以某种方式复制它,因此我可以(也许)执行以下操作:

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:我已经阅读了 --enable-debug 标志/功能,但在我当前的(简单)设置​​中,configure

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

推荐答案

在您的 configure.inconfigure.ac 文件中添加子句;

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")

现在在你的 Makefile.inMakefile.am;

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

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

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

这篇关于GNU 自动工具:调试/发布目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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