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