Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame^] | 1 | # iPXE Build automation |
| 2 | |
| 3 | # SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | SHELL = bash -eu -o pipefail |
| 7 | |
| 8 | # iPXE configuration |
| 9 | IPXE_VERSION ?= v1.20.1 |
| 10 | TARGETS ?= bin/undionly.kpxe bin/ipxe.usb |
| 11 | OPTIONS ?= EMBED=chain.ipxe |
| 12 | COPY_FILES ?= chain.ipxe |
| 13 | |
| 14 | # Build configuration |
| 15 | OUTDIR ?= $(shell pwd)/out |
| 16 | BUILDER := 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 | |
| 21 | ipxe: ## 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 | |
| 27 | out: |
| 28 | mkdir -p out |
| 29 | |
| 30 | base: | ipxe ## create bas iPXE build container using Docker |
| 31 | docker build . -t ipxe-builder:$(IPXE_VERSION) |
| 32 | |
| 33 | image: | 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 | |
| 40 | test: image ## test (currently only runs an image build) |
| 41 | |
| 42 | clean: ## remove output artifacts |
| 43 | rm -rf out/* |
| 44 | |
| 45 | clean-all: clean ## full clean (delete iPXE git repo) |
| 46 | rm -rf ipxe |
| 47 | |
| 48 | license: ## check licenses |
| 49 | reuse --version ;\ |
| 50 | reuse --root . lint |
| 51 | |
| 52 | help: ## 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};' |