问题标签 [m4]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
38 浏览

autotools - 传统的自动工具条件测试有一个额外的“x”

x在自动工具中编写测试时,将字符放在可能为空的变量之前似乎是传统的做法,因此如果它们为空,您仍然会得到一个非空的字符串:

根据情况,变量variablethatneedscheckingforempty通常采用值yesno或空/未定义。

由于代码/bin/sh在使用前被转换为 shell,这似乎是多余的。或者是否有充分的理由在字符串中放置额外的字符?

0 投票
1 回答
1089 浏览

preprocessor - Pre-Processing using m4

I am writing a pre-processor for Free-Pascal (Course Work) using m4. I was reading the thread at stackoverflow here and from there reached a blog which essentially shows the basic usage of m4 for pre-processing for C. The blogger uses a testing C file test.c.m4 like this:

and generates processed C file like this using m4, which is fine.

My doubts are:
1. The programmer will write the code where the line

would be

then who converts this line to the above line? We can use tool like sed or awk to do the same but then what is the use of m4. The thing that m4 does can be implemented using sed also.
It would be very helpful if someone can tell me how to convert the programmer's code into a file that can be used by m4.

2. I had another issue using m4. The comment in languages like C are removed before pre-processing so can this be done using m4? For this I was looking for commands in m4 by which I can replace the comments using regex and I found regexp(), but it requires the string to be replaced as argument which is not available in this case. So how to achieve this?

Sorry if this is a naive question. I read the documentation of m4 but could not find a solution.

0 投票
1 回答
1163 浏览

python - 如何在 Python 中使用 m4 并处理缩进和空格

在 Python 中使用 m4 是否有一个好的通用策略?具体来说,Python 的空白要求使得使用 m4 有点尴尬。例如,以下程序:

test01.def作为

生成python程序:

因此,缩进关闭。当然,我们可以用

但是,我觉得我们编辑的文件变得很难看,因为在我们的代码组织中很难跟踪缩进。真的,我想做的是使用第一个程序并让 m4 在包含之前吃掉前导空格。我不确定 m4 是否有可能吃掉前导空格。

此外,我知道有 Python 特定的宏实用程序。但是,我对使用这些感兴趣。我需要在多种不同的语言中使用这些 X 宏,例如在 C 和 LaTeX 中,我打算在每种情况下使用 m4,因为它很容易获得并且与语言无关。因此,如果可能的话,我真的在寻找一种 m4 解决方案。

0 投票
1 回答
424 浏览

macros - 如何在 m4 宏中缩进一段文本

有没有一种在 m4 宏中统一缩进文本块的好方法?换句话说,宏

生成

我想有一种方法可以将整个文本块缩进到指定的数量。

0 投票
1 回答
221 浏览

c++ - 使用 Automake 为 bin_SCRIPTS 中的每个文件应用一个命令

在我的项目中,我有一组 bash 脚本,它们与 C/C++ 二进制文件一起复制到安装根目录。

问题是我必须在安装之前为每个 BASH 脚本运行一个命令。更具体地说,我必须用 autoconf 输出变量替换一个变量:

这是 Makefile.am 中定义脚本的位置

我想知道是否有任何标准的方法来处理这个问题。如果不是,我想用一些技巧来处理它。谢谢!

更新

我想出了一个 hack 来解决它,这里是 Automake 配方:

但我仍然想知道是否有标准的方法来做到这一点

0 投票
0 回答
1208 浏览

automake - 重新编译hunspell时如何告诉automake找到我的aclocal版本?

我目前正在从 Fedora 下载的 git 源重新编译 hunspell,如下所示:

正如 HACKING 中的步骤所述,我安装了所有先决条件并执行构建命令:

我收到了这个错误信息:

我的电脑安装了 automake 1.14。

当系统“制造”时,会发生有问题的陈述。无论如何我要告诉 make 找到我的 aclocal 吗?我试图在制作时追踪步骤。我应该发布列出的步骤吗?

谢谢大家。

0 投票
1 回答
1874 浏览

escaping - GNU m4:转义反引号(`)

一个简单的 GNU m4 问题,但我找不到正确答案。我想打印一个开始/结束代码部分的降价标头:

如何创建包含 3 个反引号的 GNU M4 宏?就像是

0 投票
1 回答
106 浏览

assembly - 如何更改 m4 的 --synclines 选项的注释符号?

我正在使用m4带有命令行选项的预处理器--synclines。此选项在每个展开的多行之后发出#line <nn>行。

例子:

结果:

因为 sr0(reg_0, 3) 起源于第 2 行,所以 m4#line 2在每次展开后添加。

如何将评论符号更改#;, 因为汇编器不支持#作为注释符号。

0 投票
2 回答
249 浏览

linux - 如果 AC_CHECK_HEADER 在 autoconf/configure.ac 中失败,如何为不同平台指定不同的反馈?

我检查configure.ac了源根目录中的头文件

我想在不同的平台上给出不同的反馈,以反映提供标题的不同最直接的方式:

  • 在 Debian 上,它应该会出现错误消息Couldn't find or include log4c.h. Install log4c using 'sudo apt-get install liblog4c-dev'
  • 在 OpenSUSE 上它应该会出错... Install log4c using 'sudo yum install log4c-devel'(没有研究包名,但你明白我的意思)
  • 在其他系统上(我懒得研究包名称)它应该出错... Install log4c by fetching ftp://.../log4c.tar.gz and installing with './configure && make && make install' in the source root

一世

  • 检查了AM_CONDITIONAL宏,但我不知道如何使用它configure.ac而不是使用它Makefile.am(如autoconf/automake: conditional compilation based on presence of library? 中所述)
  • esyscmd在 stackoverflow.com/questions/4627900/m4-executing-a-shell-command 中找到了要运行的提示,但是当我运行时添加esyscmd (/bin/echo abc)configure.ac不打印任何内容autoreconf --install --verbose --force

两个答案都描述了在没有提到的操作系统的 shell 命令的情况下使用条件宏以及指向预定义宏(如AC_CHECK_HEADER_DEBIANAC_CHECK_HEADER_SUSE等)的链接。

以下configure.ac不起作用:

因为./configure失败了

./configure: line 4427: #include: command not found无论是否AC_CHECK_HEADER指定,都会发生这种情况。

0 投票
2 回答
86 浏览

m4 - 需要 m4 宏将边距添加到任意文本

假设我定义了一个 m4 宏 FOOBAR,其中包含一段任意文本,其中可能包含逗号字符。请创建一个 m4 宏以将 5 个空格的左边距添加到 FOOBAR 文本的扩展中。

如果文本不包含任何逗号,问题很简单(只需使用带有“^”正则表达式的 patsubst)。但我需要处理逗号。

谢谢!