Eu quero analisar um arquivo e colocar em colchete cada linha com #ifndef e #endif .
Por exemplo, começando com:
#define X 1
#define Y 2
#define Z 3
Eu quero gerar:
#ifndef X
#define X 1
#endif
#ifndef Y
#define Y 2
#endif
#ifndef Z
#define Z 3
#end if
Este script awk funciona no console, mas não funciona dentro de make :
awk '{printf "#ifndef %s\n%s %s %s\n#endif\n", $2, $1, $2, $3}' globals.tmp > globals.h
Quando executado dentro de make , é produzido da seguinte forma:
awk: cmd. line:1: {printf "#ifndef %s\n%s %s %s\n#endif\n", , , , }
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: {printf "#ifndef %s\n%s %s %s\n#endif\n", , , , }
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: {printf "#ifndef %s\n%s %s %s\n#endif\n", , , , }
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: {printf "#ifndef %s\n%s %s %s\n#endif\n", , , , }
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: {printf "#ifndef %s\n%s %s %s\n#endif\n", , , , }
awk: cmd. line:1: ^ unexpected newline or end of string
Então, obviamente, não está puxando os campos. Eu tentei brincar com $1 , $2 e $3 : adicionando barras invertidas simples, duplas e triplas, alterando as aspas, etc., nada funciona. Eu sei que awk e make podem ser peculiares, imaginando se há alguma "pegadinha" que não estou recebendo?