summaryrefslogtreecommitdiffstats
path: root/config
blob: 4cddfcd73138f260bee3839152a919c9997c14df (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
#! /bin/sh

set -e

TARGET_PKGS='binutils libbfd-dev'

main()
{
	case "${1}" in
		clean)
			clean
			;;
		*)
			get_config_values
			configure_build
			;;
	esac
}

msg()
{
	printf 'binutils config: '
	printf "${@}"
	printf '\n'
}

get_config_values()
{
	if [ -z "${PKG_TARGET_ARCH}" ]; then
		msg 'Error: No target architecture specified.' >&2
		exit 1
	fi

	# FIXME: Lookup GNU system type.
	export PKG_TARGET_ARCH_GNU=arm-cortex_a8-linux-gnu
}

configure_build()
{
	# Generate a sed script to edit files.
	_ss=
	for _name in TARGET_ARCH TARGET_ARCH_GNU; do
		_ss="${_ss}s&@PKG_${_name}@&$(eval echo \$\{PKG_${_name}\})&;"
	done

	# Write a build makefile with the configuration values.
	sed "${_ss}" build.in >build
	chmod a+x build
	msg '"build" file generated.'

	# Write metadata for <pkgbase>-<target> packages.
	for _pkg in ${TARGET_PKGS}; do
		mkdir -p "${_pkg}-${PKG_TARGET_ARCH}.pkg"
		sed "${_ss}" "${_pkg}.pkg.in/control" \
			>"${_pkg}-${PKG_TARGET_ARCH}.pkg/control"
		msg 'Metadata for package "%s" generated.' \
			"${_pkg}-${PKG_TARGET_ARCH}"
	done
}

clean()
{
	# Remove generated build makefile.
	rm -f build

	# Remove generated metadata for <pkgbase>-<target> packages.
	for _pkg in ${TARGET_PKGS}; do
		rm -Rf "${_pkg}"-*-*-*.pkg/
	done
}

main "${@}"