build: Honor user's CFLAGS, CPPFLAGS, LDFLAGS.

* build-aux/build.sh.in (AM_CFLAGS, AM_CPPFLAGS, AM_LDFLAGS): Rename
from CFLAGS, CPPFLAGS, LDFLAGS.  Export them.
* configure: Substitute them.
* configure.sh: Likewise.
* build-aux/cc.sh (compile, link): Use them.
* build-aux/config.make.in (CFLAGS, CPPFLAGS, LDFLAGS): Add
substitutable variables.
* build-aux/config.sh.in: Likewise.
* build-aux/export.make: Export them.
This commit is contained in:
Jan Nieuwenhuizen 2019-12-02 18:26:08 +01:00
parent 3de6450117
commit 5c16b1ecc1
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
8 changed files with 48 additions and 17 deletions

View File

@ -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
)

View File

@ -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=
}

View File

@ -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@

View File

@ -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@"

View File

@ -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

View File

@ -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

2
configure vendored
View File

@ -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") ""))

View File

@ -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