summaryrefslogtreecommitdiff
path: root/net/ipxe/Makefile
blob: 219991e5e7a1b39db66b61e1c8675a81504c9c49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Created by: Guerkan Karaman <gk.freebsd@googlemail.com>
# $FreeBSD$

PORTNAME=	ipxe
PORTVERSION=	20180514
CATEGORIES=	net

MAINTAINER=	tobik@FreeBSD.org
COMMENT=	Open source network boot firmware

LICENSE=	GPLv2

ONLY_FOR_ARCHS=	amd64 i386
ONLY_FOR_ARCHS_REASON=	not yet ported to anything other than amd64/i386

USES=		gmake perl5 shebangfix
USE_BINUTILS=	yes
USE_GCC=	yes
USE_GITHUB=	yes
# iPXE hasn't had a release since 2010.
# See iPXE's FAQ at http://ipxe.org/faq
#
#   Q: Which version of iPXE should I use?
#
#   A: iPXE uses a rolling release model, in which every commit is intended
#      to be production-ready.  You should always use the latest code.
#
GH_TAGNAME=	e7f67d5a4c6e9f06aa7a9db1b4245f5e16f00bb2
USE_PERL5=	build

ALL_TARGET=	bin/ipxe.dsk bin/ipxe.lkrn bin/ipxe.pxe bin/ipxe.usb bin/undionly.kpxe
MAKE_ARGS=	HOST_CC=${CC} \
		PERL=${PERL} \
		CC=${CC} \
		AS=${AS} \
		LD=${LD} \
		SIZE=${SIZE} \
		AR=${AR} \
		RANLIB=${RANLIB} \
		OBJCOPY=${OBJCOPY} \
		NM=${NM} \
		OBJDUMP=${OBJDUMP} \
		ARCH=${ARCH:S/amd64/i386/} \
		NO_WERROR=1 \
		V=1 \
		${IPXE_MAKE_ARGS}
PLIST_FILES=	${ALL_TARGET:S@^bin/@${DATADIR}/@}
SHEBANG_FILES=	util/geniso util/gensdsk
SUB_FILES=	pkg-message
WRKSRC_SUBDIR=	src

# Possible options are listed in ${WRKSRC}/config/*.h and
# http://ipxe.org/buildcfg.  Add a ! prefix to an option to undef it
# i.e. turn it off.
_IPXE_BUILDCFG=	branding:PRODUCT_NAME="${PKGNAME} (${OPSYS} ${OSREL}/${ARCH})" \
		console:CONSOLE_SERIAL \
		console:KEYBOARD_MAP=us \
		general:!DOWNLOAD_PROTO_FTP \
		general:DOWNLOAD_PROTO_HTTPS \
		general:DOWNLOAD_PROTO_NFS \
		general:IMAGE_TRUST_CMD \
		general:NET_PROTO_IPV6 \
		general:PING_CMD \
		general:POWEROFF_CMD

OPTIONS_DEFAULT=	ISO EFI
OPTIONS_DEFINE=		ISO EFI

EFI_DESC=	Create EFI image
ISO_DESC=	Create bootable CD image

EFI_ARCHS=	i386 ${ARCH:Mamd64:S/amd64/x86_64/}
.for _arch in ${EFI_ARCHS}
EFI_PLIST_FILES+=	${DATADIR}/ipxe.efi-${_arch}
.endfor

ISO_ALL_TARGET=	bin/ipxe.iso
ISO_BUILD_DEPENDS=	bash:shells/bash \
		${LOCALBASE}/share/syslinux/bios/core/isolinux.bin:sysutils/syslinux \
		mkisofs:sysutils/cdrtools
ISO_MAKE_ARGS=	ISOLINUX_BIN="${WRKSRC}/isolinux.bin" \
		LDLINUX_C32="${LOCALBASE}/share/syslinux/bios/com32/elflink/ldlinux/ldlinux.c32"

.include <bsd.port.pre.mk>

# Add user supplied build configuration after port options etc have
# been processed as they might want to overwrite some settings.
_IPXE_BUILDCFG+=	${IPXE_BUILDCFG}

# XXX: iPXE uses csplit when embedding certificates and assumes
# it's GNU csplit, so give it what it wants as a workaround if
# CERT=... is in {IPXE_,}MAKE_ARGS.
.if ${MAKE_ARGS:MCERT=*}
BUILD_DEPENDS+=	gcsplit:sysutils/coreutils
MAKE_ARGS+=	CSPLIT=gcsplit
.endif

do-configure:
.for _cat _opt in ${_IPXE_BUILDCFG:C/\:/ /}
	@${ECHO_CMD} '#undef ${_opt:S/^!//:C/(.*)=(.*)/\1/}' >> ${WRKSRC}/config/local/${_cat}.h
.if ${_opt:N!*}
	@${ECHO_CMD} '#define ${_opt:C/=/ /:S/^'//:S/'$//}' >> ${WRKSRC}/config/local/${_cat}.h
.endif
.endfor

pre-build-ISO-on:
# ISO creation fails if isolinux.bin is read only
	${INSTALL} -m 644 ${LOCALBASE}/share/syslinux/bios/core/isolinux.bin ${WRKSRC}/isolinux.bin

do-build-EFI-on:
.for _arch in ${EFI_ARCHS}
	${DO_MAKE_BUILD} ARCH=${_arch} -C ${WRKSRC} bin-${_arch}-efi/ipxe.efi
.endfor

do-install:
	@${MKDIR} ${STAGEDIR}${DATADIR}
	cd ${WRKSRC} && ${INSTALL_DATA} ${ALL_TARGET} ${STAGEDIR}${DATADIR}

do-install-EFI-on:
.for _arch in ${EFI_ARCHS}
	${INSTALL_DATA} ${WRKSRC}/bin-${_arch}-efi/ipxe.efi ${STAGEDIR}${DATADIR}/ipxe.efi-${_arch}
.endfor

.include <bsd.port.post.mk>

RUN_DEPENDS:=	${RUN_DEPENDS:Ngcc*}