forked from sporkus/PseudoMakeMeKeyCapProfiles
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
69 lines (53 loc) · 2.06 KB
/
Makefile
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
58
59
60
61
62
63
64
65
66
67
68
69
# Much faster, but requires OpenScad snapshot
OPENSCAD="/Applications/OpenSCAD Snapshot.app/Contents/MacOS/OpenSCAD" --enable=manifold
# This will work with the stable openscad
#OPENSCAD="/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD"
# OpenScad options
OPENSCAD_OPTIONS=--export-format binstl
OPENSCAD_CMD=$(OPENSCAD) $(OPENSCAD_OPTIONS)
# Directories
SRC_DIR := .
STL_DIR := stl
# Default target
all: sets singles
CS_SRC := $(SRC_DIR)/Choc_Chicago_Steno.scad $(SRC_DIR)/Choc_Chicago_Steno_Thumb.scad $(SRC_DIR)/Choc_Chicago_Steno_Convex.scad
# Create targets for files starting with `export_`
EXPORT_SCAD_FILES := $(wildcard $(SRC_DIR)/export_*.scad)
STL_TARGETS := $(patsubst $(SRC_DIR)/export_%.scad,$(STL_DIR)/%.stl,$(EXPORT_SCAD_FILES))
$(STL_DIR)/%.stl: $(SRC_DIR)/export_%.scad $(SRC_DIR)/gen_sprued_keycaps.scad $(CS_SRC)
@echo "Building set $@..."
$(OPENSCAD_CMD) --render -o $@ $<
@echo
@echo
# Generate targets for single keys
AVAILABLE_KEY_IDS := $(shell perl -n -e'/\["(cs_.*)",/ && print "$$1\n"' < gen_sprued_keycaps.scad)
define generate_key_target
$(STL_DIR)/single_keys/$(1).stl: $(SRC_DIR)/gen_single_keycap.scad $(SRC_DIR)/gen_sprued_keycaps.scad $(CS_SRC)
@echo "Building single key $(1)..."
@mkdir -p stl/single_keys
$(OPENSCAD_CMD) --render -D keycap_id=\"$(1)\" -o $$@ $$<
@echo
@echo
endef
SINGLE_KEY_TARGETS := $(foreach id,$(AVAILABLE_KEY_IDS),$(STL_DIR)/single_keys/$(id).stl)
$(foreach id,$(AVAILABLE_KEY_IDS),$(eval $(call generate_key_target,$(id))))
# Target to create sets
sets: $(STL_TARGETS)
# Target to generate single key stls
singles: $(SINGLE_KEY_TARGETS)
# Remove generated STL files
clean:
rm -f $(STL_TARGETS) $(SINGLE_KEY_TARGETS)
# Help target
help:
@echo "Available targets:"
@echo " sets: Build all set targets"
@echo " singles: Build all single targets"
@echo " clean: Remove generated STL files"
@echo " help: Show this help message"
@echo
@echo "Set Targets:"
@$(foreach target,$(STL_TARGETS),echo " $(target)";)
@echo
@echo "Single Targets:"
@$(foreach target,$(SINGLE_KEY_TARGETS),echo " $(target)";)