aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 43b5fd96bb006456a19df27cd77227e6544607d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
include config.mk

CSS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/css/ -type f -name '*.css'))
LESS_FILES = $(patsubst assets_src/%.less, assets/%.css, $(shell find assets_src/css/ -type f -name '*.less'))
JS_FILES = $(patsubst assets_src/%, assets/%, $(shell find assets_src/js/ -maxdepth 1 -type f -name '*.js'))

BROWSERIFY := ./node_modules/browserify/bin/cmd.js
LESSC := ./node_modules/less/bin/lessc

rewrite_imports = "s/(require\([\"'])lib/\1.\/lib/g"

all: .npm_update $(CSS_FILES) $(LESS_FILES) $(JS_FILES)

print_info:
	@echo $(CSS_FILES)
	@echo $(LESS_FILES)
	@echo $(JS_FILES)

.npm_update: package.json
	touch $@
	npm install

package.json: package.json.tpl config.mk
	export NAME=$(NAME) &&\
	export VERSION=$(VERSION) &&\
	./bin/template.awk < $< | sh > $@

assets/css/%.css: assets_src/css/%.css
	@mkdir -p $(@D)
	cp $< $@

assets/css/%.css: assets_src/css/%.less
	mkdir -p $(@D)
	@echo lessc $< > $@
	@$(LESSC) $< > $@

assets/js/%.js: assets_src/js/%.js .babelrc
	@echo browserify $< -o $@
	@$(BROWSERIFY) --debug $< -o $@ -t babelify

clean:
	-rm -- $(CSS_FILES)
	-rm -- $(LESS_FILES)
	-rm -- $(JS_FILES)

superclean: clean
	-rm -- .npm_last_update
	-rm -- package.json

ultraclean: superclean
	-rm -r -- node_modules

run: all
	go run *.go

.PHONY: all print_info clean superclean ultraclean run