diff options
| author | Dibyendu Majumdar <mobile@majumdar.org.uk> | 2023-08-19 08:52:57 -0700 |
|---|---|---|
| committer | Dibyendu Majumdar <mobile@majumdar.org.uk> | 2026-11-12 13:48:30 -0800 |
| commit | 520097f05ee5e5fb07c50644c67f1796b4fdf0f9 (patch) | |
| tree | 45e7dd86367f45ae22b1108d10ad2af2e1b56507 /build-support/libraries.mk | |
| download | Simple-520097f05ee5e5fb07c50644c67f1796b4fdf0f9.tar.gz Simple-520097f05ee5e5fb07c50644c67f1796b4fdf0f9.zip | |
Chapter 1: Introduction
Co-authored-by: Cliff Click <cliffc@acm.org>
Co-authored-by: Thalia Archibald <thalia@archibald.dev>
Co-authored-by: hadha <helsgithub15@gmail.com>
Co-authored-by: XmiliaH <45106915+XmiliaH@users.noreply.github.com>
Co-authored-by: Tamás Hadházy <85063808+Hels15@users.noreply.github.com>
Co-authored-by: Jun Kawasaki <jun784@gmail.com>
Diffstat (limited to 'build-support/libraries.mk')
| -rw-r--r-- | build-support/libraries.mk | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/build-support/libraries.mk b/build-support/libraries.mk new file mode 100644 index 00000000..e45f1d08 --- /dev/null +++ b/build-support/libraries.mk @@ -0,0 +1,26 @@ +# Dependency downloads are permitted only by an explicit setup goal. +# Keep this cache outside build/ so make clean does not erase it. +.PHONY: lib libs init +required_jars := lib/junit-4.12.jar lib/hamcrest-core-1.3.jar +lib libs init: $(required_jars) + +# Chapters are self-contained, but identical JARs need not be downloaded again. +# Copy an existing repository/sibling cache even for an ordinary offline build. +cached-library = $(firstword $(filter-out $(abspath $@),$(abspath $(wildcard ../lib/$(notdir $@) ../chapter*/lib/$(notdir $@))))) + +# The legacy `lib` name remains an explicit setup alias. +ifneq ($(filter lib libs init,$(MAKECMDGOALS)),) +define download-library +mkdir -p $(dir $@) && curl -fsSL $(1) -o $@.tmp && mv $@.tmp $@ +endef +else +define download-library +echo "Missing cached dependency: $@. Run make libs (or make init) while online." >&2; exit 1 +endef +endif + +lib/junit-4.12.jar: + @$(if $(cached-library),mkdir -p lib && cp "$(cached-library)" $@,$(call download-library,https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar)) + +lib/hamcrest-core-1.3.jar: + @$(if $(cached-library),mkdir -p lib && cp "$(cached-library)" $@,$(call download-library,https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar)) |
