File: Makefile

package info (click to toggle)
openscad 2015.03-2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 30,804 kB
  • ctags: 5,692
  • sloc: cpp: 39,386; sh: 3,856; ansic: 3,674; python: 1,393; yacc: 496; lex: 272; lisp: 159; makefile: 67; xml: 60
file content (48 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download
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
EXAMPLES := ../../examples
SRC=$(wildcard $(EXAMPLES)/*/*.scad)
PNG=$(patsubst $(EXAMPLES)/%.scad,html/%.png,$(SRC))
HTML=$(patsubst $(EXAMPLES)/%.scad,html/%.html,$(SRC))

OPENSCAD := ../../OpenSCAD.app/Contents/MacOS/OpenSCAD
#OPENSCAD := openscad
ARGS := --imgsize=1200,900 --camera=0,0,0,55,0,25,180 --viewall --autocenter

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

.PHONY: clean
clean :
	rm -rf html

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

.PHONY: example-data.js
example-data.js :
	( \
	echo "openscad_examples = ["; \
	for a in Basics Functions Shapes Extrusion Advanced; \
	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 $@ $< > out.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 >> $@