blob: d8acfdbf4096effe3d6f0a2b2dcae5c0c2c5ee00 [file] [log] [blame]
Zack Williams9f896c42020-10-05 21:59:11 -07001# iPXE Build automation
2
3# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
4# SPDX-License-Identifier: Apache-2.0
5
6SHELL = bash -eu -o pipefail
7
8# iPXE configuration
9IPXE_VERSION ?= v1.20.1
10TARGETS ?= bin/undionly.kpxe bin/ipxe.usb
11OPTIONS ?= EMBED=chain.ipxe
12COPY_FILES ?= chain.ipxe
13
14# Build configuration
15OUTDIR ?= $(shell pwd)/out
16BUILDER := ipxebuilder-$(shell date +"%Y%m%d%H%M%S")# timestamp for each run
17
18# phony (doesn't make files) targets
19.PHONY: base image clean clean-all license help
20
21ipxe: ## download and patch iPXE
22 git clone git://git.ipxe.org/ipxe.git \
23 && cd ipxe \
24 && git checkout $(IPXE_VERSION) \
25 && git apply ../patches/*
26
27out:
28 mkdir -p out
29
30base: | ipxe ## create bas iPXE build container using Docker
31 docker build . -t ipxe-builder:$(IPXE_VERSION)
32
33image: | out base ## create iPXE binary artifacts using Docker
34 docker run -v $(OUTDIR):/tmp/out --name $(BUILDER) -d ipxe-builder:$(IPXE_VERSION)
35 docker cp $(COPY_FILES) $(BUILDER):/ipxe/src/
36 docker exec -w /ipxe/src $(BUILDER) \
37 bash -c "make -j4 $(TARGETS) $(OPTIONS); cp $(TARGETS) /tmp/out"
38 docker rm --force $(BUILDER)
39
40test: image ## test (currently only runs an image build)
41
42clean: ## remove output artifacts
43 rm -rf out/*
44
45clean-all: clean ## full clean (delete iPXE git repo)
46 rm -rf ipxe
47
48license: ## check licenses
49 reuse --version ;\
50 reuse --root . lint
51
52help: ## Print help for each target
53 @echo infra-playbooks make targets
54 @echo
55 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
56 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'