[pm-h] can a makefile invoke a perl script?

Russell L. Harris rlharris at oplink.net
Wed Sep 5 04:38:38 PDT 2007


For a week now I've been trying without success to solve this problem
using gnu make and bash.  Here is what I have been trying to do:

The context is my web site, which is automatically regenerated by a
single makefile.  In the course of modifying the web site, I now need
to change the make file so that it transfers a mixed group of files
from a main directory, sorting them into several subdirectories.  The
source files are:

    main/red-17
    main/red-23
    main/red-28
    main/...

    main/green-20
    main/green-33
    main/...

    main/yellow-5
    main/yellow-22
    main/...

The destination files are:

    main/sub-red/red-17
    main/sub-red/red-23
    main/sub-red/red-28
    main/sub-red/...

    main/sub-green/green-20
    main/sub-green/green-33
    main/sub-green/...

    main/sub-yellow/yellow-5
    main/sub-yellow/yellow-22
    main/sub-yellow/...

I have been searching for a way to apply 'make' functions such as
$(dir ...), $(suffix ...), $(basename ...), $(filter ...), etc., to
the index of a bash for-loop, to enable operations such as:

    directories := red green yellow
        
        (for d in $(directories:/=);    
            do    
                (for f in *;    
                    do    
                        cp $(nodir $$f) $$d;    
                    done;)    
            done;)
    
But expressions such as $(nodir $$f) appear not to return a value.

It occurs to me that Perl might offer a better approach, if only a
makefile can invoke a Perl script.  I have not yet found an answer in
the GNU make manual.

RLH


More information about the Houston mailing list