m4

AM_PATH_PYTHON for python2 and python3

六眼飞鱼酱① 提交于 2021-01-27 06:59:25
问题 I am using automake's macro AM_PATH_PYTHON to find the pythondir variable. Till now I have been calling it without arguments which defaults to python 2.7 on Ubuntu. Now I also want to build it for python3.x (3.3 specifically). Is there a way where I can call AM_PATH_PYTHON([3]) to get python3.3 , store all the generated variables using AC_SUBST in a python3 specific variable and then call AM_PATH_PYTHON([2]) for python2 . I am doing this AM_PATH_PYTHON([3]) AC_SUBST(PYTHON3,$PYTHON) AC_SUBST

How to indent a block of text in an m4 macro

久未见 提交于 2020-01-15 04:56:27
问题 Is there a good way to uniformly indent a block of text in an m4 macro? In other words, the macro define(`mytext',dnl This is a piece of text that I would like to indent) mytext generates This is a piece of text that I would like to indent I'd like to have a way to indent the whole block of text to a specified amount. 回答1: How about patsubst: patsubst(mytext,`^', ` ') 来源: https://stackoverflow.com/questions/29026753/how-to-indent-a-block-of-text-in-an-m4-macro

make m4 see macro when macro ends with same character as string following macro

人走茶凉 提交于 2020-01-04 14:20:53
问题 I'm working on a system that uses M4 to expand some files out, but I'm getting a problem with the expansion in certain cases. The convention for definition / macro naming (which I'd rather not change if possible) is __<name>__ (i.e. double leading and trailing underscores.) So this expands correctly: define(`__ROOT__', `/home/mydir') ... __ROOT__/bin gives /home/mydir/bin but, define(`__PREFIX__', `App_Mnemonic') ... __PREFIX___some_service should give: App_Mnemonic_some_service but gives _

Using m4 to convert a string to ASCII codepoints

一曲冷凌霜 提交于 2019-12-22 14:44:07
问题 This should be possible, but as I am a novice with m4, I'm not sure how to go about it, or how to write an algorithm to do so (in m4). edit: Just solved it, anyway for future reference, I have a series of characters, they need to be translated to their equivalent ASCII code points, e.g. ascii(-{COLON}-, -{:}-) => #define TKN_COLON 58 回答1: For the benefit of others interested in a pure m4 implementation I've managed to create the following conversion macro. It has to meddle with the quoting

M4 eval precision

核能气质少年 提交于 2019-12-22 11:33:46
问题 I'm trying to use M4 macros to generate css files. I'm willing to enter my values in px and do simple math using eval() to get results in em. Unfortunatly I didn't find how to get floats. define(`FONTSIZE', `13')dnl define(`LINEHEIGHT', `17')dnl .content {padding : eval(LINEHEIGHT / FONTSIZE)em} >>> m4 style.css.m4 >>> .content {padding : 1em} Any ideas? Thanks! 回答1: For your particular purpose the expression may become something like eval(LINEHEIGHT/FONTSIZE).substr(eval(((LINEHEIGHT

Using m4 macros with Eclipse & Java

删除回忆录丶 提交于 2019-12-18 09:07:13
问题 Is there a way to use m4 macros when developing in Java for Eclipse, ie. making sure the preprocessor is automatically invoked before Eclipse compiles? Or has anyone used another preprocessor successfully with Eclipse? 回答1: You can specify an arbitrary builder on an Eclipse project, and order the builder so that it is executed before the Java builder is run. To define the new builder, open the project properties (right click->Properties or alt - enter ), select Builders then New... . Select

How to match newlines in GNU M4 _properly_

风流意气都作罢 提交于 2019-12-13 02:41:37
问题 I am trying to craft a macro replacing newlines. My first try was: define(`m4_pascal_str',` patsubst(`$1',`^\(.*\)$',`\1++') ') m4_pascal_str(` 11 22 33 44 ') define(zz,` 11 22 33 44 ') m4_pascal_str(`zz') That gives correct answer when not using intermediate macro, and match only last newline otherwise. See results below: ++ ++ 11++ ++ 22 33 44++ ++ 11 22 33 44 ++ Then I found similar question: in m4's patsubst, how do I replace newlines with spaces? So, I just made: define(`m4_pascal_str',`

m4 preprocessor BC macro

◇◆丶佛笑我妖孽 提交于 2019-12-13 01:08:19
问题 Relative to this question, I'd like to define a BC m4 macro of that function: syscmd(bc <<< "scale=6; print ARITHMETIC_OPERATION_STRING") NB: It just process an arithmetic operation with bc , for ex: syscmd(bc <<< "scale=6; print 1.2*2") => 2.4 I guess something like: define(`BC', syscmd(bc <<< "scale=6; print $1")) but how to expand other variables in BC argument , eg: define(`ONEPOINTTWO', `1.2') define(`TWO', `2') BC(ONEPOINTTWO*TWO) => 2.4 Thank you 回答1: define(`BC', `syscmd(echo "scale=6

In m4, how do you include a file that has an environment variable in its name?

强颜欢笑 提交于 2019-12-12 16:19:46
问题 I want to include a file based relative to my sandbox base directory inside of my m4 text without using the -I switch. So far, I have figured out how to grab the environment variables using a sys call: define(MODEL_ROOT,`syscmd(`printf $MODEL_ROOT')')dnl Next, I want to include a file based off that environment variable: include(MODEL_ROOT/sw/lib/m4_macros/foreach2.m4) In total, I have: define(MODEL_ROOT,`syscmd(`printf $MODEL_ROOT')') MODEL_ROOT MODEL_ROOT/sw/lib/m4_macros/foreach2.m4

error while installing ocamlfind.1.3.3 configure: m4 not in PATH; this is required

一曲冷凌霜 提交于 2019-12-12 12:34:58
问题 configure: m4 not in PATH; this is required I wonder how I can fix this. Thanks a lot! (I tried to copy the m4 folder to that path but it is not working) ==== ERROR [while installing ocamlfind.1.3.3] ==== # opam-version 1.0.0 # os linux # command ./configure -bindir /home/airobert/.opam/4.01.0dev+trunk/bin -sitelib /home/airobert/.opam/4.01.0dev+trunk/lib -mandir /home/airobert/.opam/4.01.0dev+trunk/man -config /home/airobert/.opam/4.01.0dev+trunk/lib/findlib.conf # path /home/airobert/.opam