configure.sh (175a4d10428e1c2f26f1426003757daf25d4726f) configure.sh (76238846ad3e9e271a3d1f792f72beab727fd153)
1#! /bin/sh
2#
3# SPDX-License-Identifier: BSD-2-Clause
4#
5# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:

--- 758 unchanged lines hidden (view full) ---

767 bc_default_prompt=""
768 dc_default_prompt=""
769 bc_default_expr_exit=1
770 dc_default_expr_exit=1
771 bc_default_digit_clamp=1
772 dc_default_digit_clamp=0;;
773
774 GDH)
1#! /bin/sh
2#
3# SPDX-License-Identifier: BSD-2-Clause
4#
5# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:

--- 758 unchanged lines hidden (view full) ---

767 bc_default_prompt=""
768 dc_default_prompt=""
769 bc_default_expr_exit=1
770 dc_default_expr_exit=1
771 bc_default_digit_clamp=1
772 dc_default_digit_clamp=0;;
773
774 GDH)
775 CFLAGS="-flto -Weverything -Wno-padded -Werror -pedantic -std=c11"
775 CFLAGS="-flto -Weverything -Wno-padded -Wno-unsafe-buffer-usage -Werror -pedantic -std=c11"
776 bc_only=0
777 dc_only=0
778 coverage=0
779 debug=0
780 optimization="3"
781 hist=1
782 hist_impl="internal"
783 extra_math=1

--- 17 unchanged lines hidden (view full) ---

801 bc_default_prompt=""
802 dc_default_prompt=""
803 bc_default_expr_exit=0
804 dc_default_expr_exit=0
805 bc_default_digit_clamp=1
806 dc_default_digit_clamp=1;;
807
808 DBG)
776 bc_only=0
777 dc_only=0
778 coverage=0
779 debug=0
780 optimization="3"
781 hist=1
782 hist_impl="internal"
783 extra_math=1

--- 17 unchanged lines hidden (view full) ---

801 bc_default_prompt=""
802 dc_default_prompt=""
803 bc_default_expr_exit=0
804 dc_default_expr_exit=0
805 bc_default_digit_clamp=1
806 dc_default_digit_clamp=1;;
807
808 DBG)
809 CFLAGS="-Weverything -Wno-padded -Werror -pedantic -std=c11"
809 CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Werror -pedantic -std=c11"
810 bc_only=0
811 dc_only=0
812 coverage=0
813 debug=1
814 optimization="0"
815 hist=1
816 hist_impl="internal"
817 extra_math=1

--- 830 unchanged lines hidden (view full) ---

1648 test_bc_history_prereqs=" test_bc_history_skip"
1649 test_dc_history_prereqs=" test_dc_history_skip"
1650 history_tests="@printf 'Skipping history tests...\\\\n'"
1651 fi
1652
1653 # We are also setting the CFLAGS and LDFLAGS here.
1654 if [ "$editline" -ne 0 ]; then
1655 LDFLAGS="$LDFLAGS -ledit"
810 bc_only=0
811 dc_only=0
812 coverage=0
813 debug=1
814 optimization="0"
815 hist=1
816 hist_impl="internal"
817 extra_math=1

--- 830 unchanged lines hidden (view full) ---

1648 test_bc_history_prereqs=" test_bc_history_skip"
1649 test_dc_history_prereqs=" test_dc_history_skip"
1650 history_tests="@printf 'Skipping history tests...\\\\n'"
1651 fi
1652
1653 # We are also setting the CFLAGS and LDFLAGS here.
1654 if [ "$editline" -ne 0 ]; then
1655 LDFLAGS="$LDFLAGS -ledit"
1656 CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
1656 CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
1657 elif [ "$readline" -ne 0 ]; then
1658 LDFLAGS="$LDFLAGS -lreadline"
1657 elif [ "$readline" -ne 0 ]; then
1658 LDFLAGS="$LDFLAGS -lreadline"
1659 CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
1659 CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
1660 else
1660 else
1661 CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
1661 CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
1662 fi
1663
1664fi
1665
1666# Test FreeBSD. This is not in an if statement because regardless of whatever
1667# the user says, we need to know if we are on FreeBSD. If we are, we cannot set
1668# _POSIX_C_SOURCE and _XOPEN_SOURCE. The FreeBSD headers turn *off* stuff when
1669# that is done.

--- 7 unchanged lines hidden (view full) ---

1677
1678if [ "$err" -ne 0 ]; then
1679 printf 'On FreeBSD. Not using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
1680else
1681 printf 'Not on FreeBSD. Using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
1682 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
1683fi
1684
1662 fi
1663
1664fi
1665
1666# Test FreeBSD. This is not in an if statement because regardless of whatever
1667# the user says, we need to know if we are on FreeBSD. If we are, we cannot set
1668# _POSIX_C_SOURCE and _XOPEN_SOURCE. The FreeBSD headers turn *off* stuff when
1669# that is done.

--- 7 unchanged lines hidden (view full) ---

