| 1 |
# |
| 2 |
# Maintenance Makefile |
| 3 |
# |
| 4 |
|
| 5 |
# Enforce bash with fatal errors. |
| 6 |
SHELL := /bin/bash -eo pipefail |
| 7 |
|
| 8 |
# Keep intermediates around on failures for better caching. |
| 9 |
.SECONDARY: |
| 10 |
|
| 11 |
# Default build and source directories. |
| 12 |
BUILDDIR ?= ./build |
| 13 |
SRCDIR ?= . |
| 14 |
|
| 15 |
# |
| 16 |
# Target: help |
| 17 |
# |
| 18 |
|
| 19 |
.PHONY: help |
| 20 |
help: |
| 21 |
@# 80-width marker: |
| 22 |
@# 01234567012345670123456701234567012345670123456701234567012345670123456701234567 |
| 23 |
@echo "make [TARGETS...]" |
| 24 |
@echo |
| 25 |
@echo "The following targets are provided by this maintenance makefile:" |
| 26 |
@echo |
| 27 |
@echo " help: Print this usage information" |
| 28 |
@echo |
| 29 |
@echo " publish-github: Publish a release to GitHub" |
| 30 |
|
| 31 |
# |
| 32 |
# Target: BUILDDIR |
| 33 |
# |
| 34 |
|
| 35 |
$(BUILDDIR)/: |
| 36 |
mkdir -p "$@" |
| 37 |
|
| 38 |
$(BUILDDIR)/%/: |
| 39 |
mkdir -p "$@" |
| 40 |
|
| 41 |
# |
| 42 |
# Target: FORCE |
| 43 |
# |
| 44 |
# Used as alternative to `.PHONY` if the target is not fixed. |
| 45 |
# |
| 46 |
|
| 47 |
.PHONY: FORCE |
| 48 |
FORCE: |
| 49 |
|
| 50 |
# |
| 51 |
# Target: publish-* |
| 52 |
# |
| 53 |
|
| 54 |
PUBLISH_REPO ?= r-efi/r-efi |
| 55 |
PUBLISH_VERSION ?= |
| 56 |
|
| 57 |
define PUBLISH_RELNOTES_PY |
| 58 |
with open('NEWS.md', 'r') as f: |
| 59 |
notes = f.read().split("\n## CHANGES WITH ")[1:] |
| 60 |
notes = dict(map(lambda v: (v[:v.find(":")], v), notes)) |
| 61 |
notes = notes["$(PUBLISH_VERSION)"].strip() |
| 62 |
print(" # r-efi - UEFI Reference Specification Protocol Constants and Definitions\n") |
| 63 |
print(" ## CHANGES WITH", notes) |
| 64 |
endef |
| 65 |
|
| 66 |
export PUBLISH_RELNOTES_PY |
| 67 |
export PUBLISH_REPO |
| 68 |
export PUBLISH_VERSION |
| 69 |
|
| 70 |
.PHONY: publish-github |
| 71 |
publish-github: |
| 72 |
test ! -z "$${PUBLISH_REPO}" |
| 73 |
test ! -z "$${PUBLISH_VERSION}" |
| 74 |
python \ |
| 75 |
- \ |
| 76 |
<<<"$${PUBLISH_RELNOTES_PY}" \ |
| 77 |
| gh \ |
| 78 |
release \ |
| 79 |
--repo "$${PUBLISH_REPO}" \ |
| 80 |
create \ |
| 81 |
--verify-tag \ |
| 82 |
--title \ |
| 83 |
"r-efi-$${PUBLISH_VERSION}" \ |
| 84 |
--notes-file - \ |
| 85 |
"v$${PUBLISH_VERSION}" |