How to run Perl one liner from a makefile?

I know that perl one liner below is very simple, works and makes a global replacement, A for a; but how do I run it in a makefile?

perl -pi -e "s/a/A/g" filename

I tried (now I think the rest of the message is undesirable since the shell command does a command line extension - NOT WHAT I WANT!) The question above still stands!

APP = $(shell perl -pi -e "s/a/A/g" filename)

with and without the next line

EXE = $(APP)

and I always get the following error:

make: APP: Command not found

which I assume comes from the line that launches APP

thanks

+5
source share
2 answers

If you want to run perl as part of the target action, you can use

$ cat makefile
all:
        echo abc | perl -pe 's / a / A / g'
$ make
echo abc | perl -pe 's/a/A/g'
Abc

( , echo TAB).

Perl -i , make (, , ). . :

$ cat Makefile
all: bAr

bAr: bar.in
        perl -pe 's/a/A/g' bar.in > bAr
$ cat bar.in
bar
$ make
perl -pe 's/a/A/g' bar.in > bAr
$ cat bAr
bAr

, , , .

+4

Makefile, , , . , Makefile , . , APP all: .

APP = $(shell date)

all:
    APP

, :

APP = $(shell date)

all:
    $(APP)

perl, . Perl? perl -pi -e "s/a/A/g"

GNU make.

+1

All Articles