forked from opnsense/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
192 lines (161 loc) · 5.73 KB
/
Makefile
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Copyright (c) 2015-2023 Franco Fichtner <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
STEPS= audit arm base boot chroot clean clone compress confirm \
connect core distfiles download dvd fingerprint info \
kernel list make.conf nano options packages plugins ports \
prefetch print rebase release rename rewind serial sign \
skim test update upload verify vga vm xtools
SCRIPTS= custom distribution factory hotfix nightly watch
.PHONY: ${STEPS} ${SCRIPTS}
PAGER?= less
.MAKE.JOB.PREFIX?= # tampers with some of our make invokes
all:
@cat ${.CURDIR}/README.md | ${PAGER}
lint-steps:
.for STEP in common ${STEPS}
@sh -n ${.CURDIR}/build/${STEP}.sh
.endfor
lint-composite:
.for SCRIPT in ${SCRIPTS}
@sh -n ${.CURDIR}/composite/${SCRIPT}.sh
.endfor
lint: lint-steps lint-composite
# Special vars to load early build.conf settings:
ROOTDIR?= /usr
TOOLSDIR?= ${ROOTDIR}/tools
TOOLSBRANCH?= master
.if defined(CONFIGDIR)
_CONFIGDIR= ${CONFIGDIR}
.elif defined(SETTINGS)
_CONFIGDIR= ${TOOLSDIR}/config/${SETTINGS}
.elif !defined(CONFIGDIR)
__CONFIGDIR!= find -s ${TOOLSDIR}/config -name "build.conf" -type f
.for DIR in ${__CONFIGDIR}
. if exists(${DIR}) && empty(_CONFIGDIR)
_CONFIGDIR= ${DIR:C/\/build\.conf$//}
. endif
.endfor
.endif
.-include "${_CONFIGDIR}/build.conf.local"
.include "${_CONFIGDIR}/build.conf"
# Bootstrap the build options if not set:
NAME?= OPNsense
TYPE?= ${NAME:tl}
SUFFIX?= # empty
_ARCH!= uname -p
ARCH?= ${_ARCH}
ABI?= ${_CONFIGDIR:C/^.*\///}
KERNEL?= SMP
ADDITIONS?= # empty
DEBUG?= # empty
DEVICE?= A10
COMSPEED?= 115200
UEFI?= arm dvd serial vga vm
ZFS?= # empty
GITBASE?= https://github.com/opnsense
MIRRORS?= https://opnsense.c0urier.net \
http://mirrors.nycbug.org/pub/opnsense \
http://mirror.wdc1.us.leaseweb.net/opnsense \
http://mirror.sfo12.us.leaseweb.net/opnsense \
http://mirror.fra10.de.leaseweb.net/opnsense \
http://mirror.ams1.nl.leaseweb.net/opnsense
SERVER?= [email protected]
UPLOADDIR?= .
_VERSION!= date '+%Y%m%d%H%M'
VERSION?= ${_VERSION}
STAGEDIRPREFIX?=/usr/obj
EXTRABRANCH?= # empty
COREBRANCH?= stable/${ABI}
COREVERSION?= # empty
COREDIR?= ${ROOTDIR}/core
COREENV?= CORE_PHP=${PHP} CORE_ABI=${ABI} CORE_PYTHON=${PYTHON}
PLUGINSBRANCH?= stable/${ABI}
PLUGINSDIR?= ${ROOTDIR}/plugins
PLUGINSENV?= PLUGIN_PHP=${PHP} PLUGIN_ABI=${ABI} PLUGIN_PYTHON=${PYTHON}
PORTSBRANCH?= master
PORTSDIR?= ${ROOTDIR}/ports
PORTSENV?= # empty
PORTSREFURL?= https://git.FreeBSD.org/ports.git
PORTSREFDIR?= ${ROOTDIR}/freebsd-ports
PORTSREFBRANCH?=main
SRCBRANCH?= stable/${ABI}
SRCDIR?= ${ROOTDIR}/src
# A couple of meta-targets for easy use and ordering:
kernel ports distfiles: base
audit plugins: ports
core: plugins
packages test: core
arm dvd nano serial vga vm: kernel core
sets: kernel distfiles packages
images: dvd nano serial vga vm
release: dvd nano serial vga
# Expand target arguments for the script append:
.for TARGET in ${.TARGETS}
_TARGET= ${TARGET:C/\-.*//}
.if ${_TARGET} != ${TARGET}
.if ${SCRIPTS:M${_TARGET}}
${_TARGET}_ARGS+= ${TARGET:C/^[^\-]*(\-|\$)//}
.else
${_TARGET}_ARGS+= ${TARGET:C/^[^\-]*(\-|\$)//:S/,/ /g}
.endif
${TARGET}: ${_TARGET}
.endif
.endfor
.if "${VERBOSE}" != ""
VERBOSE_FLAGS= -x
.else
VERBOSE_HIDDEN= @
.endif
.for _VERSION in ABI DEBUG LUA PERL PHP PYTHON RUBY SSL VERSION ZFS
VERSIONS+= PRODUCT_${_VERSION}=${${_VERSION}}
.endfor
# Expand build steps to launch into the selected
# script with the proper build options set:
.for STEP in ${STEPS}
${STEP}: lint-steps
${VERBOSE_HIDDEN} cd ${.CURDIR}/build && \
sh ${VERBOSE_FLAGS} ./${.TARGET}.sh -a ${ARCH} -F ${KERNEL} \
-n ${NAME} -v "${VERSIONS}" -s ${_CONFIGDIR} \
-S ${SRCDIR} -P ${PORTSDIR} -p ${PLUGINSDIR} -T ${TOOLSDIR} \
-C ${COREDIR} -R ${PORTSREFDIR} -t ${TYPE} -k "${PRIVKEY}" \
-K "${PUBKEY}" -l "${SIGNCHK}" -L "${SIGNCMD}" -d ${DEVICE} \
-m ${MIRRORS:Ox:[1]} -o "${STAGEDIRPREFIX}" -c ${COMSPEED} \
-b ${SRCBRANCH} -B ${PORTSBRANCH} -e ${PLUGINSBRANCH} \
-g ${TOOLSBRANCH} -E ${COREBRANCH} -G ${PORTSREFBRANCH} \
-H "${COREENV}" -u "${UEFI:tl}" -U "${SUFFIX}" \
-V "${ADDITIONS}" -O "${GITBASE}" -r "${SERVER}" \
-h "${PLUGINSENV}" -I "${UPLOADDIR}" -D "${EXTRABRANCH}" \
-A "${PORTSREFURL}" -J "${PORTSENV}" ${${STEP}_ARGS}
.endfor
.for SCRIPT in ${SCRIPTS}
${SCRIPT}: lint-composite
${VERBOSE_HIDDEN} cd ${.CURDIR} && \
sh ${VERBOSE_FLAGS} ./composite/${SCRIPT}.sh ${${SCRIPT}_ARGS}
.endfor
_OS!= uname -r
_OS:= ${_OS:C/-.*//}
.if "${_OS}" != "${OS}"
.error Expected OS version ${OS} for ${_CONFIGDIR}; to continue anyway set OS=${_OS}
.endif