summaryrefslogtreecommitdiff
path: root/mk
blob: 7e8a70d9d1db089a4699dcab6981f8dcf997bcd1 (plain)
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
#!/usr/bin/env sh

# SPDX-License-Identifier: GPL-3.0-or-later

# Copyright (c) 2020-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>

set -u -e

ispwd="true"

if [ "$0" != "./mk" ]; then
	ispwd="false"
fi

if [ "$ispwd" = "true" ] && [ -L "mk" ]; then
	ispwd="false"
fi

if [ "$ispwd" = "false" ]; then
	printf "You must run this in the proper work directory.\n" 1>&2
	exit 1
fi

. "include/lib.sh"
. "include/init.sh"
. "include/vendor.sh"
. "include/mrc.sh"
. "include/inject.sh"
. "include/rom.sh"
. "include/release.sh"
. "include/get.sh"

main()
{
	cmd=""
	if [ $# -gt 0 ]; then
		cmd="$1"
		shift 1
	fi

	case "$cmd" in
	version)
		printf "%s\nWebsite: %s\n" "$relname" "$projectsite"
		;;
	release|download|inject)
		$cmd "$@"
		;;
	-*)
		return 0
		;;
	*)
		err "bad command" main "$@"
		;;
	esac

	# some commands disable them. turn them back on!
	set -u -e

	return 1
}

main "$@" || exit 0

. "include/tree.sh"

trees "$@" || exit 0

x_ touch "$mkhelpercfg"

. "$mkhelpercfg"
$cmd