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 | |
Zack Williams | aaae497 | 2020-11-10 14:00:07 -0700 | [diff] [blame^] | 33 | image: | out base ## create iPXE binary artifacts using Docker |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 34 | docker run -v $(OUTDIR):/tmp/out --name $(BUILDER) -d ipxe-builder:$(IPXE_VERSION) |
Zack Williams | aaae497 | 2020-11-10 14:00:07 -0700 | [diff] [blame^] | 35 | for file in $(COPY_FILES); do \ |
| 36 | docker cp $$file $(BUILDER):/ipxe/src/ ;\ |
| 37 | done |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 38 | docker exec -w /ipxe/src $(BUILDER) \ |
| 39 | bash -c "make -j4 $(TARGETS) $(OPTIONS); cp $(TARGETS) /tmp/out" |
| 40 | docker rm --force $(BUILDER) |
| 41 | |
| 42 | test: image ## test (currently only runs an image build) |
| 43 | |
Zack Williams | aaae497 | 2020-11-10 14:00:07 -0700 | [diff] [blame^] | 44 | clean: ## remove output artifacts |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 45 | rm -rf out/* |
| 46 | |
Zack Williams | aaae497 | 2020-11-10 14:00:07 -0700 | [diff] [blame^] | 47 | clean-all: clean ## full clean (delete iPXE git repo) |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 48 | rm -rf ipxe |
| 49 | |
| 50 | license: ## check licenses |
| 51 | reuse --version ;\ |
| 52 | reuse --root . lint |
| 53 | |
| 54 | help: ## 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};' |