Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Make vs. Perl

by tedv (Pilgrim)
on Nov 15, 2000 at 21:34 UTC ( #41803=perlmeditation: print w/replies, xml ) Need Help??

I'm currently working on a project at work that that involves running some programs which generate special assembler source files which are in turn compiled and run on two different internal simulators and compared to an expected output. Since there's a lot of dependancies, and many situations where we wouldn't need to recompile code (on different levels), "make" seemed like a good fit, although I hadn't used it before. In just a day of working with make, I realized that what it does (dependancies), it does very well. And everything else is so syntax burdened that it's nigh impossible to use elegantly.

What bothered me the most was that I felt like equivalent perl code would be less efficient because it lacked an easy way of tracking dependancies. Needless to say, I would much rather use Perl than make. Is there some way I can use perl to perform this dependancy checking shell scripting behavior in a far more elegant way than make?


Replies are listed 'Best First'.
RE: Make vs. Perl
by Fastolfe (Vicar) on Nov 15, 2000 at 21:44 UTC
    If you're looking for generic dependency-handling code (there are Perl implementations of 'make' I believe; don't re-invent the wheel), something recursive like this might work for you:
    my %dependencies = ( item1 => [ 'item2' ], item2 => [ qw' item3 item4 ' ], ); my %done; sub act_on { my $item = shift; $done{$item} = undef; # mark it early to avoid circular dependen +cies if (exists $dependencies{$item}) { foreach my $dep (@{$dependencies{$item}}) { warn "Circular dependency $item => $dep" if exists $done{$dep} and !$done{$dep}; &act_on($dep) unless exists $done{$dep}; } } # Dependencies satisfied, do whatever on $item print "Doing $item...\n"; $done{$item} = 1; # really done } act_on "item1"; Doing item3... Doing item4... Doing item2... Doing item1...
    Change the function name around if you like to make it more idiomatic if that's what you're looking for...
RE: Make vs. Perl
by knight (Friar) on Nov 15, 2000 at 22:23 UTC
    Nick Ing-Simmons wrote pmake, a Perl implementation of make. I don't know where to find it; a manual CPAN search didn't turn up anything, and there's another same-named "pmake" out there that's a parallel-implementation of make which returns more Google hits. Update:It uses the module, which is available on CPAN.

    Cons is a more "purely Perl" make substitute. The configuration files are Perl scripts that call an API to establish targets and dependencies. Dependency analysis and builds are all carried out by a single top-level executable, not through recursive invocation of the tool.

    makepp (a.k.a. make++) is a Perl re-implementation of make that preserves Makefile syntax, but uses the Cons build-engine model of a single top-level process.

    Lastly, Rich Miller created a utility named "perlmake" for IDX Systems Corp., but I don't think it's been publicly released.
      What about a module that gives me a make interface I can use from a script that does other things. I guess I could just do a system("make $foo") or "cons $foo" or whatever, but I was hoping for a module with a real API to set up dependancies and then fullfill them. I suppose this is what you're talking about. I'll take a look at that. I was hoping for something that wasn't so inbred with Make's horrendous syntax for pattern matching and whatnot...

        Cons has been talking for a long time about moving to an architecture like you're describing--a modular build engine to manage dependencies, with plug-in modules for various dependency scanners, compile tools, etc. The consensus among that community is that itwould be a Good Thing, but no one has actually had time or energy to go ahead and do it.

        I agree completely about the hassles arising from being so closely tied to Make's syntax.

        I'm not sure what you want to do in Perl that you couldn't do within a Cons config file itself, since it's just a Perl script. You shouldn't need to do a separate system("cons $foo").
RE: Make vs. Perl
by clemburg (Curate) on Nov 15, 2000 at 22:23 UTC

    See Cons, also covered in "Cons: A Software Construction System" - The Perl Journal, Spring 1998. This is what you want, I think.

    There is also pmake, but I think this is not what you want, since it merely emulates make in Perl.

    Christian Lemburg
    Brainbench MVP for Perl

RE: Make vs. Perl
by merlyn (Sage) on Nov 15, 2000 at 21:40 UTC

      updatemerlyn fixed the above, you can ignore this now : )

      after looking at the source for the node (which looked pretty funny) I think merlyn meant to say:

      "See this or that for "make-in-Perl" solutions."

      where this and that are my words placed between the <A href="... tags that merlyn supplied. I simply added those words and so the links would show up(they look useful). I did not change any other content. If I in any way altered the intent or meaning of the post please let me know.

      update: I lied. I did change the content. I forgot to mention that i changed the code in the first link to query CPAN for make not pmake, as pmake gave no results and make gave plenty of relevant ones...again, seemed to be a typo...

      <myExperience> $mostLanguages = 'Designed for engineers by engineers.'; $perl = 'Designed for people who speak by a linguist.'; </myExperience>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://41803]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-07-17 14:01 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (368 votes). Check out past polls.