46 lines
1 KiB
Makefile
46 lines
1 KiB
Makefile
|
.PHONY: all clean
|
||
|
|
||
|
.PRECIOUS: $(EXAMPLES_PPM)
|
||
|
|
||
|
DOCKER := docker
|
||
|
ZIP := zip
|
||
|
PANDOC := pandoc
|
||
|
CONVERT := convert
|
||
|
|
||
|
HANDIN := hw1b.michael.zhang.zip
|
||
|
BINARY := ./assignment-1b
|
||
|
WRITEUP := writeup.pdf
|
||
|
SOURCES := $(shell find -name "*.rs")
|
||
|
|
||
|
EXAMPLES := $(shell find examples -name "*.txt")
|
||
|
EXAMPLES_PPM := $(patsubst %.txt,%.ppm,$(EXAMPLES))
|
||
|
EXAMPLES_PNG := $(patsubst %.txt,%.png,$(EXAMPLES))
|
||
|
|
||
|
all: $(HANDIN)
|
||
|
|
||
|
$(BINARY): $(SOURCES)
|
||
|
$(DOCKER) run \
|
||
|
--rm \
|
||
|
-v "$(shell pwd)":/usr/src/myapp \
|
||
|
-v cargo-registry:/usr/local/cargo \
|
||
|
--user "$(shell id -u)":"$(shell id -g)" \
|
||
|
-w /usr/src/myapp \
|
||
|
rust \
|
||
|
cargo build --release
|
||
|
mv target/release/assignment-1b $@
|
||
|
|
||
|
$(HANDIN): $(BINARY) $(WRITEUP) Makefile Cargo.toml Cargo.lock README.md $(EXAMPLES_PNG) $(EXAMPLES_PPM)
|
||
|
$(ZIP) -r $@ src examples $^
|
||
|
|
||
|
examples/%.ppm: examples/%.txt $(SOURCES)
|
||
|
cargo run -- -o $@ $<
|
||
|
|
||
|
examples/%.png: examples/%.ppm
|
||
|
convert $< $@
|
||
|
|
||
|
writeup.pdf: writeup.md $(EXAMPLES_PNG)
|
||
|
$(PANDOC) -o $@ $<
|
||
|
|
||
|
clean:
|
||
|
rm -f $(HANDIN) $(BINARY) $(WRITEUP) $(EXAMPLES_PPM) $(EXAMPLES_PNG)
|