diff --git a/ChangeLog b/ChangeLog index f8ae856..9388e45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2022-06-04 Alex Kotov * configure.ac: Remove feature "pic" + * configure.ac: Add feature "freestanding" 2022-06-03 Alex Kotov diff --git a/README.md b/README.md index 3d0a558..b91c5f5 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ stable options. #### Features +* `--enable-freestanding` - build for freestanding environment * `--enable-tests` - enable usual tests and examples * `--enable-tests-all` - enable all tests * `--enable-tests-python` - enable tests that require Python 3 with YAML and @@ -163,11 +164,11 @@ without it in `$PATH`: ``` ./configure \ --host='i386-elf' \ + --enable-freestanding \ --with-libc-all \ AR="$(which i386-elf-ar)" \ CC="$(which i386-elf-gcc)" \ - RANLIB="$(which i386-elf-ranlib)" \ - CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector' + RANLIB="$(which i386-elf-ranlib)" ``` You can see the following messages. It's diff --git a/config/dev-cross-i386 b/config/dev-cross-i386 index 36b5139..c3a0208 100755 --- a/config/dev-cross-i386 +++ b/config/dev-cross-i386 @@ -14,6 +14,4 @@ export AR="$CROSS-ar" export CC="$CROSS-gcc" export RANLIB="$CROSS-ranlib" -export CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector' - -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc-all +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc-all diff --git a/config/dev-cross-riscv64 b/config/dev-cross-riscv64 index 446cc1d..469d490 100755 --- a/config/dev-cross-riscv64 +++ b/config/dev-cross-riscv64 @@ -14,6 +14,4 @@ export AR="$CROSS-ar" export CC="$CROSS-gcc" export RANLIB="$CROSS-ranlib" -export CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector' - -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc-all +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc-all diff --git a/config/dev-cross-x86_64 b/config/dev-cross-x86_64 index 500094d..f077730 100755 --- a/config/dev-cross-x86_64 +++ b/config/dev-cross-x86_64 @@ -14,6 +14,6 @@ export AR="$CROSS-ar" export CC="$CROSS-gcc" export RANLIB="$CROSS-ranlib" -export CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector -mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone' +export CFLAGS='-mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone' -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc-all +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc-all diff --git a/config/root-cross-i386-linux b/config/root-cross-i386-linux index 199b875..dc9d809 100755 --- a/config/root-cross-i386-linux +++ b/config/root-cross-i386-linux @@ -14,6 +14,4 @@ export AR="$TARGET-ar" export CC="$TARGET-gcc" export RANLIB="$TARGET-ranlib" -export CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector' - -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc-all +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc-all diff --git a/config/root-cross-riscv64-linux b/config/root-cross-riscv64-linux index 9e153ea..6f48a85 100755 --- a/config/root-cross-riscv64-linux +++ b/config/root-cross-riscv64-linux @@ -14,6 +14,4 @@ export AR="$TARGET-ar" export CC="$TARGET-gcc" export RANLIB="$TARGET-ranlib" -export CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector' - -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc-all +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc-all diff --git a/config/root-cross-x86_64-linux b/config/root-cross-x86_64-linux index 5e0db62..ccd68b1 100755 --- a/config/root-cross-x86_64-linux +++ b/config/root-cross-x86_64-linux @@ -14,6 +14,6 @@ export AR="$TARGET-ar" export CC="$TARGET-gcc" export RANLIB="$TARGET-ranlib" -export CFLAGS='-fno-pic -ffreestanding -nostdlib -fno-stack-protector -mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone' +export CFLAGS='-mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone' -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --with-libc-all +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc-all diff --git a/configure.ac b/configure.ac index a69d194..f9a7343 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,7 @@ AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable f AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror])) dnl Features (disabled by default) +AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [build for freestanding environment])) AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [enable usual tests and examples])) AC_ARG_ENABLE([tests-all], AS_HELP_STRING([--enable-tests-all], [enable all tests])) AC_ARG_ENABLE([tests-python], AS_HELP_STRING([--enable-tests-python], [enable tests that require Python 3 with YAML and Jinja2])) @@ -104,6 +105,7 @@ AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_fl AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes]) dnl Features (disabled by default) +AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [enable_freestanding=no]) AS_IF([test "$enable_tests" = yes], [enable_tests=yes], [enable_tests=no]) AS_IF([test "$enable_tests_all" = yes], [enable_tests_all=yes], [enable_tests_all=no]) AS_IF([test "$enable_tests_python" = yes], [enable_tests_python=yes], [enable_tests_python=no]) @@ -160,6 +162,7 @@ AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes]) AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes]) dnl Features (disabled by default) +AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes]) AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" = yes]) AM_CONDITIONAL([ENABLE_TESTS_PYTHON], [test "$enable_tests_python" = yes]) @@ -202,6 +205,7 @@ AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1] AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])]) dnl Features (disabled by default) +AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])]) AS_IF([test "$enable_tests" = yes], [AC_DEFINE([ENABLE_TESTS], [1], [enabled usual tests and examples])]) AS_IF([test "$enable_tests_python" = yes], [AC_DEFINE([ENABLE_TESTS_PYTHON], [1], [enabled tests that require Python 3 with YAML and Jinja2])]) @@ -262,6 +266,12 @@ AS_IF([test "$with_libc_strnlen" = no], [AC_SUBST([comment_line_libc_strnlen], [ +AC_DEFUN([do_disable_freestanding], [CFLAGS+=' -fpic ']) +AC_DEFUN([do_enable_freestanding], [CFLAGS+=' -nostdlib -ffreestanding -fno-pic -fno-stack-protector ']) +AS_IF([test "$enable_freestanding" = yes], do_enable_freestanding, do_disable_freestanding) + + + AM_INIT_AUTOMAKE([1.9 subdir-objects]) AC_CONFIG_FILES([