csci5607/assignment-1/Makefile

44 lines
1,001 B
Makefile
Raw Normal View History

2023-02-01 22:13:48 +00:00
.PHONY: all clean
2023-02-01 08:37:02 +00:00
2023-02-01 22:13:48 +00:00
DOCKER := docker
ZIP := zip
PANDOC := pandoc
2023-02-01 23:12:30 +00:00
CONVERT := convert
2023-02-01 08:37:02 +00:00
2023-02-01 22:13:48 +00:00
HANDIN := hw1a.michael.zhang.zip
2023-02-01 23:12:30 +00:00
BINARY := ./assignment-1
2023-02-01 22:13:48 +00:00
WRITEUP := writeup.pdf
SOURCES := $(shell find -name "*.rs")
2023-02-01 08:37:02 +00:00
2023-02-01 23:12:30 +00:00
EXAMPLES := $(shell find examples -name "*.txt")
EXAMPLES_PPM := $(patsubst %.txt,%.ppm,$(EXAMPLES))
EXAMPLES_PNG := $(patsubst %.txt,%.png,$(EXAMPLES))
2023-02-01 08:37:02 +00:00
all: $(HANDIN)
2023-02-01 22:13:48 +00:00
$(BINARY): $(SOURCES)
$(DOCKER) run \
2023-02-01 08:37:02 +00:00
--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
2023-02-01 22:13:48 +00:00
mv target/release/assignment-1 $@
2023-02-01 23:12:30 +00:00
$(HANDIN): $(BINARY) $(WRITEUP) Cargo.toml Cargo.lock README.md $(EXAMPLES_PNG) $(EXAMPLES_PPM)
$(ZIP) -r $@ src examples $^
examples/%.ppm: examples/%.txt
cargo run -- -o $@ $<
examples/%.png: examples/%.ppm
convert $< $@
2023-02-01 08:37:02 +00:00
2023-02-02 08:34:51 +00:00
writeup.pdf: writeup.md $(EXAMPLES_PNG)
2023-02-01 22:13:48 +00:00
$(PANDOC) -o $@ $<
2023-02-01 08:37:02 +00:00
clean:
2023-02-01 23:46:54 +00:00
rm -f $(HANDIN) $(BINARY) $(WRITEUP) $(EXAMPLES_PPM) $(EXAMPLES_PNG)