From bbb9b2546e9979c3b673bb23ffda695187d9fa03 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 | 20 +++++++++++++------- build-aux/build-lib.sh | 5 +++-- build-aux/build.sh.in | 1 - build-aux/cc.sh | 12 ++++++++---- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in index b2d56c50..f572e1df 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,13 +54,15 @@ 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 @@ -72,7 +74,8 @@ $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 @@ -84,7 +87,8 @@ $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 @@ -96,7 +100,8 @@ $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 @@ -113,7 +118,8 @@ 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 diff --git a/build-aux/build-lib.sh b/build-aux/build-lib.sh index ea36bfbe..69c3188e 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