csci5607/assignment-1c/Makefile

55 lines
1.3 KiB
Makefile
Raw Normal View History

2023-02-19 00:28:55 +00:00
.PHONY: all clean
.PRECIOUS: $(EXAMPLES_PPM)
RAYTRACER_FLAGS :=
DOCKER := docker
ZIP := zip
PANDOC := pandoc
CONVERT := convert
2023-02-20 23:40:19 +00:00
HANDIN := ./hw1c.michael.zhang.zip
BINARY := ./raytracer1c
2023-02-19 00:28:55 +00:00
WRITEUP := ./writeup.pdf
SHOWCASE := ./showcase.png
SOURCES := Cargo.toml $(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)
mkdir -p target/docker
$(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 \
-e CARGO_TARGET_DIR=/usr/src/myapp/target/docker \
rust \
cargo build --profile release-handin
2023-02-20 23:40:19 +00:00
mv target/docker/release-handin/raytracer1c $@
2023-02-19 00:28:55 +00:00
$(HANDIN): $(BINARY) $(WRITEUP) Makefile Cargo.toml Cargo.lock README.md $(EXAMPLES_PNG) $(EXAMPLES_PPM) $(SHOWCASE)
$(ZIP) -r $@ src examples $^
$(SHOWCASE): examples/soft-shadow-demo.png
cp $< $@
examples/%.ppm: examples/%.txt $(SOURCES)
cargo run --release -- -o $@ $(RAYTRACER_FLAGS) $<
examples/%.png: examples/%.ppm
convert $< $@
writeup.pdf: writeup.md $(EXAMPLES_PNG)
$(PANDOC) -o $@ $<
clean:
rm -rf target/docker \
$(HANDIN) $(BINARY) $(WRITEUP) $(SHOWCASE) \
$(EXAMPLES_PPM) $(EXAMPLES_PNG)