diff --git a/PKGBUILD b/PKGBUILD index 4e7b8b1..1a4febb 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -6,7 +6,7 @@ _target=lm32-elf pkgname=$_target-gcc pkgver=10.2.0 _islver=0.22 -pkgrel=1 +pkgrel=2 #_snapshot=8-20180427 pkgdesc='The GNU Compiler Collection - cross compiler for LatticeMico32 (bare-metal) target' arch=(x86_64) @@ -32,8 +32,6 @@ else fi prepare() { - mkdir build-gcc - cd $_basedir # link isl for in-tree builds @@ -43,14 +41,11 @@ prepare() { # hack! - some configure tests for header files using "$CPP $CPPFLAGS" sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure -} - -build() { - cd build-gcc - export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections' - export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections' + mkdir "$srcdir"/build-{gcc,gcc-nano} +} +_build_gcc() { "$srcdir"/$_basedir/configure \ --target=$_target \ --prefix=/usr \ @@ -90,11 +85,36 @@ build() { make } -package() { - cd build-gcc +build() { + cd "$srcdir"/build-gcc + export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections' + export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections' + _build_gcc + # Build libstdc++ without exceptions support (the 'nano' variant) + cd "$srcdir"/build-gcc-nano + export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions' + export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions' + _build_gcc +} + +package() { + cd "$srcdir"/build-gcc make DESTDIR="$pkgdir" install -j1 + cd "$srcdir"/build-gcc-nano + make DESTDIR="$pkgdir.nano" install -j1 + + # we need only libstdc nano files + multilibs=( $("$pkgdir"/usr/bin/$_target-gcc -print-multi-lib 2>/dev/null) ) + for multilib in "${multilibs[@]}"; do + dir="${multilib%%;*}" + from_dir="$pkgdir".nano/usr/$_target/lib/"$dir" + to_dir="$pkgdir"/usr/$_target/lib/"$dir" + cp -f "$from_dir"/libstdc++.a "$to_dir"/libstdc++_nano.a + cp -f "$from_dir"/libsupc++.a "$to_dir"/libsupc++_nano.a + done + # strip target binaries find "$pkgdir"/usr/lib/gcc/$_target/$pkgver "$pkgdir"/usr/$_target/lib \ -type f -and \( -name \*.a -or -name \*.o \) \