diff --git a/build-aux/build.sh.in b/build-aux/build.sh.in index 13952a90..e86990c6 100644 --- a/build-aux/build.sh.in +++ b/build-aux/build.sh.in @@ -51,40 +51,40 @@ fi debug= #debug=-g -CFLAGS=" +AM_CFLAGS=" -static $debug " if test $mes_libc = mes; then - CFLAGS="$CFLAGS + AM_CFLAGS="$AM_CFLAGS -nostdinc -nostdlib -fno-builtin " fi -CPPFLAGS=" +AM_CPPFLAGS=" -D HAVE_CONFIG_H=1 -I ../include -I ${srcdir}/../include -I ${srcdir}/../include/$mes_kernel/$mes_cpu " -LDFLAGS=" +AM_LDFLAGS=" $debug -L . " if test $mes_libc = mes; then - LDFLAGS="$LDFLAGS + AM_LDFLAGS="$AM_LDFLAGS -nostdlib " fi LIBS=-lc -export CFLAGS -export CPPFLAGS -export LDFLAGS +export AM_CFLAGS CFLAGS +export AM_CPPFLAGS CPPFLAGS +export AM_LDFLAGS LDFLAGS export LIBS ( @@ -96,7 +96,7 @@ export LIBS srcdir=../ fi if test $compiler = gcc; then - CPPFLAGS=" + AM_CPPFLAGS=" -D HAVE_CONFIG_H=1 -I include -I ${srcdest}include @@ -110,12 +110,12 @@ export LIBS ( if test $compiler = gcc; then - LDFLAGS="$LDFLAGS + AM_LDFLAGS="$AM_LDFLAGS -L gcc-lib " fi - CPPFLAGS=" + AM_CPPFLAGS=" -D HAVE_CONFIG_H=1 -I include -I ${srcdest}include @@ -136,7 +136,7 @@ export LIBS srcdest=../ srcdir=../ fi - CPPFLAGS=" + AM_CPPFLAGS=" -D HAVE_CONFIG_H=1 -I include -I ${srcdest}include @@ -145,6 +145,10 @@ export LIBS compiler=mescc AR="${srcdest}pre-inst-env mesar" CC="${srcdest}pre-inst-env mescc -m $mes_bits" + # No user overrides for MesCC, they are probably intended for GCC + CFLAGS= + CPPFLAGS= + LDFLAGS= ${SHELL} ${srcdest}build-aux/build-lib.sh ${SHELL} ${srcdest}build-aux/build-source-lib.sh ) diff --git a/build-aux/cc.sh b/build-aux/cc.sh index 93ae07ba..28a21802 100755 --- a/build-aux/cc.sh +++ b/build-aux/cc.sh @@ -23,8 +23,8 @@ compile () { o=$b.o objects="$objects $o" if test $c -nt $o; then - trace "CC $c" $CC -c $CPPFLAGS $CFLAGS -o $o $c - $CC -c $CPPFLAGS $CFLAGS -o $o $c + trace "CC $c" $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o $c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o $c fi } @@ -51,6 +51,6 @@ link () { else crt1=crt1.o fi - trace "CCLD $out" $CC $CFLAGS $LDFLAGS -o $out $crt1 $objects $LIBS + trace "CCLD $out" $CC $AM_CFLAGS $CFLAGS $AM_LDFLAGS $LDFLAGS -o $out $crt1 $objects $LIBS objects= } diff --git a/build-aux/config.make.in b/build-aux/config.make.in index 45947ef8..1d8e4087 100644 --- a/build-aux/config.make.in +++ b/build-aux/config.make.in @@ -20,6 +20,8 @@ AR:=@AR@ BASH:=@BASH@ BLOOD_ELF:=@BLOOD_ELF@ CC:=@CC@ +CFLAGS:=@CFLAGS@ +CPPFLAGS:=@CPPFLAGS@ DIFF:=@DIFF@ DOT:=@DOT@ GIT:=@GIT@ @@ -29,6 +31,7 @@ GUILE_EFFECTIVE_VERSION:=@GUILE_EFFECTIVE_VERSION@ GUIX:=@GUIX@ HELP2MAN:=@HELP2MAN@ HEX2:=@HEX2@ +LDFLAGS:=@LDFLAGS@ MAKEINFO:=@MAKEINFO@ M1:=@M1@ MES_FOR_BUILD:=@MES_FOR_BUILD@ diff --git a/build-aux/config.sh.in b/build-aux/config.sh.in index 83fa015d..29006499 100644 --- a/build-aux/config.sh.in +++ b/build-aux/config.sh.in @@ -21,6 +21,8 @@ AR=${AR-"@AR@"} BASH="@BASH@" BLOOD_ELF="@BLOOD_ELF@" CC=${CC-"@CC@"} +CFLAGS=${CFLAGS-"@CFLAGS@"} +CPPFLAGS=${CPPFLAGS-"@CPPFLAGS@"} DIFF=${DIFF-@DIFF@} DOT="@DOT@" GIT="@GIT@" @@ -30,6 +32,7 @@ GUILE_EFFECTIVE_VERSION="@GUILE_EFFECTIVE_VERSION@" GUIX="@GUIX@" HELP2MAN="@HELP2MAN@" HEX2="@HEX2@" +LDFLAGS=${LDFLAGS-"@LDFLAGS@"} MAKEINFO="@MAKEINFO@" M1="@M1@" MES_FOR_BUILD="@MES_FOR_BUILD@" diff --git a/build-aux/export.make b/build-aux/export.make index f3807af7..6876c8e4 100644 --- a/build-aux/export.make +++ b/build-aux/export.make @@ -131,6 +131,18 @@ ifdef GUILE_LOAD_COMPILED_PATH export GUILE_LOAD_COMPILED_PATH endif +ifdef AM_CFLAGS +export AM_CFLAGS +endif + +ifdef AM_CPPFLAGS +export AM_CPPFLAGS +endif + +ifdef AM_LDFLAGS +export AM_LDFLAGS +endif + ifdef CFLAGS export CFLAGS endif @@ -139,6 +151,10 @@ ifdef CPPFLAGS export CPPFLAGS endif +ifdef LDFLAGS +export LDFLAGS +endif + ifdef HEX2FLAGS export HEX2FLAGS endif diff --git a/build-aux/test-c.sh b/build-aux/test-c.sh index 9a84f6c4..49c6f385 100755 --- a/build-aux/test-c.sh +++ b/build-aux/test-c.sh @@ -59,8 +59,8 @@ else crt1=crt1.o fi -$CC -c $CPPFLAGS $CFLAGS -o "$o".o "$t" -$CC $CFLAGS $LDFLAGS -L . -o "$o" $crt1 "$o".o $LIBS +$CC -g -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o "$o".o "$t" +$CC -g $AM_CFLAGS $CFLAGS $AM_LDFLAGS $LDFLAGS -L . -o "$o" $crt1 "$o".o $LIBS set +e timeout 10 "$o" -s --long file0 file1 > "$o".1 2> "$o".2 diff --git a/configure b/configure index 44c44cb2..8edb2ce7 100755 --- a/configure +++ b/configure @@ -612,6 +612,8 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system) ("@SHELL@" . ,shell) ("@CFLAGS@" . ,(or (getenv "CFLAGS") "")) + ("@CPPFLAGS@" . ,(or (getenv "CPPFLAGS") "")) + ("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "")) ("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") "")) ("@M1FLAGS@" . ,(or (getenv "M1FLAGS") "")) diff --git a/configure.sh b/configure.sh index edf57789..947ddd85 100755 --- a/configure.sh +++ b/configure.sh @@ -58,6 +58,8 @@ AR=${AR-$(command -v ar)} || true BASH=${BASH-$(command -v bash)} BLOOD_ELF=${BLOOD_ELF-$(command -v blood-elf)} CC=${CC-$(command -v gcc)} || true +CFLAGS=${CFLAGS-} +CPPFLAGS=${CPPFLAGS-} DIFF=${DIFF-$(command -v diff || echo $PWD/pre-inst-env diff.scm)} GUILD=${GUILD-$(command -v guild)} || true GUILE_TOOLS=${GUILE_TOOLS-$(command -v guile-tools)} || true @@ -70,6 +72,7 @@ if test ! "$GUILD"; then fi GUILE=${GUILE-$(command -v guile)} || true HEX2=${HEX2-$(command -v hex2)} +LDPFLAGS=${LDFLAGS-} M1=${M1-$(command -v M1)} MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)} GIT=${GIT-$(command -v git)} || true