Commit 9eab3b88 authored by Hugo Grostabussiat's avatar Hugo Grostabussiat
Browse files

Clean up Makefile

Prepare the Makefile for producing more than one image, and fix small
issues along the way.

- Rename 'IMAGE' to 'IMAGES', and generate COMPRESSED from IMAGES (the
  '.xz' suffix is appended to every filename in IMAGE).
- Fix the image being rebuilt every time even when no change occurred by
  making the 'local.sh-link' prerequisite order-only.
- Make CHECKSUM depend on COMPRESSED so that the checksum file is
  updated if the images changed.
- Use variable STAMPFILE instead of repeating 'tmp/$(IMAGE).stamp'.
- Remove all .tmp file in the 'clean' target. This also eliminates a
  potentially dangerous 'rm -rf *'.
parent 6b76e241
# SPDX-License-Identifier: GPL-3.0+
BOARD=imx6
TYPE=unstable
IMAGE=$(BOARD).img
COMPRESSED=$(IMAGE).xz
CHECKSUM=sha256sums
DIST=buster+ci
BOARD ?= imx6
TYPE ?= unstable
DIST ?= buster+ci
STAMPFILE := tmp/$(BOARD).img.stamp
IMAGES := $(BOARD).img
COMPRESSED := $(addsuffix .xz,$(IMAGES))
CHECKSUM := sha256sums
DEPS=\
build-image \
root.sh \
......@@ -18,24 +20,28 @@ SHELLCHECK_SCRIPTS=\
build/build_kernel_deb.sh \
$(NULL)
.PHONY: all
all: $(COMPRESSED)
$(IMAGE): tmp/$(IMAGE).stamp
tmp/$(IMAGE).stamp: local.sh-link $(DEPS)
$(IMAGES): $(STAMPFILE)
# Use an order-only dependency to prevent rebuilding $(STAMPFILE) every time
# local.sh-link is out of date (it is always out of date because of .PHONY).
$(STAMPFILE): | local.sh-link
$(STAMPFILE): $(DEPS)
./build-image -b $(BOARD) -T $(TYPE) -d $(DIST)
touch tmp/$(IMAGE).stamp
touch $@
%.img.xz: %.img tmp/%.img.stamp
%.img.xz: %.img
xz -T0 --stdout $< > $@.tmp
mv $@.tmp $@
$(CHECKSUM):
$(CHECKSUM): $(COMPRESSED)
sha256sum $(COMPRESSED) > $@.tmp
mv $@.tmp $@
clean:
rm -rf files/ tmp/ $(IMAGE) $(COMPRESSED) $(CHECKSUM)*
rm -rf files/ tmp/ $(IMAGES) $(COMPRESSED) $(CHECKSUM) *.tmp
check:
shellcheck -x $(SHELLCHECK_SCRIPTS)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment