-2

My work is converting Linux command into CMake execute_process(COMMAND ...), and there are some differences between them, so i need to understand each Linux command. But this m4 command really beat me. The m4 command as below:

m4 -Isource/analyzer/ -P < source/analyzer/aParser.m4y > source/analyzer/aParser.by

What does this command mean?

I have read m4 document before, and it said the format of the m4 command is: m4 [option…] [file…], so i think in command:

m4 -Isource/analyzer/ -P < source/analyzer/aParser.m4y > source/analyzer/aParser.by

the -Isource/analyzer/ -P is [option...] of m4, and this m4 commad use<to read the file source/analyzer/aParser.m4y as m4 [file...], did i understand right?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Chao Zhang
  • 190
  • 2
  • 15
  • 1
    This quesion does not show any effort or research. Downvoting. – usr1234567 Apr 22 '16 at 08:52
  • [This page](http://www.gnu.org/savannah-checkouts/gnu/m4/manual/m4-1.4.17/html_node/Command-line-files.html#Command-line-files) explicitely says, that without specifying input file names `m4` reads *standard input stream*. Redirectrion `<` provides content for that stream. – Tsyvarev Apr 22 '16 at 09:37
  • @Tsyvarev, thanks a lot, i just want to confirm it, thanks for your help! – Chao Zhang Apr 23 '16 at 05:39

1 Answers1

5

m4 is a macro processor. Read its documentation (for GNU m4). It is a quite complex thing, so I won't try to abstract it in a few sentences. The -P option is prefixing builtins with m4_ so define becomes m4_define etc...

The < (and >) is not an option to m4, it is a general shell redirection.

Of course, you also need to study the documentation of cmake (which I personally don't like much, since GNU make 4 is powerful enough without cmake)

You probably should spend weeks in reading documentations, including Advanced Bash Scripting guide & Advanced Linux Programming (and the other documentations I pointed here).

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • I have read this document before, and it said the format of the m4 command is: `m4 [option…] [file…]`, i am wondering weather the `< source/analyzer/aParser.m4y` in the `middel `means `aParser.m4y` use `<` as the `[file…]`, and then wirte the content of `aParser.m4y` into `aParser.by` at the `last`? – Chao Zhang Apr 22 '16 at 07:34
  • 1
    I don't understand what you actually have understood. I strongly suggest to spend *weeks* in reading documentation. – Basile Starynkevitch Apr 22 '16 at 07:46
  • I mean in command:`m4 -Isource/analyzer/ -P < source/analyzer/aParser.m4y > source/analyzer/aParser.by`, `-Isource/analyzer/ -P` is `[option...]` of m4, and this m4 commad use`<`to read the file `source/analyzer/aParser.m4y` as `m4` `[file...]` – Chao Zhang Apr 22 '16 at 07:51
  • 1
    Please read documentation. I don't want and don't have time to explain you all the basics. I gave you many links. – Basile Starynkevitch Apr 22 '16 at 07:52
  • My project is very urgent, and this command is the last i have to process, i would surely like to reading documentation detailedly when i am free. Thanks for your help. :-) – Chao Zhang Apr 22 '16 at 07:53
  • Then, ask your boss to have some more weeks. Or to subcontract your own work. – Basile Starynkevitch Apr 22 '16 at 07:53