Circuit Macros helper script

Programming — Alex @ 5:55 pm

For some reason or another, I’m always installing the Circuit Macros package by Dwight Aplevich. The part that always takes the most time is going through and changing the definition for HOMELIB_ in each of the m4 files. So here’s a little script that does that for you automagically.

[perl]
#!/usr/bin/perl

# The directory that CircuitMacros was unzipped into (with trailing /)
$cdir = $ARGV[0];

# The directory that changed files should be sent to (with trailing /)
$outdir = $ARGV[1];

@m4files = < $cdir*.m4 >;

foreach $file (@m4files) {
$sanitizedfile = $file;
$sanitizedfile =~ s/$cdir//;
$cmd = ” sed ’s/\/u\/aplevich\/lib\//\/home\/wherever\/libs\//’ $file > $outdir$sanitizedfile”;
print “$cmd \n”;
system($cmd);
}
[/perl]

Possibly relevant posts:

2 Comments »

  1. Another way to do it is to create an M4 library file, (say) homelib.m4, in the directory pointed to by the M4PATH variable containing:

    divert(-1)
    define(`HOMELIB_’,`’)
    divert(0)dnl

    The first line immediately following .PS in the Circuit Macro file should then just include this homelib.m4 “library” file, e.g.:

    .PS
    include(homelib.m4)


    .PE

    Comment by Peter-Jan Randewijk — 6/15/2005 @ 8:40 am
  2. Sweet! this will be easier to remember— once I look up divert(). Thanks.

    Comment by Alex — 6/15/2005 @ 12:47 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2008 ChapterZero | powered by WordPress with Barecity