blob: 759d9ac7f32c92e63cf978dc8636a87ecab65b4b [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
Zack Williamsaaae4972020-11-10 14:00:07 -070033image: | out base ## create iPXE binary artifacts using Docker
Zack Williams9f896c42020-10-05 21:59:11 -070034 docker run -v $(OUTDIR):/tmp/out --name $(BUILDER) -d ipxe-builder:$(IPXE_VERSION)
Zack Williamsaaae4972020-11-10 14:00:07 -070035 for file in $(COPY_FILES); do \
36 docker cp $$file $(BUILDER):/ipxe/src/ ;\
37 done
Zack Williams9f896c42020-10-05 21:59:11 -070038 docker exec -w /ipxe/src $(BUILDER) \
39 bash -c "make -j4 $(TARGETS) $(OPTIONS); cp $(TARGETS) /tmp/out"
40 docker rm --force $(BUILDER)
41
42test: image ## test (currently only runs an image build)
43
Zack Williamsaaae4972020-11-10 14:00:07 -070044clean: ## remove output artifacts
Zack Williams9f896c42020-10-05 21:59:11 -070045 rm -rf out/*
46
Zack Williamsaaae4972020-11-10 14:00:07 -070047clean-all: clean ## full clean (delete iPXE git repo)
Zack Williams9f896c42020-10-05 21:59:11 -070048 rm -rf ipxe
49
50license: ## check licenses
51 reuse --version ;\
52 reuse --root . lint
53
54help: ## Print help for each target
55 @echo infra-playbooks make targets
56 @echo
57 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
58 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'