1 # Contributor: Rick W. Chen <stuffcorpse at archlinux dot us>
3 pkgname=bfin-toolchain-git
6 pkgdesc="GNU toolchain for the Blackfin processor"
8 url="http://blackfin.uclinux.org/"
10 depends=('zlib' 'libx11' 'libftdi')
11 options=(!strip zipman docs)
12 makedepends=('git' 'bison' 'autoconf' 'automake' 'awk' 'libftdi'
13 'expect' 'dejagnu' 'xz-utils')
14 source=("${pkgname}.sh")
15 backup=("etc/profile.d/${pkgname}.sh")
16 md5sums=('a2c8569952267a4331fced5dd1aa13c9')
21 _branch="trunk" # git branch: e.g. trunk, 2010R1 or 2009R1
22 _binutils_ver="2.17" # binutils version: 2.21, 2.17
23 _gcc_version="4.3" # target gcc version: only 4.3 is supported now
24 _date_stamp=1 # date Stamp all output files
25 _disable_gfx=0 # disable all graphical utilities
26 _keep_builddir=0 # keep build directory afterwards
27 _keep_logs=1 # keep build logs at the end of makepkg
28 _stack_check=0 # add stack checking to all tests
29 _test_hardware=0 # test components on hardware (arg: ip address or 0)
30 _test_simulator=0 # test components on simulator
32 _warnings_log=1 # warnings to be sent to a different log file
37 _gitmirror="git://sources.blackfin.uclinux.org/git/readonly-mirrors"
38 _gitname=("toolchain" "linux-kernel" "u-boot")
39 _gitroot=("$_gitmirror/${_gitname[0]}"
40 "$_gitmirror/${_gitname[1]}"
41 "$_gitmirror/${_gitname[2]}")
46 _logdir="${startdir}/logs"
47 _testdir="${startdir}/tests"
48 _builddir="${srcdir}/build"
56 if [[ "$2" == "trunk" ]] ; then
58 elif [[ "$1" == "toolchain" ]] && [[ "$2" == "2009R1" ]] ; then
59 echo "toolchain_09r1_branch"
60 elif [[ "$1" == "toolchain" ]] && [[ "$2" == "2010R1" ]] ; then
62 elif [[ "$2" == "2010R1" ]] ; then
64 elif [[ "$2" == "2009R1" ]] ; then
67 error "Error: option _branch has to be either 'trunk', '2010R1', or '2009R1'"
78 ########################
79 # checking out git repos
80 ########################
81 msg "Checking out git repos"
84 for repo in ${_gitname[@]}; do
85 if [[ -d "${srcdir}/$repo" ]] ; then
86 msg2 "Updating $repo git mirror"
88 br=$(_get_git_branch $repo $_branch)
89 git --bare fetch origin $br:$br
92 msg2 "Creating $repo git mirror"
93 git clone --mirror ${_gitroot[$len]} ${_gitname[$len]}
102 msg "Creating build directory"
104 [[ -d "${_builddir}" ]] && rm -fr "${_builddir}"
105 mkdir -p "${_builddir}"
108 for repo in ${_gitname[@]}; do
110 msg2 "Cloning local $repo source tree"
111 git clone -l "${srcdir}/$repo" "${_builddir}/$repo"
113 if [[ ! "$_branch" == "trunk" ]] ; then
114 br=$(_get_git_branch $repo $_branch)
115 msg2 "Checking out branch: $br"
116 cd "${_builddir}/$repo" && git checkout -b $_branch origin/$br
126 [[ $_date_stamp -eq 1 ]] && _optargs="$_optargs -d"
127 [[ $_disable_gfx -eq 1 ]] && _optargs="$_optargs -X"
128 [[ $_stack_check -eq 1 ]] && _optargs="$_optargs -f"
129 [[ $_test_hardware -ne 0 ]] && _optargs="$_optargs -T $_test_hardware"
130 [[ $_test_simulator -eq 1 ]] && _optargs="$_optargs -t"
131 [[ $_verbose -eq 1 ]] && _optargs="$_optargs -v"
132 [[ $_warnings_log -eq 1 ]] && _optargs="$_optargs -w"
134 if [[ -n $_optargs ]] ; then
135 msg "Extra build options: $_optargs"
141 msg "Starting make..."
143 msg2 "Unsetting CFLAGS LDFLAGS"
144 unset CFLAGS CXXFLAGS LDFLAGS
148 "${_builddir}/$_gitname/buildscript/BuildToolChain" \
150 -c "${_gcc_version}" \
152 -B "${_binutils_ver}" \
153 -O "${_builddir}/package" \
154 -s "${_builddir}/${_gitname[0]}" \
155 -k "${_builddir}/${_gitname[1]}" \
156 -u "${_builddir}/${_gitname[2]}" \
157 $_optargs | tee "$_logdir/script.log"
161 _dest="$pkgdir/opt/blackfin"
163 install -Dm755 "$srcdir/${pkgname}.sh" "$pkgdir/etc/profile.d/${pkgname}.sh"
164 install -Dm755 -d "$_dest"
165 cp -arf "$_builddir/package/share/man/man1"/* "$_builddir/package/man/man1"/
166 cp -arf "$_builddir/package"/* "$_dest"/
171 if [[ -n $_dest ]] ; then
172 msg "Stripping debugging symbols from binaries"
174 find $_dest -type f 2>/dev/null | while read binary ; do
175 case "$(file -biz "$binary")" in
176 *compressed-encoding*) # Skip compressed binarys
178 *application/x-executable*) # Binaries
179 /usr/bin/strip "$binary" >/dev/null 2>&1 || continue ;;
189 if [[ "$_keep_logs" -eq 1 ]] ; then
190 msg2 "Backing up build logs"
191 _logs="$_logdir/logs-$(date +%Y%m%d%H%M)"
193 cp -arf "${_logdir}"/*.log $_logs/
194 cp -arf "${_builddir}/logs"/* $_logs/
197 [[ $(ls -A "$_logdir") ]] || rm -fr "$_logdir"
200 if [[ "$_test_simulator" -eq 1 ]] || [[ "$_test_hardware" -eq 1 ]] ; then
201 msg2 "Backing up test results"
202 mkdir -p "$startdir"/tests
203 cp -arf "${_builddir}/tests"/* "$_testdir"/
206 if [[ "$_keep_builddir" -eq 0 ]] ; then
207 msg2 "Removing build directory"
208 rm -fr "${_builddir}"
212 # vim: ts=2:sw=2:sts=2:et: