forked from make-me/make-me
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (48 loc) · 1.73 KB
/
Makefile
File metadata and controls
58 lines (48 loc) · 1.73 KB
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
#-*- mode:makefile-gmake; -*-
ROOT = $(shell pwd)
USB ?= $(shell ls /dev/ | grep tty.usbmodem | head -1)
## Apps
GRUE ?= $(ROOT)/vendor/Miracle-Grue/bin/miracle_grue
GRUE_CONFIG ?= default
PRINT ?= $(ROOT)/bin/print_gcode -m "The Replicator 2" -p /dev/$(USB) -f
## What are we making?
THING_DIR = $(realpath $(shell dirname $(MAKECMDGOALS)))
THING_NAME = $(notdir $(MAKECMDGOALS))
%: %.gcode | init
ifneq ($(words $(MAKECMDGOALS)), 1)
@echo "!!!> ERROR:Can only make one thing at a time" >&2
@exit 1
endif
@[[ -c /dev/$(USB) ]] || { echo "No USB device found"; exit 1; }
@echo "Printing"
( \
$(PRINT) $(realpath $^) & \
echo $$! > $(ROOT)/tmp/print.pid; \
wait `cat $(ROOT)/tmp/print.pid` && \
rm $(ROOT)/tmp/print.pid; \
)
%.gcode: %.stl
@echo "Building gcode: At[$@] In[$^]"
@( \
$(GRUE) -s /dev/null -e /dev/null -c $(ROOT)/config/grue-$(GRUE_CONFIG).config \
-o "$(realpath $(dir $@))/$(notdir $@)" "$(realpath $^)" & \
echo $$! > $(ROOT)/tmp/slice.pid; \
wait `cat $(ROOT)/tmp/slice.pid` && \
rm $(ROOT)/tmp/slice.pid; \
)
## Plumbing
init:
@echo "=> Loading submodules"
git submodule sync
git submodule update --init --recursive
@echo "=> Building deps"
$(MAKE) -C vendor
## Main
.DEFAULT_GOAL = help
.PHONY: help init sandwich
# Easter egg
sandwich:
$(MAKE) data/sandwich
help:
@echo "Usage: "
@echo " $$ make name/of/thing"