diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in index 192508a7..3665a0ec 100644 --- a/build-aux/bootstrap.sh.in +++ b/build-aux/bootstrap.sh.in @@ -30,22 +30,22 @@ MES_PREFIX=${MES_PREFIX-$PWD} . build-aux/configure-lib.sh CPPFLAGS="-D HAVE_CONFIG_H=1 -I include" -CFLAGS="" +AM_CFLAGS="" mkdir -p mescc-lib cp config.sh mescc-lib/config.sh cd mescc-lib srcdest=../ -CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kernel/$mes_cpu" +AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kernel/$mes_cpu" mkdir $mes_cpu-mes -$CC -c $CPPFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c +$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c cp crt1.o $mes_cpu-mes cp crt1.s $mes_cpu-mes objects= for c in $libc_mini_SOURCES; do echo "CC $c" - $CC -c $CPPFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c o=$(basename $c .c).o objects="$objects $o" done @@ -55,7 +55,7 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects objects= for c in $libc_SOURCES; do echo "CC $c" - $CC -c $CPPFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c o=$(basename $c .c).o objects="$objects $o" done @@ -65,7 +65,7 @@ $AR crD $mes_cpu-mes/libc.a $objects objects= for c in $libc_tcc_SOURCES; do echo "CC $c" - $CC -c $CPPFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c o=$(basename $c .c).o objects="$objects $o" done @@ -79,7 +79,7 @@ CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kern objects= for c in $mes_SOURCES; do echo "CC $c" - $CC -c $CPPFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c o=$(basename $c .c).o objects="$objects $o" done diff --git a/build-aux/build.sh.in b/build-aux/build.sh.in index 6ac111fa..ca7c46f7 100644 --- a/build-aux/build.sh.in +++ b/build-aux/build.sh.in @@ -48,14 +48,12 @@ if test -n "$GUILE" -a "$GUILE" != true; then ${SHELL} ${srcdest}build-aux/build-guile.sh fi -debug=${debug--g} - -AM_CFLAGS=" --static -$debug -" +AM_CFLAGS= if test $mes_libc = mes; then + AM_CFLAGS=" +-static +" AM_CFLAGS="$AM_CFLAGS -nostdinc -nostdlib @@ -71,7 +69,6 @@ AM_CPPFLAGS=" " AM_LDFLAGS=" -$debug -L . " if test $mes_libc = mes; then diff --git a/configure b/configure index d48492d0..e6364c5e 100755 --- a/configure +++ b/configure @@ -252,23 +252,39 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)' (if result (set-field dependency (dependency-file-name) name) dependency)))) +(define (cflags-list) + (let ((cflags (getenv "CFLAGS"))) + (if cflags (list cflags) + '()))) + +(define (ldflags-list) + (let ((ldflags (getenv "LDFLAGS"))) + (if ldflags (list ldflags) + '()))) + (define (check-preprocess-header-c cc header) (with-output-to-file ".config.c" (cut format #t "#include \"~a\"" header)) - (with-error-to-file "/dev/null" - (cut zero? (system* cc "-E" "-o" ".config.E" ".config.c")))) + (let ((test (lambda _ (apply system* `(,cc "-E" "-o" ".config.E" ,@(cflags-list) ".config.c"))))) + (zero? (if %verbose? (test) + (with-error-to-file "/dev/null" + test))))) (define (check-compile-string-c cc string) (with-output-to-file ".config.c" (cut display string)) - (with-error-to-file "/dev/null" - (cut zero? (system* cc "--std=gnu99" "-c" "-o" ".config.o" ".config.c")))) + (let ((test (lambda _ (apply system* `(,cc "--std=gnu99" "-c" "-o" ".config.o" ,@(cflags-list) ".config.c"))))) + (zero? (if %verbose? (test) + (with-error-to-file "/dev/null" + test))))) (define (check-link-string-c cc string) (with-output-to-file ".config.c" (cut display string)) - (with-error-to-file "/dev/null" - (cut zero? (system* cc "--std=gnu99" "-o" ".config" ".config.c")))) + (let ((test (lambda _ (apply system* `(,cc "--std=gnu99" "-o" ".config" ,@(cflags-list) ,@(ldflags-list) ".config.c"))))) + (zero? (if %verbose? (test) + (with-error-to-file "/dev/null" + test))))) (define (parse-opts args) (let* ((option-spec @@ -600,9 +616,9 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system) ("@SCHEME@" . ,(if with-cheating? guile "")) ("@SHELL@" . ,shell) - ("@CFLAGS@" . ,(or (getenv "CFLAGS") "")) + ("@CFLAGS@" . ,(or (getenv "CFLAGS") "-static -g")) ("@CPPFLAGS@" . ,(or (getenv "CPPFLAGS") "")) - ("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "")) + ("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "-static -g")) ("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") "")) ("@M1FLAGS@" . ,(or (getenv "M1FLAGS") ""))