0

I'm writing my first Makefile...

This question is similar to this one but I want to point the Makefile to a specific directory of .js and .css files.. how do you do this?

I have this so far:

JS_TARGETS = $(find path/to/js/ -name '*.js')
CSS_TARGETS = $(find path/to/css/ -name '*.css')

.DEFAULT_GOAL := all

which doesn't work:

make: *** No rule to make target `all'. Stop.

Must be simple for someone who makes lots of Makefiles! Thanks :).

Community
  • 1
  • 1
ale
  • 11,636
  • 27
  • 92
  • 149

1 Answers1

2

Use wildcard function:

JS_TARGETS  := $(wildcard path/to/js/*.js)
CSS_TARGETS := $(wildcard path/to/css/*.css)

Or, if for some reasons you have to use find, invoke it using shell function as follows:

JS_TARGETS  := $(shell find path/to/js/  -name '*.js')
CSS_TARGETS := $(shell find path/to/css/ -name '*.css')

However, the first way is preferable as more portable and fast.

Eldar Abusalimov
  • 24,387
  • 4
  • 67
  • 71