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 |
Zack Williams | 2e46971 | 2022-01-26 18:11:09 -0700 | [diff] [blame^] | 9 | IPXE_VERSION ?= v1.21.1 |
| 10 | TARGETS ?= bin/undionly.kpxe bin/ipxe.usb bin/ipxe.iso bin/ipxe.pdsk |
| 11 | TARGETS_EFI32 ?= bin-i386-efi/ipxe.usb |
| 12 | TARGETS_EFI64 ?= bin-x86_64-efi/ipxe.usb |
| 13 | OPTIONS ?= EMBED=chain.ipxe |
| 14 | COPY_FILES ?= chain.ipxe |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 15 | |
| 16 | # Build configuration |
Zack Williams | 2e46971 | 2022-01-26 18:11:09 -0700 | [diff] [blame^] | 17 | OUTDIR ?= $(shell pwd)/out |
| 18 | BUILDER := ipxebuilder-$(shell date +"%Y%m%d%H%M%S")# timestamp for each run |
| 19 | |
| 20 | # print help by default |
| 21 | .DEFAULT_GOAL := help |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 22 | |
| 23 | # phony (doesn't make files) targets |
| 24 | .PHONY: base image clean clean-all license help |
| 25 | |
| 26 | ipxe: ## download and patch iPXE |
| 27 | git clone git://git.ipxe.org/ipxe.git \ |
| 28 | && cd ipxe \ |
| 29 | && git checkout $(IPXE_VERSION) \ |
| 30 | && git apply ../patches/* |
| 31 | |
| 32 | out: |
| 33 | mkdir -p out |
| 34 | |
Zack Williams | 2e46971 | 2022-01-26 18:11:09 -0700 | [diff] [blame^] | 35 | base: | ipxe ## create base iPXE build container using Docker |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 36 | docker build . -t ipxe-builder:$(IPXE_VERSION) |
| 37 | |
Zack Williams | 2e46971 | 2022-01-26 18:11:09 -0700 | [diff] [blame^] | 38 | image: | out base ## create iPXE binaries using Docker |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 39 | 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] | 40 | for file in $(COPY_FILES); do \ |
| 41 | docker cp $$file $(BUILDER):/ipxe/src/ ;\ |
| 42 | done |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 43 | docker exec -w /ipxe/src $(BUILDER) \ |
Zack Williams | 2e46971 | 2022-01-26 18:11:09 -0700 | [diff] [blame^] | 44 | bash -c "make -j4 $(TARGETS) $(OPTIONS); cp $(TARGETS) /tmp/out; \ |
| 45 | make -j4 $(TARGETS_EFI32) $(OPTIONS); cp $(TARGETS_EFI32) /tmp/out/ipxe_efi32.usb; \ |
| 46 | make -j4 $(TARGETS_EFI64) $(OPTIONS); cp $(TARGETS_EFI64) /tmp/out/ipxe_efi64.usb" |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 47 | docker rm --force $(BUILDER) |
| 48 | |
| 49 | test: image ## test (currently only runs an image build) |
| 50 | |
Zack Williams | aaae497 | 2020-11-10 14:00:07 -0700 | [diff] [blame] | 51 | clean: ## remove output artifacts |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 52 | rm -rf out/* |
| 53 | |
Zack Williams | aaae497 | 2020-11-10 14:00:07 -0700 | [diff] [blame] | 54 | clean-all: clean ## full clean (delete iPXE git repo) |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 55 | rm -rf ipxe |
| 56 | |
| 57 | license: ## check licenses |
| 58 | reuse --version ;\ |
| 59 | reuse --root . lint |
| 60 | |
| 61 | help: ## Print help for each target |
| 62 | @echo infra-playbooks make targets |
| 63 | @echo |
Zack Williams | 2e46971 | 2022-01-26 18:11:09 -0700 | [diff] [blame^] | 64 | @grep '^[[:alnum:]_-]*:.* ## ' $(MAKEFILE_LIST) \ |
Zack Williams | 9f896c4 | 2020-10-05 21:59:11 -0700 | [diff] [blame] | 65 | | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};' |