summaryrefslogtreecommitdiff
path: root/script/handle/make
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-05 22:49:19 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-05 22:51:05 +0100
commit9d419e77a0621ddf8398edecb40ddedc3388dc42 (patch)
tree393175c361643f1ada2c833acb57109b84d58f1b /script/handle/make
parent106841024a5d744768734def462387648d473014 (diff)
handle/make/*: unified main() function
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/handle/make')
-rwxr-xr-xscript/handle/make/config22
-rwxr-xr-xscript/handle/make/file28
2 files changed, 9 insertions, 41 deletions
diff --git a/script/handle/make/config b/script/handle/make/config
index 9d028a85..694119c4 100755
--- a/script/handle/make/config
+++ b/script/handle/make/config
@@ -9,6 +9,7 @@ set -u -e
. "include/err.sh"
. "include/option.sh"
+. "include/make.sh"
read projectname < projectname
read our_version < version
@@ -20,26 +21,7 @@ eval "$(setvars "" arch cfgsdir codedir config config_name crossgcc_ada mode \
tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)"
-main()
-{
- while getopts b:m:u:c:x: option
- do
- case "${1}" in
- -b) mode="all" ;;
- -u) mode="oldconfig" ;;
- -m) mode="menuconfig" ;;
- -c) mode="distclean" ;;
- -x) mode="crossgcc-clean" ;;
- *) fail "Invalid option" ;;
- esac
- shift; project="${OPTARG}"; shift
- done
- [ -z "${mode}" ] && fail "mode not given (-m, -u, -b, -c or -x)"
- [ -z "${project}" ] && fail "project name not specified"
-
- handle_dependencies $@
- handle_targets
-}
+# main() is in include/make.sh
handle_dependencies()
{
diff --git a/script/handle/make/file b/script/handle/make/file
index c0a6afb4..ff41f375 100755
--- a/script/handle/make/file
+++ b/script/handle/make/file
@@ -6,30 +6,16 @@
set -u -e
. "include/err.sh"
+. "include/make.sh"
-eval "$(setvars "" mode project _flag)"
+eval "$(setvars "" mode project _flag codedir)"
-main()
-{
- while getopts b:c: option
- do
- _flag="${1}"
- case "${_flag}" in
- -b) : ;;
- -c) mode="distclean" ;;
- *) err "Invalid option" ;;
- esac
- shift; project="${OPTARG}"; shift
- done
- [ -z "${project}" ] && err "project name not specified"
- [ $# -gt 0 ] && x_ ./handle make file ${_flag} ${@}
-
- handle_dependencies
- run_make_command
-}
+# main() is in include/make.sh
handle_dependencies()
{
+ [ $# -gt 0 ] && x_ ./handle make file ${_flag} ${@}
+
[ -d "${project}" ] || x_ ./update project repo "${project%/*}"
[ -d "${project}" ] || \
err "handle_dependencies: ${project%/*} not downloaded"
@@ -42,11 +28,11 @@ handle_dependencies()
)
}
-run_make_command()
+handle_targets()
{
[ -f "${project}/Makefile" ] || [ -f "${project}/makefile" ] || \
[ -f "${project}/GNUmakefile" ] || return 0
- [ -z "${mode}" ] && x_ make -C "${project}" -j$(nproc) && return 0
+ [ "${mode}" = "all" ] && x_ make -C "${project}" -j$(nproc) && return 0
x_ make -C "${project}" clean
make -C "${project}" distclean 2>/dev/null || :
}