Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix find with GNU Make to auto-update files

I have .haml files and want to convert them automatically into .html files and update the latter when .haml is changed.

The generic makefile rule is no problem:

%.html: %.haml
    hamlpy $< $@

But now I need a rule or a command to do the following:

  • find all X.haml files in templates/
  • execute make X.html command, where X is the same filename (haml is replaced with html).

I can't find how to do this with GNU Make or Unix find.

like image 626
culebrón Avatar asked Jul 30 '12 11:07

culebrón


1 Answers

If all of your *.haml files are well name (i.e. no spaces or other funny characters), you can do it with a call to find(1):

HAML_FILES = $(shell find templates/ -type f -name '*.haml')
HTML_FILES = $(HAML_FILES:.haml=.html)

all: $(HTML_FILES)

%.html : %.haml
        hamlpy $< $@
like image 88
Thor Avatar answered Sep 20 '22 19:09

Thor