Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve portability, enable build on Solaris SPARC. #27

Merged
merged 7 commits into from Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile.in
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down Expand Up @@ -29,7 +29,7 @@
#
.POSIX:

VERSION = 2.5.0
VERSION = 2.5.1

gavinhoward marked this conversation as resolved.
Show resolved Hide resolved
SRC = %%SRC%%
OBJ = %%OBJ%%
Expand Down Expand Up @@ -140,7 +140,7 @@ BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DVERSION=$(VERSION) %%LONG_BIT_DEFINE%%
CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
gavinhoward marked this conversation as resolved.
Show resolved Hide resolved
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT)
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
@@ -1,5 +1,11 @@
# News

## 2.5.1

This is a production release which addresses portability concerns discovered
in the `bc` build system. No `bc` code was changed. Minor documentation edits
were performed (platform support and copyright year). Solaris SPARC now works.

## 2.5.0

This is a production release with new translations. No code changed.
Expand Down
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -24,9 +24,9 @@ This `bc` is Free and Open Source Software (FOSS). It is offered under the BSD
## Prerequisites

This `bc` only requires a C99-compatible compiler and a (mostly) POSIX
2008-compatible system with the XSI (X/Open System Interfaces) option group.
2001-compatible system with the XSI (X/Open System Interfaces) option group.

Since POSIX 2008 with XSI requires the existence of a C99 compiler as `c99`, any
Since POSIX 2001 with XSI requires the existence of a C99 compiler as `c99`, any
POSIX and XSI-compatible system will have everything needed.

Systems that are known to work:
Expand All @@ -36,6 +36,7 @@ Systems that are known to work:
* OpenBSD
* NetBSD
* Mac OSX
* Solaris

