Questions tagged [m4]

m4 is a general purpose macro processing language developed by Brian Kernighan and Dennis Ritchie.

m4 is a general purpose macro processing language developed by Brian Kernighan and Dennis Ritchie in 1977.

Various implementations of m4 exist, e.g. those in FreeBSD, NetBSD, OpenBSD, and the GNU implementation commonly found in Linux distributions.

GNU m4 is used extensively by GNU Autoconf. The GNU implementation addresses many limitations found in prior m4 implementations, like limits on line lengths and the number of macros in use.

212 questions
3
votes
2 answers

How can you do an ifdef guard for m4 macro file includes?

For C header files, you can prevent multiple inclusion of a header file like: #ifndef MY_FOO_H #define MY_FOO_H [...] #endif How can I do the same thing in m4 such that multiple include() macro calls to the same file will only cause the contents…
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
3
votes
3 answers

How to troubleshoot "Possibly undefined macro: AC_MSG_ERROR"

I'm trying to build libpsl from GutHub sources. Its requires an autoreconf. Autotools is failing with: # Try to reconfigure. Autotools is so broken... libtoolize --force && aclocal && autoheader && autoreconf --force --install ... libtoolize:…
jww
  • 97,681
  • 90
  • 411
  • 885
3
votes
1 answer

m4 - executing a shell command

I'm new to m4 and am trying to set up a macro which allows the user to specify the location of a library at configure-time ./configure --with-mylib=/path/to/lib.so. In the m4 macro using AC_ARG_WITH, I'll check that the given file actually exists,…
ajwood
  • 18,227
  • 15
  • 61
  • 104
3
votes
1 answer

Escaping Commas in m4 ifdef Statements

I'm using a combination of markdown and m4 to produce three different versions of a document depending on the flags given at the beginning. Let's call them Gold, Silver, and Bronze. The problem that I've come across is that if I have a section that…
aepksbuck
  • 367
  • 2
  • 10
3
votes
0 answers

Octave and warning "ARPACK library found, but does not seem to work properly; disabling eigs function"

Situation I work with Ubuntu 14.04. I am building GNU Octave 4.2.1 from source with GNU 6.3.0. This version of Octave is quite new, but I see the issue arising also when trying to compile older Octave releases (down to 3.8.1). I configure the build…
XavierStuvw
  • 1,294
  • 2
  • 15
  • 30
3
votes
0 answers

The GNU M4 macro for getting ascii code of character

I would like to implement a macro for calculating hashes of C-strings, and first thing, which I need, is getting codes of characters in string. My idea is use the builtin macro index with string, which includes all of 256 ascii characters, and the…
Kayo
  • 179
  • 8
3
votes
1 answer

AS_HELP_STRING multiple lines

Is there a way to get AS_HELP_STRING (or there's some alternative macro) to nicely format help on multiple lines? I've an --enable-option= which may take multiple values val1,val2,... and I'd like configure --help to show one help line for each…
Alex
  • 3,264
  • 1
  • 25
  • 40
3
votes
1 answer

How to use m4 with Python and dealing with indendentation and whitespace

Is there a good general strategy for using m4 with Python? Specifically, Python's whitespace requirements make using m4 somewhat awkward. For example, the following program: def foo(): pushdef(`X',` $1 = $2') include(test01.def) …
wyer33
  • 6,060
  • 4
  • 23
  • 53
3
votes
1 answer

How to tell AC_SUBST to not substitute variables in arguments?

I'm using autotools to build my project and I'd like to globally set AM_CPPFLAGS to -I$(top_srcdir)/include. https://stackoverflow.com/a/325436/2592351 this answer helped me and I'm doing the "include $(top_srcdir)/include" hack and it…
Ivan Dives
  • 477
  • 5
  • 9
3
votes
1 answer

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

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 …
user2608042
3
votes
1 answer

in m4's patsubst, how do I replace newlines with spaces?

How can I tell m4's patsubstr to replace all newlines in a string with a space? I've tried: patsubst(MULTI_LINE_STR_DEFINE,`\n',` ') and patsubst(MULTI_LINE_STR_DEFINE,`\\n',` ')
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
3
votes
1 answer

m4 expand macro inside words

I am very new to m4 but cannot find this simple thing: Is it possible to expand a macro in the middle of a word? (I would use it for a counter that would be used in a C symbol name in low-level code) I mean like: define(`foo',`bar') Happy…
dennis90
  • 239
  • 1
  • 4
  • 12
3
votes
1 answer

What is M4 composite macros, like foreach?

I would like to use m4 for doing some type-saving stuffs, so the loop will be definitely needed. When I read m4 doc, in chapter 6 there is 6.4 and 6.5 for iteration. But it looks like that foreach is not a builtin macro (Composite?), how could I use…
Li Dong
  • 1,088
  • 2
  • 16
  • 27
2
votes
1 answer

Add sources to build php extension

I want to write a test php extension, which will provide a test class. I want to extract class declaration into a separate C-File and call class registration from module init function of myext.c file. I have the following files: testlib/ …
Eugene Manuilov
  • 4,271
  • 8
  • 32
  • 48
2
votes
1 answer

GNU M4 seems to access unnecessary value in ifelse

I'm trying out the m4 CLI on linux and trying to create a for(begin, end, step) macro that will print out a comma separated list of numbers in the given range. I also want it to support a default step of 1. I tried the following [tom@sp4 ~]$…
NoComprende
  • 731
  • 4
  • 14
1 2
3
14 15