File: Makefile

package info (click to toggle)
openscad 2021.01-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,972 kB
  • sloc: cpp: 53,199; sh: 4,384; ansic: 4,382; python: 1,813; yacc: 853; javascript: 762; lex: 417; lisp: 163; xml: 127; makefile: 118
file content (52 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download | duplicates (5)
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
EXAMPLES := ../../examples
LOG := out.log
SRC=$(wildcard $(EXAMPLES)/*/*.scad)
PNG=$(patsubst $(EXAMPLES)/%.scad,html/%.png,$(SRC))
HTML=$(patsubst $(EXAMPLES)/%.scad,html/%.html,$(SRC))

OPENSCAD := $(shell ls ../../openscad ../../OpenSCAD.app/Contents/MacOS/OpenSCAD 2>/dev/null | head -n 1)
ARGS := --imgsize=1200,900 --camera=0,0,0,55,0,25,180 --viewall --autocenter

all : info $(PNG) $(HTML) example-data.js assets

.PHONY: info
info:
	@echo Using $(OPENSCAD)

.PHONY: clean
clean :
	rm -rf html $(LOG)

.PHONY: assets
assets :
	cp -a assets html/

.PHONY: example-data.js
example-data.js :
	( \
	echo "openscad_examples = ["; \
	for a in `grep '\[' ../../examples/examples.json | tr -d ' \t":[]'`; \
	do \
		echo "  {"; \
		echo "    name : \"$$a\","; \
		echo "    files : ["; \
		for f in "$(EXAMPLES)/$$a/"*.scad ; \
		do \
			echo "      \"`basename -s .scad $$f`\","; \
		done; \
		echo "    ]"; \
		echo "  },"; \
	done; \
	echo "];" \
	) > html/example-data.js

html/%.png : $(EXAMPLES)/%.scad
	mkdir -p `dirname $@`
	$(OPENSCAD) $(ARGS) -o $@ $< > $(LOG) 2>&1

html/%.html : $(EXAMPLES)/%.scad template-pre.html template-post.html
	#echo $(notdir $(patsubst %.scad,%.png,$<))
	mkdir -p `dirname $@`
	sed -e 's/@@IMAGE@@/$(notdir $(patsubst %.scad,%.png,$<))/g' template-pre.html > $@
	sed -e 's/</\&lt/; s/>/\&gt/;' $< >> $@
	cat template-post.html >> $@