aboutsummaryrefslogtreecommitdiffstats
path: root/makerelease.sh
blob: 4793e15e626d9bfe028411f6755a16bbb2992531 (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
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
#!/bin/sh

srcdir="$(dirname "$0")"
[ "$(echo "$srcdir" | cut -c1)" = '/' ] || srcdir="$PWD/$srcdir"

die() { echo "$*"; exit 1; }

# Import the makerelease.lib
# http://bues.ch/gitweb?p=misc.git;a=blob_plain;f=makerelease.lib;hb=HEAD
for path in $(echo "$PATH" | tr ':' ' '); do
	[ -f "$MAKERELEASE_LIB" ] && break
	MAKERELEASE_LIB="$path/makerelease.lib"
done
[ -f "$MAKERELEASE_LIB" ] && . "$MAKERELEASE_LIB" || die "makerelease.lib not found."


hook_get_version()
{
	local file="$1/firmware/version.h"
	local regex='#define[[:space:]]VERSION[[:space:]]'
	version="$(grep -e "$regex" "$file" | head -n1 | cut -d'"' -f2)"
}

hook_testbuild()
{
	default_hook_testbuild "$1/firmware"
}

hook_regression_tests()
{
	make -C "$1/firmware" tests
}

do_build()
{
	local fwdir="$1"
	local targetdir="$2"
	shift 2

	echo
	echo "Building configuration:  $*"
	mkdir -p "$targetdir"

	echo "$*" | tr '[:space:]' '\n' > "$targetdir/build_config.txt"
	make -C "$fwdir" all "$@" C=1

	echo "Fuse configuration:" > "$targetdir/fuses.txt"
	echo >> "$targetdir/fuses.txt"
	make --no-print-directory -C "$fwdir" print_fuses "$@" >> "$targetdir/fuses.txt"

	mv "$fwdir"/*.hex "$targetdir"/
	make -C "$fwdir" distclean "$@"
}

hook_pre_archives()
{
	# Build the hex files.
	for hw in legacy smd; do
		for dev in 88 88p 328p; do
			local releases="release"
			[ $dev = 328p ] && local releases="release debug"

			for rel in $releases; do
				local fwdir="$2/firmware"
				local targetdir="$2/hex/board_$hw/atmega$dev/$rel"

				if [ $hw = legacy ]; then
					local CONF_IDLETOGGLE=1
				else
					local CONF_IDLETOGGLE=0
				fi

				if [ $dev = 88 -o $dev = 88p ]; then
					local CONF_KCONF=0
				else
					local CONF_KCONF=1
				fi

				if [ $rel = debug ]; then
					local CONF_DEBUG=1
				else
					local CONF_DEBUG=0
				fi

				do_build "$fwdir" "$targetdir" \
					HW=$hw DEV=m$dev \
					CONF_PRESETS=1 \
					CONF_BOOST=0 \
					CONF_IDLE=1 \
					CONF_IDLETOGGLE=$CONF_IDLETOGGLE \
					CONF_DEBUG=$CONF_DEBUG \
					CONF_EERING=1 \
					CONF_ADJ=1 \
					CONF_KCONF=$CONF_KCONF
			done
		done
	done

	# Move the documentation.
	mv "$2"/schematics-lf1600/lf1600.pdf "$2"/schematics-lf1600.pdf
}

hook_pre_documentation()
{
	# Update the README
	local makefile="$1/firmware/Makefile"
	for arch in M88 M88P M328P; do
		local lfuse="$(grep -e "$arch"'_LFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
		local hfuse="$(grep -e "$arch"'_HFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
		local efuse="$(grep -e "$arch"'_EFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
		sed -i -e 's/%%'"$arch"'_LFUSE%%/'"$lfuse"'/g' \
		       -e 's/%%'"$arch"'_HFUSE%%/'"$hfuse"'/g' \
		       -e 's/%%'"$arch"'_EFUSE%%/'"$efuse"'/g' \
		       "$1/README.md"
	done
}

project=xytronic-lf
default_archives="tar.xz"
makerelease "$@"
bues.ch cgit interface