1677
1678if [ "$err" -ne 0 ]; then
1679 printf 'On FreeBSD. Not using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
1680else
1681 printf 'Not on FreeBSD. Using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
1682 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
1683fi
1684
1685# Test Mac OSX. This is not in an if statement because regardless of whatever
1686# the user says, we need to know if we are on Mac OSX. If we are, we have to set
1687# _DARWIN_C_SOURCE.
1688printf 'Testing for Mac OSX...\n'
1689
1690flags="-DBC_TEST_APPLE -DBC_ENABLE_AFL=0"
1691"$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/src/vm.c" > /dev/null 2>&1
1692
1693err="$?"
1694
1695if [ "$err" -ne 0 ]; then
1696 printf 'On Mac OSX. Using _DARWIN_C_SOURCE.\n\n'
1697 apple="-D_DARWIN_C_SOURCE"
1698else
1699 printf 'Not on Mac OSX.\n\n'
1700 apple=""
1701fi
1702
1685# Test OpenBSD. This is not in an if statement because regardless of whatever
1686# the user says, we need to know if we are on OpenBSD to activate _BSD_SOURCE.
1687# No, I cannot `#define _BSD_SOURCE` in a header because OpenBSD's patched GCC
1688# and Clang complain that that is only allowed for system headers. Sigh....So we
1689# have to check at configure time and set it on the compiler command-line. And
1690# we have to set it because we also set _POSIX_C_SOURCE, which OpenBSD headers
1691# detect, and when they detect it, they turn off _BSD_SOURCE unless it is
1692# specifically requested.
1703# Test OpenBSD. This is not in an if statement because regardless of whatever
1704# the user says, we need to know if we are on OpenBSD to activate _BSD_SOURCE.
1705# No, I cannot `#define _BSD_SOURCE` in a header because OpenBSD's patched GCC
1706# and Clang complain that that is only allowed for system headers. Sigh....So we
1707# have to check at configure time and set it on the compiler command-line. And
1708# we have to set it because we also set _POSIX_C_SOURCE, which OpenBSD headers
1709# detect, and when they detect it, they turn off _BSD_SOURCE unless it is
1710# specifically requested.
1693set +e
1694printf 'Testing for OpenBSD...\n'
1695
1696flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0"
1697"$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/src/vm.c" > /dev/null 2>&1
1698
1699err="$?"
1700
1701if [ "$err" -ne 0 ]; then

--- 6 unchanged lines hidden (view full) ---

1708 usage "Cannot use readline on OpenBSD"
1709 fi
1710
1711else
1712 printf 'Not on OpenBSD.\n\n'
1713 bsd=""
1714fi
1715
1711printf 'Testing for OpenBSD...\n'
1712
1713flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0"
1714"$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/src/vm.c" > /dev/null 2>&1
1715
1716err="$?"
1717
1718if [ "$err" -ne 0 ]; then

--- 6 unchanged lines hidden (view full) ---

1725 usage "Cannot use readline on OpenBSD"
1726 fi
1727
1728else
1729 printf 'Not on OpenBSD.\n\n'
1730 bsd=""
1731fi
1732
1733set -e
1734
1716if [ "$library" -eq 1 ]; then
1717 bc_lib=""
1718fi
1719
1720if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ] && [ "$library" -eq 0 ]; then
1721 BC_LIB2_O="\$(GEN_DIR)/lib2.o"
1722else
1723 BC_LIB2_O=""

--- 343 unchanged lines hidden (view full) ---

2067
2068contents=$(replace "$contents" "GEN_DIR" "$GEN_DIR")
2069contents=$(replace "$contents" "GEN" "$GEN")
2070contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET")
2071contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
2072contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
2073
2074contents=$(replace "$contents" "BSD" "$bsd")
1735if [ "$library" -eq 1 ]; then
1736 bc_lib=""
1737fi
1738
1739if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ] && [ "$library" -eq 0 ]; then
1740 BC_LIB2_O="\$(GEN_DIR)/lib2.o"
1741else
1742 BC_LIB2_O=""

--- 343 unchanged lines hidden (view full) ---

2086
2087contents=$(replace "$contents" "GEN_DIR" "$GEN_DIR")
2088contents=$(replace "$contents" "GEN" "$GEN")
2089contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET")
2090contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
2091contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
2092
2093contents=$(replace "$contents" "BSD" "$bsd")
2094contents=$(replace "$contents" "APPLE" "$apple")
2075
2076contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner")
2077contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset")
2078contents=$(replace "$contents" "DC_DEFAULT_SIGINT_RESET" "$dc_default_sigint_reset")
2079contents=$(replace "$contents" "BC_DEFAULT_TTY_MODE" "$bc_default_tty_mode")
2080contents=$(replace "$contents" "DC_DEFAULT_TTY_MODE" "$dc_default_tty_mode")
2081contents=$(replace "$contents" "BC_DEFAULT_PROMPT" "$bc_default_prompt")
2082contents=$(replace "$contents" "DC_DEFAULT_PROMPT" "$dc_default_prompt")

--- 29 unchanged lines hidden ---
2095
2096contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner")
2097contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset")
2098contents=$(replace "$contents" "DC_DEFAULT_SIGINT_RESET" "$dc_default_sigint_reset")
2099contents=$(replace "$contents" "BC_DEFAULT_TTY_MODE" "$bc_default_tty_mode")
2100contents=$(replace "$contents" "DC_DEFAULT_TTY_MODE" "$dc_default_tty_mode")
2101contents=$(replace "$contents" "BC_DEFAULT_PROMPT" "$bc_default_prompt")
2102contents=$(replace "$contents" "DC_DEFAULT_PROMPT" "$dc_default_prompt")

--- 29 unchanged lines hidden ---