Please submit bug reports if this `bc` does not build out of the box on any
system besides Windows. If Windows binaries are needed, they can be found at
Expand Down
24 changes: 12 additions & 12 deletions configure.sh
@@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down Expand Up @@ -212,7 +212,7 @@ replace_ext() {
_replace_ext_ext1="$2"
_replace_ext_ext2="$3"

_replace_ext_result=$(printf "$_replace_ext_file" | sed -e "s@\.$_replace_ext_ext1@\.$_replace_ext_ext2@")
_replace_ext_result=${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2

printf '%s\n' "$_replace_ext_result"
}
Expand Down Expand Up @@ -278,7 +278,7 @@ gen_file_lists() {

if [ "$_gen_file_lists_use" -ne 0 ]; then

_gen_file_lists_replacement=$(ls $_gen_file_lists_filedir/*.c | tr '\n' ' ')
_gen_file_lists_replacement=$(cd "$_gen_file_lists_filedir" && find . ! -name . -prune -name "*.c" | cut -d/ -f2 | sed "s@^@$_gen_file_lists_filedir/@g" | tr '\n' ' ')
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_src" "$_gen_file_lists_replacement")
gavinhoward marked this conversation as resolved.
Show resolved Hide resolved

_gen_file_lists_replacement=$(replace_exts "$_gen_file_lists_replacement" "c" "o")
Expand Down Expand Up @@ -441,7 +441,7 @@ while getopts "bBcdDEfgGhHk:MNO:PST-" opt; do

done

if [ "$bc_only" -eq 1 -a "$dc_only" -eq 1 ]; then
if [ "$bc_only" -eq 1 ] && [ "$dc_only" -eq 1 ]; then
usage "Can only specify one of -b(-D) or -d(-B)"
gavinhoward marked this conversation as resolved.
Show resolved Hide resolved
fi

Expand Down Expand Up @@ -550,15 +550,15 @@ else
LONG_BIT_DEFINE="-DBC_LONG_BIT=\$(BC_LONG_BIT)"
fi

if [ -z "${HOSTCFLAGS+set}" -a -z "${HOST_CFLAGS+set}" ]; then
if [ -z "${HOSTCFLAGS+set}" ] && [ -z "${HOST_CFLAGS+set}" ]; then
HOSTCFLAGS="$CFLAGS"
elif [ -z "${HOSTCFLAGS+set}" ]; then
HOSTCFLAGS="$HOST_CFLAGS"
fi

if [ "$debug" -eq 1 ]; then

if [ -z "$CFLAGS" -a -z "$optimization" ]; then
if [ -z "$CFLAGS" ] && [ -z "$optimization" ]; then
CFLAGS="-O0"
fi

Expand All @@ -577,7 +577,7 @@ fi

if [ "$coverage" -eq 1 ]; then

if [ "$bc_only" -eq 1 -o "$dc_only" -eq 1 ]; then
if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
usage "Can only specify -c without -b or -d"
gavinhoward marked this conversation as resolved.
Show resolved Hide resolved
fi

Expand Down Expand Up @@ -608,7 +608,7 @@ if [ -z "${BINDIR+set}" ]; then
BINDIR="$PREFIX/bin"
fi

if [ "$install_manpages" -ne 0 -o "$nls" -ne 0 ]; then
if [ "$install_manpages" -ne 0 ] || [ "$nls" -ne 0 ]; then
if [ -z "${DATAROOTDIR+set}" ]; then
DATAROOTDIR="$PREFIX/share"
fi
Expand Down Expand Up @@ -637,7 +637,7 @@ if [ -z "$CC" ]; then
CC="c99"
fi

if [ -z "$HOSTCC" -a -z "$HOST_CC" ]; then
if [ -z "$HOSTCC" ] && [ -z "$HOST_CC" ]; then
HOSTCC="$CC"
elif [ -z "$HOSTCC" ]; then
HOSTCC="$HOST_CC"
Expand All @@ -652,7 +652,7 @@ if [ "$nls" -ne 0 ]; then
flags="-DBC_ENABLE_NLS=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc -DBC_ENABLE_SIGNALS=$signals"
flags="$flags -DBC_ENABLE_HISTORY=$hist"
flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/"
flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
flags="$flags -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600"

gavinhoward marked this conversation as resolved.
Show resolved Hide resolved
"$HOSTCC" $HOSTCFLAGS $flags -c "src/vm.c" -o "$scriptdir/vm.o" > /dev/null 2>&1

Expand Down Expand Up @@ -725,7 +725,7 @@ if [ "$hist" -eq 1 ]; then
flags="-DBC_ENABLE_HISTORY=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc -DBC_ENABLE_SIGNALS=$signals"
flags="$flags -DBC_ENABLE_NLS=$nls"
flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/"
flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
flags="$flags -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600"

"$HOSTCC" $HOSTCFLAGS $flags -c "src/history/history.c" -o "$scriptdir/history.o" > /dev/null 2>&1

Expand All @@ -751,7 +751,7 @@ if [ "$hist" -eq 1 ]; then

fi

if [ "$extra_math" -eq 1 -a "$bc" -ne 0 ]; then
if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ]; then
BC_LIB2_O="\$(GEN_DIR)/lib2.o"
else
BC_LIB2_O=""
Expand Down
6 changes: 3 additions & 3 deletions functions.sh
@@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down Expand Up @@ -156,10 +156,10 @@ substring_replace() {
_substring_replace_replacement="$1"
shift

_substring_replace_result=$(printf '%s' "$_substring_replace_str" | \
_substring_replace_result=$(printf '%s\n' "$_substring_replace_str" | \
sed -e "s!$_substring_replace_needle!$_substring_replace_replacement!g")

printf '%s\n' "$_substring_replace_result"
printf '%s' "$_substring_replace_result"
}
gavinhoward marked this conversation as resolved.
Show resolved Hide resolved

gen_nlspath() {
Expand Down
2 changes: 1 addition & 1 deletion gen/bc_help.txt
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion gen/dc_help.txt
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion gen/lib.bc
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion gen/lib2.bc
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
4 changes: 2 additions & 2 deletions gen/strgen.c
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down Expand Up @@ -43,7 +43,7 @@
#include <libgen.h>

static const char* const bc_gen_header =
"// Copyright (c) 2018-2019 Gavin D. Howard and contributors.\n"
"// Copyright (c) 2018-2020 Gavin D. Howard and contributors.\n"
"// Licensed under the 2-clause BSD license.\n"
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n";

Expand Down
2 changes: 1 addition & 1 deletion include/args.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bc.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/dc.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/history.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/lang.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/lex.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/num.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/parse.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/program.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/read.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/status.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/vector.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion include/vm.h
@@ -1,7 +1,7 @@
/*
* *****************************************************************************
*
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion install.sh
@@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion karatsuba.py
@@ -1,6 +1,6 @@
#! /usr/bin/python3 -B
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion link.sh
@@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion locale_install.sh
@@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion locale_uninstall.sh
@@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (c) 2018-2019 Gavin D. Howard and contributors.
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
#
# All rights reserved.
#
Expand Down