blob: aba4aec347c5ded9bdc215725f77c9ed5400058b [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
Zack Williams2e469712022-01-26 18:11:09 -07009IPXE_VERSION ?= v1.21.1
Zack Williams09b4f4a2022-05-18 11:11:21 -070010TARGETS_BIOS ?= bin/undionly.kpxe bin/ipxe.usb bin/ipxe.iso bin/ipxe.pdsk
11TARGETS_EFI32 ?= bin-i386-efi/snponly.efi bin-i386-efi/ipxe.usb
12TARGETS_EFI64 ?= bin-x86_64-efi/snponly.efi bin-x86_64-efi/ipxe.usb
Zack Williams2e469712022-01-26 18:11:09 -070013OPTIONS ?= EMBED=chain.ipxe
14COPY_FILES ?= chain.ipxe
Zack Williams9f896c42020-10-05 21:59:11 -070015
16# Build configuration
Zack Williams09b4f4a2022-05-18 11:11:21 -070017DOCKER_ARGS ?=
18TMP_DIR ?= /tmp
Zack Williams2e469712022-01-26 18:11:09 -070019OUTDIR ?= $(shell pwd)/out
20BUILDER := ipxebuilder-$(shell date +"%Y%m%d%H%M%S")# timestamp for each run
21
22# print help by default
23.DEFAULT_GOAL := help
Zack Williams9f896c42020-10-05 21:59:11 -070024
25# phony (doesn't make files) targets
26.PHONY: base image clean clean-all license help
27
28ipxe: ## download and patch iPXE
Zack Williams09b4f4a2022-05-18 11:11:21 -070029 git clone https://github.com/ipxe/ipxe.git \
Zack Williams9f896c42020-10-05 21:59:11 -070030 && cd ipxe \
31 && git checkout $(IPXE_VERSION) \
32 && git apply ../patches/*
33
34out:
35 mkdir -p out
36
Zack Williams2e469712022-01-26 18:11:09 -070037base: | ipxe ## create base iPXE build container using Docker
Zack Williams09b4f4a2022-05-18 11:11:21 -070038 docker build $(DOCKER_ARGS) . -t ipxe-builder:$(IPXE_VERSION)
Zack Williams9f896c42020-10-05 21:59:11 -070039
Zack Williams2e469712022-01-26 18:11:09 -070040image: | out base ## create iPXE binaries using Docker
Zack Williams09b4f4a2022-05-18 11:11:21 -070041 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 Williamsaaae4972020-11-10 14:00:07 -070045 for file in $(COPY_FILES); do \
46 docker cp $$file $(BUILDER):/ipxe/src/ ;\
47 done
Zack Williams9f896c42020-10-05 21:59:11 -070048 docker exec -w /ipxe/src $(BUILDER) \
Zack Williams09b4f4a2022-05-18 11:11:21 -070049 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 Williams9f896c42020-10-05 21:59:11 -070054 docker rm --force $(BUILDER)
55
56test: image ## test (currently only runs an image build)
57
Zack Williamsaaae4972020-11-10 14:00:07 -070058clean: ## remove output artifacts
Zack Williams9f896c42020-10-05 21:59:11 -070059 rm -rf out/*
60
Zack Williamsaaae4972020-11-10 14:00:07 -070061clean-all: clean ## full clean (delete iPXE git repo)
Zack Williams9f896c42020-10-05 21:59:11 -070062 rm -rf ipxe
63
64license: ## check licenses
65 reuse --version ;\
66 reuse --root . lint
67
68help: ## Print help for each target
69 @echo infra-playbooks make targets
70 @echo
Zack Williams2e469712022-01-26 18:11:09 -070071 @grep '^[[:alnum:]_-]*:.* ## ' $(MAKEFILE_LIST) \
Zack Williams9f896c42020-10-05 21:59:11 -070072 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'