blob: 60b38d6e6266695fefe9399c6ea84e6ce84ef79c [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
10TARGETS ?= bin/undionly.kpxe bin/ipxe.usb bin/ipxe.iso bin/ipxe.pdsk
11TARGETS_EFI32 ?= bin-i386-efi/ipxe.usb
12TARGETS_EFI64 ?= bin-x86_64-efi/ipxe.usb
13OPTIONS ?= EMBED=chain.ipxe
14COPY_FILES ?= chain.ipxe
Zack Williams9f896c42020-10-05 21:59:11 -070015
16# Build configuration
Zack Williams2e469712022-01-26 18:11:09 -070017OUTDIR ?= $(shell pwd)/out
18BUILDER := ipxebuilder-$(shell date +"%Y%m%d%H%M%S")# timestamp for each run
19
20# print help by default
21.DEFAULT_GOAL := help
Zack Williams9f896c42020-10-05 21:59:11 -070022
23# phony (doesn't make files) targets
24.PHONY: base image clean clean-all license help
25
26ipxe: ## 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
32out:
33 mkdir -p out
34
Zack Williams2e469712022-01-26 18:11:09 -070035base: | ipxe ## create base iPXE build container using Docker
Zack Williams9f896c42020-10-05 21:59:11 -070036 docker build . -t ipxe-builder:$(IPXE_VERSION)
37
Zack Williams2e469712022-01-26 18:11:09 -070038image: | out base ## create iPXE binaries using Docker
Zack Williams9f896c42020-10-05 21:59:11 -070039 docker run -v $(OUTDIR):/tmp/out --name $(BUILDER) -d ipxe-builder:$(IPXE_VERSION)
Zack Williamsaaae4972020-11-10 14:00:07 -070040 for file in $(COPY_FILES); do \
41 docker cp $$file $(BUILDER):/ipxe/src/ ;\
42 done
Zack Williams9f896c42020-10-05 21:59:11 -070043 docker exec -w /ipxe/src $(BUILDER) \
Zack Williams2e469712022-01-26 18:11:09 -070044 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 Williams9f896c42020-10-05 21:59:11 -070047 docker rm --force $(BUILDER)
48
49test: image ## test (currently only runs an image build)
50
Zack Williamsaaae4972020-11-10 14:00:07 -070051clean: ## remove output artifacts
Zack Williams9f896c42020-10-05 21:59:11 -070052 rm -rf out/*
53
Zack Williamsaaae4972020-11-10 14:00:07 -070054clean-all: clean ## full clean (delete iPXE git repo)
Zack Williams9f896c42020-10-05 21:59:11 -070055 rm -rf ipxe
56
57license: ## check licenses
58 reuse --version ;\
59 reuse --root . lint
60
61help: ## Print help for each target
62 @echo infra-playbooks make targets
63 @echo
Zack Williams2e469712022-01-26 18:11:09 -070064 @grep '^[[:alnum:]_-]*:.* ## ' $(MAKEFILE_LIST) \
Zack Williams9f896c42020-10-05 21:59:11 -070065 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'