tags:

views:

345

answers:

4

I have Makefile under a directory and directory has many .pm ( perl files ) I want to add makefile at this directory level which does perl file syntax checking. Basically I want to add:

perl -c <filename>

How to get list of files automatically in that directory without hardcoding.

+1  A: 

You can try the filter command:

PMFILES=$(filter %.pm, $(SRC))

Documentation for filter is hard to find. See here for an example.

kgiannakakis
+1  A: 

This is the normal workaround:

check_pm_syntax:
        for file in *.pm; do ${PERL} -c $$file; done

You run 'make check_pm_syntax' and it goes off and runs the shell loop for all the *.pm files it can find. You can simply list check_pm_syntax as a pre-requisite for your all target if you like (but it means you'll always do work when you build all). The only time this causes trouble is if there are no *.pm files in the directory.

Jonathan Leffler
this one works for me Thanks.
Avinash
A: 

thanks guys, check_pm_syntax solutions works form me.

Avinash
A: 

Here's a slightly different approach:

.PHONY: check_%.pm
check_%.pm:
    perl -c $*.pm

check_all: $(addprefix check_,$(wildcard *.pm))
Beta