我如何构建严格本地的文件夹(不是完整的全局系统安装)来试验 GDB(Stallman 的书)这个 M4 宏处理器?

问题描述 投票:0回答:1

这个“迷宫”以一种无辜的方式开始:“只是用

gdb
书中提出的可执行文件进行调试”。这本“学习如何调试书”的作者选择的程序是这个
m4
宏处理器。 问题是 m4 已经以其最新版本出现在我的 linux 中(正如许多人所知的许多其他人一样),并且是用于许多任务的关键程序。所以不是直接调整的好目标。 我在 2023 年 2 月 11 日发布了一个问题(下面的 SO 链接),我收到了很多有用的帮助。 在按照答案的说明进行操作之前,我决定在
configure, make, make install
git
(所有这些都很有趣。目标,标签,别名,层次结构等)中获得更多的知识。为了更深入地了解我要做什么,而不仅仅是盲目地输入命令。

我在这篇文章的回答中选择了第二个选项(选择了

m4
的 2000 年回购版本,而不是 1988 年的版本,后者会增加额外的难度,即必须调整甚至构建一个
gcc
版本会接受那些 1988 年的消息来源)。

经过经历过的问题(见下文),我现在的问题是:

不可能只做一个

gcc -o m4 foo.c bar.c ....
等......并生成一个纯本地文件夹的可执行文件来直接用
GDB
进行实验(这从一开始就是所有这一切的主要目标)。避免与合法/本机 m4 发生任何冲突,并避免覆盖(即写入 /bin/m4)现有的和最新的 m4 安装。 这仅仅是构建脚本上的“标志”问题吗? 如何才能做到这一点?

最终目标是能够做到这一点:

gdb ./m4

(并故意在 m4 的 *.c 源代码上放置错误,并遵循本书必须教授的所有内容。第一个错误部分已经由评论员在古老的帖子中解决了。但首先我必须得到它来编译和构建(本地)可执行文件。否则我什么也做不了)。

(这段旅程,从这里开始: 卡在 Stallman 的 GDB 书中尝试调试 m4(宏处理器)“错误”示例:我拥有的 m4 可执行文件是 /bin 中的直接 bin(没有“.../gnu/./m4”)

这一切都是用 git 检索的:

$ git clone git://git.sv.gnu.org/m4
$ git checkout branch-1.4

这就是我所做的: 这是文件夹的样子:

$ ls
acinclude.m4    build-aux       configure     gnulib       NEWS    TODO
AUTHORS         c-boxes.el      configure.ac  HACKING      po
autom4te.cache  cfg.mk          COPYING       INSTALL      README
BACKLOG         ChangeLog-2014  doc           lib          src
bootstrap       checks          examples      m4           tests
bootstrap.conf  config.log      gl            Makefile.am  THANKS

当我输入 autoreconf 时:

$ autoreconf
configure.ac:230: warning: macro 'AM_GNU_GETTEXT' not found in library
configure.ac:231: warning: macro 'AM_GNU_GETTEXT_VERSION' not found in library
sh: 1: build-aux/git-version-gen: not found
configure.ac:25: error: AC_INIT should be called with package and version arguments
/usr/share/aclocal-1.16/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
configure.ac:25: the top level
autom4te: error: /usr/bin/m4 failed with exit status: 1
aclocal: error: /usr/bin/autom4te failed with exit status: 1
autoreconf: error: aclocal failed with exit status: 1

当我输入 autoconf configure.ac 时:

$ autoconf configure.ac
-- snippet (just the errors) --
configure.ac:25: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:27: error: possibly undefined macro: AM_SILENT_RULES
configure.ac:36: error: possibly undefined macro: M4_EARLY
configure.ac:155: error: possibly undefined macro: M4_INIT
configure.ac:223: error: possibly undefined macro: M4_WITH_DMALLOC
configure.ac:230: error: possibly undefined macro: AM_GNU_GETTEXT
configure.ac:231: error: possibly undefined macro: AM_GNU_GETTEXT_VERSION
           

当我输入 ./configure 时:

$ ./configure 

./configure: line 2273: syntax error near unexpected token `1.11.6'
./configure: line 2273: `AM_INIT_AUTOMAKE(1.11.6 dist-bzip2 dist-xz color-tests parallel-tests'

)

gcc makefile gdb configure m4
1个回答
0
投票

Mark Plotnik> 运行

./bootstrap
,然后
autoreconf
.

谢谢 @MarkPlotnick 先生,听起来不错。问题是......这会覆盖本机 m4 安装

不,它没有。

它创建一个

Makefile
,您可以使用它来构建和调试
m4
的本地构建。

Makefile
会覆盖原生
m4
安装 附言要回答原来的“可能只是做一个make install
”,答案是肯定的,
但是它需要一个gcc -o m4 foo.c bar.c ....

文件。

您可以手写
config.h,但这有点难。通常这个文件是通过运行 config.h
 生成的,你会更好地使用 
./configure

./configure

.
© www.soinside.com 2019 - 2024. All rights reserved.