in reply to Re: how to create makefile?
in thread how to create makefile?

Perhaps, I have mixed up the c makefile with perl makefile. as we put all c programs in the make file, we compile and then, we run, I thought that I can run automatically the perl programs in the same manner.

Regarding the dependency, the first script has to be finished without error as it generates files for the 2nd script. beyond that there is no other dependency.

I should perhaps have said that all modules, mod1, ..., mod4 and pgm1 and pgm2 are in the same directory. If they are not, I think for the modules, the path should be given after -I.

Replies are listed 'Best First'.
Re^3: how to create makefile?
by Corion (Patriarch) on Jan 09, 2015 at 09:23 UTC

    This sounds like a great job for make, but this is Perlmonks, not makemonks. I suggest that you learn about make and then use that knowledge to create the appropriate Makefile. If you want to implement this in Perl, there is Algorithm::Depends, which allows you to list file dependencies and then perform actions based on the dependencies.

    The Makefile for your case would likely be something like the following. You will need to preserve the tabs, because tabs are special characters in make:

    .PHONY all all: resultfile1 resultfile2 resultfile1: perl -I -Mmod1 -Mmod2 pgm.pl paramFile resultfile2: resultfile1 perl -I -Mmod3 -Mmod4 pgm2.pl paramFile2

    As you haven't told us the names of the resulting files of the program runs, I've substituted resultfile1 and resultfile2 for them.

      so, do I not have to use

      use ExtUtils::MakeMaker; WriteMakefile( NAME => 'myPgm', VERSION => .... );

      with your code for the make or they are 2 different things? If different, how to run yours, just by typing make or perl fileName.PL?

        No. ExtUtils::MakeMaker is for creating a Makefile for module installation.

        If your process is not about module installation for Perl, ExtUtils::MakeMaker is the wrong tool.

        Maybe now it's time for you to explain what the actual goal is and why you think that a Makefile is the appropriate tool.

Re^3: how to create makefile?
by Anonymous Monk on Jan 09, 2015 at 10:09 UTC