2023-06-13 11:09:01 +00:00
|
|
|
#!/usr/bin/env sh
|
2023-09-25 01:19:30 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2023-09-25 01:27:26 +00:00
|
|
|
# SPDX-FileCopyrightText: 2014-2016,2020,2021,2023 Leah Rowe <leah@libreboot.org>
|
2021-05-18 12:56:12 +00:00
|
|
|
|
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
|
|
set -u -e
|
|
|
|
|
2023-08-23 23:30:07 +00:00
|
|
|
. "include/err.sh"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
main()
|
|
|
|
{
|
2023-08-23 23:30:07 +00:00
|
|
|
printf "Building coreboot utils\n"
|
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
for board in "${@}"; do
|
2023-10-01 05:33:43 +00:00
|
|
|
x_ build_for_mainboard ${board}
|
2023-05-20 16:53:03 +00:00
|
|
|
done
|
|
|
|
else
|
2023-09-04 01:36:41 +00:00
|
|
|
for boarddir in config/coreboot/*; do
|
2023-05-20 16:53:03 +00:00
|
|
|
[ ! -d "${boarddir}" ] && continue
|
2023-10-01 05:33:43 +00:00
|
|
|
x_ build_for_mainboard ${boarddir##*/}
|
2023-05-20 16:53:03 +00:00
|
|
|
done
|
2023-05-20 15:12:25 +00:00
|
|
|
fi
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 17:00:31 +00:00
|
|
|
build_for_mainboard() {
|
2023-05-20 15:12:25 +00:00
|
|
|
board="${1}"
|
2023-09-04 01:36:41 +00:00
|
|
|
[ -d "config/coreboot/${board}" ] || \
|
2023-10-01 05:33:43 +00:00
|
|
|
err "build_for_mainboard ${board}: boarddir does not exist"
|
2023-09-04 01:36:41 +00:00
|
|
|
[ -f "config/coreboot/${board}/target.cfg" ] || \
|
2023-10-01 05:33:43 +00:00
|
|
|
err "build_for_mainboard ${board}: target.cfg does not exist"
|
2023-08-16 20:34:21 +00:00
|
|
|
tree="undefined"
|
2023-09-04 01:36:41 +00:00
|
|
|
. "config/coreboot/${board}/target.cfg" # source
|
2023-08-23 23:30:07 +00:00
|
|
|
[ "${tree}" = "undefined" ] && \
|
2023-10-01 05:33:43 +00:00
|
|
|
err "build_for_mainboard ${board}: improper tree definition"
|
2023-08-23 23:30:07 +00:00
|
|
|
buildutils "${tree}"
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
buildutils() {
|
2023-08-16 20:34:21 +00:00
|
|
|
tree="${1}"
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -d "coreboot/${tree}/" ] || \
|
2023-10-01 05:33:43 +00:00
|
|
|
x_ ./update project trees coreboot ${tree}
|
2023-06-13 11:09:01 +00:00
|
|
|
for util in cbfstool ifdtool; do
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -f "cbutils/${tree}/${util}" ] && continue
|
2023-10-01 05:33:43 +00:00
|
|
|
[ -d "cbutils/${tree}" ] || x_ mkdir -p "cbutils/${tree}"
|
2023-06-24 22:23:16 +00:00
|
|
|
|
2023-08-16 20:34:21 +00:00
|
|
|
utildir="coreboot/${tree}/util/${util}"
|
2023-10-01 05:33:43 +00:00
|
|
|
x_ make distclean -C "${utildir}"
|
|
|
|
x_ make -j$(nproc) -C "${utildir}"
|
|
|
|
x_ cp "${utildir}/${util}" "cbutils/${tree}"
|
|
|
|
x_ make distclean -C "${utildir}"
|
2023-05-20 15:12:25 +00:00
|
|
|
done
|
2023-05-20 16:53:03 +00:00
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
main $@
|