-
Notifications
You must be signed in to change notification settings - Fork 3
/
GNUmakefile
41 lines (35 loc) · 1.29 KB
/
GNUmakefile
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
################################################################################
SIDES = right left
PARTS = case top cover
################################################################################
SRC = minidox-case.scad
DIR = stls
################################################################################
define ADD_FEATURES
$(if $(findstring cover,$(1)),-D feature_cover=true -D feature_magnets=true)
endef
################################################################################
# $1: Side.
# $2: Part.
# $3: Features.
define ADD_PARTS
-D print_side='"$(1)"' -D print_part='"$(2)"' $(call ADD_FEATURES,$(3)) \
$(if $(findstring cover,$(2)),-D feature_magnets=true)
endef
################################################################################
# $1: Side.
# $2: Part.
define STL
all: $(DIR)/$(2)/$(2)-$(1).stl
$(DIR)/$(2)/$(2)-$(1).stl: $(SRC)
@ mkdir -p `dirname $$@`
openscad -o $$@ $(call ADD_PARTS,$(1),$(2)) $(SRC)
ifeq ($(2),case)
all: $(DIR)/$(2)/$(2)-$(1)-with-cover.stl
$(DIR)/$(2)/$(2)-$(1)-with-cover.stl: $(SRC)
@ mkdir -p `dirname $$@`
openscad -o $$@ $(call ADD_PARTS,$(1),$(2),cover) $(SRC)
endif
endef
################################################################################
$(foreach p,$(PARTS),$(foreach s,$(SIDES),$(eval $(call STL,$(s),$(p)))))