0

I have a simple makefile which takes care of building my website by moving assets from ~/static_source to ~/static. However, when I add my Javascript folder to the makefile, my HTML and CSS stop compiling! When I comment out the JS block, my HTML and CSS compiles again.

Bad Version

LESS = $(wildcard static_source/styles/*.less)
CSS = $(patsubst static_source/%.less,static/%.css,$(LESS))
static/styles/%.css: static_source/styles/%.less static_source/styles/base.less static_source/styles/header.less
    lessc $< $@

HTML = $(patsubst static_source/%,static/%,$(wildcard static_source/*.html))
static/%.html: static_source/%.html
    ln -s ../$< $@

#This stops CSS and HTML from running. Perhaps it's because static/scripts is a folder?
JS = static/scripts
static/scripts: static_source/scripts
    ln -s ../$< $@


all: $(CSS) $(HTML)

Good Version:

LESS = $(wildcard static_source/styles/*.less)
CSS = $(patsubst static_source/%.less,static/%.css,$(LESS))
static/styles/%.css: static_source/styles/%.less static_source/styles/base.less static_source/styles/header.less
    lessc $< $@

HTML = $(patsubst static_source/%,static/%,$(wildcard static_source/*.html))
static/%.html: static_source/%.html
    ln -s ../$< $@

#This stops CSS and HTML from running. Perhaps it's because static/scripts is a folder?
JS = static/scripts
#static/scripts: static_source/scripts
#   ln -s ../$< $@


all: $(CSS) $(HTML)

I do not know why the scripts folder is being created with the "bad" version (nothing depends on it), or why the static/scripts rule prevents HTML and CSS from being created.

The only output from the bad version, as of the second running, is "make: 'static/scripts' is up to date." The output from the good version, as of the second running, is "make: Nothing to be done for 'all'."

DDR
  • 392
  • 1
  • 4
  • 14

1 Answers1

0

Ah, How does "make" app know default target to build if no target is specified? applies - it seems make uses the first "plain" rule as the default. So, since in this case static/scripts is before all, the fix is to explicitly set all to be the default rule. Prepend:

.DEFAULT_GOAL := all
Community
  • 1
  • 1
DDR
  • 392
  • 1
  • 4
  • 14