From 010ab9ae74aa105fe033949fd7ba4194446f58b9 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 21 May 2022 15:10:46 +0200 Subject: [PATCH] build: Cater for colliding basename in C sources. This is a follow-up to commit f785f8d560a85121c9688f671a8a4921c49616f4 build: Fix --with-bootstrap build. * build-aux/cc.sh: Retain directory name in object file name. * build-aux/bootstrap.sh.in: Likewise. Compile crt1.c from local directory. * build-aux/build-lib.sh: Likewise. * build-aux/build.sh.in: Remove globals.o hack. --- build-aux/bootstrap.sh.in | 30 ++++++++++++++++++------------ build-aux/build-lib.sh | 5 +++-- build-aux/build.sh.in | 1 - build-aux/cc.sh | 12 ++++++++---- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in index b2d56c50..1457b907 100644 --- a/build-aux/bootstrap.sh.in +++ b/build-aux/bootstrap.sh.in @@ -1,7 +1,7 @@ #! @SHELL@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen +# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -54,16 +54,18 @@ AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_k AM_CFLAGS="-L ${srcdest}lib" mkdir -p $mes_cpu-mes -$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c +cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c . +$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS crt1.c cp crt1.o $mes_cpu-mes cp crt1.s $mes_cpu-mes objects= for c in $libc_mini_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -72,10 +74,11 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects objects= for c in $libmescc_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -84,10 +87,11 @@ $AR crD $mes_cpu-mes/libmescc.a $objects objects= for c in $libc_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -96,10 +100,11 @@ $AR crD $mes_cpu-mes/libc.a $objects objects= for c in $libc_tcc_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -113,10 +118,11 @@ AM_CFLAGS="-L ${srcdest}lib" objects= for c in $mes_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done diff --git a/build-aux/build-lib.sh b/build-aux/build-lib.sh index 4eaead50..b1caf80e 100755 --- a/build-aux/build-lib.sh +++ b/build-aux/build-lib.sh @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2019 Jan (janneke) Nieuwenhuizen +# Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -26,7 +26,8 @@ trap 'test -f .log && cat .log' EXIT mkdir -p $mes_cpu-mes -compile lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c +cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c . +compile crt1.c cp crt1.o $mes_cpu-mes if test -e crt1.s; then cp crt1.s $mes_cpu-mes diff --git a/build-aux/build.sh.in b/build-aux/build.sh.in index f4a6a264..bbde993c 100644 --- a/build-aux/build.sh.in +++ b/build-aux/build.sh.in @@ -151,7 +151,6 @@ fi ${SHELL} ${srcdest}build-aux/build-lib.sh ${SHELL} ${srcdest}build-aux/build-source-lib.sh if $bootstrap; then - rm -f globals.* # FIXME: avoid name clash with globals from lib ${SHELL} ${srcdest}build-aux/build-mes.sh cp -f bin/mes-mescc ../bin cp -f bin/mes ../bin diff --git a/build-aux/cc.sh b/build-aux/cc.sh index 1a99e95f..edc93fba 100755 --- a/build-aux/cc.sh +++ b/build-aux/cc.sh @@ -1,5 +1,5 @@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -18,8 +18,12 @@ objects= compile () { - c=${srcdest}$1 - b=$(basename $c .c) + if test $(dirname $1) = "."; then + c=$1 + else + c=${srcdest}$1 + fi + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) o=$b.o objects="$objects $o" if test ! -e $o -o $c -nt $o; then @@ -34,7 +38,7 @@ archive () { sources="$@" objects= for c in $sources; do - b=$(basename $c .c) + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) o=$b.o compile $c done