Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile all less file using a makefile

Tags:

makefile

I have a number of less file that I would like to compile using a makefile.

DEBUG=yes
LESS_FILES= static/backend/css/styles.less static/frontend/css/styles.less

ifeq ($(DEBUG),yes)
    LESSC=lessc
else
    LESSC=lessc -x
endif


less: $(LESS_FILES)

%.css: %.less
    $(LESSC) $< > $@

I created this makefile, but when starting make less I get :

make: Rien à faire pour « less ».

The file .css doesn't exists yet. What's wrong ?

like image 264
Natim Avatar asked Dec 05 '11 12:12

Natim


2 Answers

I've got it ! Sometimes it's help to ask the question to find the answer ...

DEBUG=True
LESS_FILES= static/admin/css/modulo_admin.less
CSS_FILES=$(LESS_FILES:.less=.css)

ifeq ($(DEBUG),True)
    LESSC=lessc
else
    LESSC=lessc -x
endif

less: $(CSS_FILES)

%.css: %.less
    $(LESSC) $< > $@
like image 146
Natim Avatar answered Nov 13 '22 05:11

Natim


Note that the target less depends upon the source files. Those already exist and are up-to-date.

I suggest changing the less target to look more like this:

less: $(CSS_FILES:.less=.css)

(Untested, I don't have the lessc tool installed, nor suitable input files.)

like image 32
sarnold Avatar answered Nov 13 '22 04:11

sarnold