Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Perl from within a makefile

by sg (Pilgrim)
on Dec 17, 2007 at 02:49 UTC ( #657363=perlquestion: print w/replies, xml ) Need Help??

sg has asked for the wisdom of the Perl Monks concerning the following question:

Starting with a c-header file, foo.h, that has the line:
#define VERSION_STRING "Foo built Sun Dec 16 21:40:50 2007"
I would like to update the time-stamp portion of the line by issuing the command:
make version
I can write a perl script that makes the update, and have the command "make version" end up calling that script. I am wondering if there a way to in-line perl in the Makefile to achieve the same end?

Replies are listed 'Best First'.
Re: Perl from within a makefile
by educated_foo (Vicar) on Dec 17, 2007 at 02:57 UTC
    It seems like perl -e 'YOUR_SCRIPT...' should do the trick.
Re: Perl from within a makefile
by tachyon-II (Chaplain) on Dec 17, 2007 at 05:23 UTC

    You can execute anything you can do in the shell in your makefile so you can just insert a one liner. Note that quoting conventions differ on Win32 and *nix so this is not entirely portable.

    #define VERSION_STRING "Foo built Sun Dec 16 21:40:50 2007" version: perl -pi.old -e 's/(VERSION_STRING[\w\s\"]+built )[^\"]+/$$1.local +time/e' Makefile

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://657363]
Approved by randyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2022-11-29 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?