1*5a6e8488SAndroid Build Coastguard Worker# Build 2*5a6e8488SAndroid Build Coastguard Worker 3*5a6e8488SAndroid Build Coastguard WorkerThis `bc` attempts to be as portable as possible. It can be built on any 4*5a6e8488SAndroid Build Coastguard WorkerPOSIX-compliant system. 5*5a6e8488SAndroid Build Coastguard Worker 6*5a6e8488SAndroid Build Coastguard WorkerTo accomplish that, a POSIX-compatible, custom `configure.sh` script is used to 7*5a6e8488SAndroid Build Coastguard Workerselect build options, compiler, and compiler flags and generate a `Makefile`. 8*5a6e8488SAndroid Build Coastguard Worker 9*5a6e8488SAndroid Build Coastguard WorkerThe general form of configuring, building, and installing this `bc` is as 10*5a6e8488SAndroid Build Coastguard Workerfollows: 11*5a6e8488SAndroid Build Coastguard Worker 12*5a6e8488SAndroid Build Coastguard Worker``` 13*5a6e8488SAndroid Build Coastguard Worker[ENVIRONMENT_VARIABLE=<value>...] ./configure.sh [build_options...] 14*5a6e8488SAndroid Build Coastguard Workermake 15*5a6e8488SAndroid Build Coastguard Workermake install 16*5a6e8488SAndroid Build Coastguard Worker``` 17*5a6e8488SAndroid Build Coastguard Worker 18*5a6e8488SAndroid Build Coastguard WorkerTo get all of the options, including any useful environment variables, use 19*5a6e8488SAndroid Build Coastguard Workereither one of the following commands: 20*5a6e8488SAndroid Build Coastguard Worker 21*5a6e8488SAndroid Build Coastguard Worker``` 22*5a6e8488SAndroid Build Coastguard Worker./configure.sh -h 23*5a6e8488SAndroid Build Coastguard Worker./configure.sh --help 24*5a6e8488SAndroid Build Coastguard Worker``` 25*5a6e8488SAndroid Build Coastguard Worker 26*5a6e8488SAndroid Build Coastguard Worker***WARNING***: even though `configure.sh` supports both option types, short and 27*5a6e8488SAndroid Build Coastguard Workerlong, it does not support handling both at the same time. Use only one type. 28*5a6e8488SAndroid Build Coastguard Worker 29*5a6e8488SAndroid Build Coastguard WorkerTo learn the available `make` targets run the following command after running 30*5a6e8488SAndroid Build Coastguard Workerthe `configure.sh` script: 31*5a6e8488SAndroid Build Coastguard Worker 32*5a6e8488SAndroid Build Coastguard Worker``` 33*5a6e8488SAndroid Build Coastguard Workermake help 34*5a6e8488SAndroid Build Coastguard Worker``` 35*5a6e8488SAndroid Build Coastguard Worker 36*5a6e8488SAndroid Build Coastguard WorkerSee [Build Environment Variables][4] for a more detailed description of all 37*5a6e8488SAndroid Build Coastguard Workeraccepted environment variables and [Build Options][5] for more detail about all 38*5a6e8488SAndroid Build Coastguard Workeraccepted build options. 39*5a6e8488SAndroid Build Coastguard Worker 40*5a6e8488SAndroid Build Coastguard Worker## Windows 41*5a6e8488SAndroid Build Coastguard Worker 42*5a6e8488SAndroid Build Coastguard WorkerFor releases, Windows builds of `bc`, `dc`, and `bcl` are available for download 43*5a6e8488SAndroid Build Coastguard Workerfrom <https://git.gavinhoward.com/gavin/bc> and GitHub. 44*5a6e8488SAndroid Build Coastguard Worker 45*5a6e8488SAndroid Build Coastguard WorkerHowever, if you wish to build it yourself, this `bc` can be built using Visual 46*5a6e8488SAndroid Build Coastguard WorkerStudio or MSBuild. 47*5a6e8488SAndroid Build Coastguard Worker 48*5a6e8488SAndroid Build Coastguard WorkerUnfortunately, only one build configuration (besides Debug or Release) is 49*5a6e8488SAndroid Build Coastguard Workersupported: extra math and history enabled, NLS (locale support) disabled, with 50*5a6e8488SAndroid Build Coastguard Workerboth calculators built. The default [settings][11] are `BC_BANNER=1`, 51*5a6e8488SAndroid Build Coastguard Worker`{BC,DC}_SIGINT_RESET=0`, `{BC,DC}_TTY_MODE=1`, `{BC,DC}_PROMPT=1`. 52*5a6e8488SAndroid Build Coastguard Worker 53*5a6e8488SAndroid Build Coastguard WorkerThe library can also be built on Windows. 54*5a6e8488SAndroid Build Coastguard Worker 55*5a6e8488SAndroid Build Coastguard Worker### Visual Studio 56*5a6e8488SAndroid Build Coastguard Worker 57*5a6e8488SAndroid Build Coastguard WorkerIn Visual Studio, open up the solution file (`bc.sln` for `bc`, or `bcl.sln` for 58*5a6e8488SAndroid Build Coastguard Workerthe library), select the desired configuration, and build. 59*5a6e8488SAndroid Build Coastguard Worker 60*5a6e8488SAndroid Build Coastguard Worker### MSBuild 61*5a6e8488SAndroid Build Coastguard Worker 62*5a6e8488SAndroid Build Coastguard WorkerTo build with MSBuild, first, *be sure that you are using the MSBuild that comes 63*5a6e8488SAndroid Build Coastguard Workerwith Visual Studio*. 64*5a6e8488SAndroid Build Coastguard Worker 65*5a6e8488SAndroid Build Coastguard WorkerTo build `bc`, run the following from the root directory: 66*5a6e8488SAndroid Build Coastguard Worker 67*5a6e8488SAndroid Build Coastguard Worker``` 68*5a6e8488SAndroid Build Coastguard Workermsbuild -property:Configuration=<config> vs/bc.sln 69*5a6e8488SAndroid Build Coastguard Worker``` 70*5a6e8488SAndroid Build Coastguard Worker 71*5a6e8488SAndroid Build Coastguard Workerwhere `<config>` is either one of `Debug` or `Release`. 72*5a6e8488SAndroid Build Coastguard Worker 73*5a6e8488SAndroid Build Coastguard WorkerTo build the library, run the following from the root directory: 74*5a6e8488SAndroid Build Coastguard Worker 75*5a6e8488SAndroid Build Coastguard Worker``` 76*5a6e8488SAndroid Build Coastguard Workermsbuild -property:Configuration=<config> vs/bcl.sln 77*5a6e8488SAndroid Build Coastguard Worker``` 78*5a6e8488SAndroid Build Coastguard Worker 79*5a6e8488SAndroid Build Coastguard Workerwhere `<config>` is either one of `Debug`, `ReleaseMD`, or `ReleaseMT`. 80*5a6e8488SAndroid Build Coastguard Worker 81*5a6e8488SAndroid Build Coastguard Worker## POSIX-Compatible Systems 82*5a6e8488SAndroid Build Coastguard Worker 83*5a6e8488SAndroid Build Coastguard WorkerBuilding `bc`, `dc`, and `bcl` (the library) is more complex than on Windows 84*5a6e8488SAndroid Build Coastguard Workerbecause many build options are supported. 85*5a6e8488SAndroid Build Coastguard Worker 86*5a6e8488SAndroid Build Coastguard Worker### Out-of-Source Builds 87*5a6e8488SAndroid Build Coastguard Worker 88*5a6e8488SAndroid Build Coastguard WorkerOut-of-source builds are done by calling `configure.sh` from the directory where 89*5a6e8488SAndroid Build Coastguard Workerthe build will happen. The `Makefile` is generated into that directory, and the 90*5a6e8488SAndroid Build Coastguard Workerbuild can happen normally from there. 91*5a6e8488SAndroid Build Coastguard Worker 92*5a6e8488SAndroid Build Coastguard WorkerFor example, if the source is in `bc`, the build should happen in `build`, then 93*5a6e8488SAndroid Build Coastguard Workercall `configure.sh` and `make` like so: 94*5a6e8488SAndroid Build Coastguard Worker 95*5a6e8488SAndroid Build Coastguard Worker``` 96*5a6e8488SAndroid Build Coastguard Worker../bc/configure.sh 97*5a6e8488SAndroid Build Coastguard Workermake 98*5a6e8488SAndroid Build Coastguard Worker``` 99*5a6e8488SAndroid Build Coastguard Worker 100*5a6e8488SAndroid Build Coastguard Worker***WARNING***: The path to `configure.sh` from the build directory must not have 101*5a6e8488SAndroid Build Coastguard Workerspaces because `make` does not support target names with spaces. 102*5a6e8488SAndroid Build Coastguard Worker 103*5a6e8488SAndroid Build Coastguard Worker### Cross Compiling 104*5a6e8488SAndroid Build Coastguard Worker 105*5a6e8488SAndroid Build Coastguard WorkerTo cross-compile this `bc`, an appropriate compiler must be present and assigned 106*5a6e8488SAndroid Build Coastguard Workerto the environment variable `HOSTCC` or `HOST_CC` (the two are equivalent, 107*5a6e8488SAndroid Build Coastguard Workerthough `HOSTCC` is prioritized). This is in order to bootstrap core file(s), if 108*5a6e8488SAndroid Build Coastguard Workerthe architectures are not compatible (i.e., unlike i686 on x86_64). Thus, the 109*5a6e8488SAndroid Build Coastguard Workerapproach is: 110*5a6e8488SAndroid Build Coastguard Worker 111*5a6e8488SAndroid Build Coastguard Worker``` 112*5a6e8488SAndroid Build Coastguard WorkerHOSTCC="/path/to/native/compiler" ./configure.sh 113*5a6e8488SAndroid Build Coastguard Workermake 114*5a6e8488SAndroid Build Coastguard Workermake install 115*5a6e8488SAndroid Build Coastguard Worker``` 116*5a6e8488SAndroid Build Coastguard Worker 117*5a6e8488SAndroid Build Coastguard Worker`HOST_CC` will work in exactly the same way. 118*5a6e8488SAndroid Build Coastguard Worker 119*5a6e8488SAndroid Build Coastguard Worker`HOSTCFLAGS` and `HOST_CFLAGS` can be used to set compiler flags for `HOSTCC`. 120*5a6e8488SAndroid Build Coastguard Worker(The two are equivalent, as `HOSTCC` and `HOST_CC` are.) `HOSTCFLAGS` is 121*5a6e8488SAndroid Build Coastguard Workerprioritized over `HOST_CFLAGS`. If neither are present, `HOSTCC` (or `HOST_CC`) 122*5a6e8488SAndroid Build Coastguard Workeruses `CFLAGS` (see [Build Environment Variables][4] for more details). 123*5a6e8488SAndroid Build Coastguard Worker 124*5a6e8488SAndroid Build Coastguard WorkerIt is expected that `CC` produces code for the target system and `HOSTCC` 125*5a6e8488SAndroid Build Coastguard Workerproduces code for the host system. See [Build Environment Variables][4] for more 126*5a6e8488SAndroid Build Coastguard Workerdetails. 127*5a6e8488SAndroid Build Coastguard Worker 128*5a6e8488SAndroid Build Coastguard WorkerIf an emulator is necessary to run the bootstrap binaries, it can be set with 129*5a6e8488SAndroid Build Coastguard Workerthe environment variable `GEN_EMU`. 130*5a6e8488SAndroid Build Coastguard Worker 131*5a6e8488SAndroid Build Coastguard Worker### Build Environment Variables 132*5a6e8488SAndroid Build Coastguard Worker 133*5a6e8488SAndroid Build Coastguard WorkerThis `bc` supports `CC`, `HOSTCC`, `HOST_CC`, `CFLAGS`, `HOSTCFLAGS`, 134*5a6e8488SAndroid Build Coastguard Worker`HOST_CFLAGS`, `CPPFLAGS`, `LDFLAGS`, `LDLIBS`, `PREFIX`, `DESTDIR`, `BINDIR`, 135*5a6e8488SAndroid Build Coastguard Worker`DATAROOTDIR`, `DATADIR`, `MANDIR`, `MAN1DIR`, `MAN3DIR`, `EXECSUFFIX`, 136*5a6e8488SAndroid Build Coastguard Worker`EXECPREFIX`, `LONG_BIT`, `GEN_HOST`, and `GEN_EMU` environment variables in 137*5a6e8488SAndroid Build Coastguard Worker`configure.sh`. Any values of those variables given to `configure.sh` will be 138*5a6e8488SAndroid Build Coastguard Workerput into the generated Makefile. 139*5a6e8488SAndroid Build Coastguard Worker 140*5a6e8488SAndroid Build Coastguard WorkerMore detail on what those environment variables do can be found in the following 141*5a6e8488SAndroid Build Coastguard Workersections. 142*5a6e8488SAndroid Build Coastguard Worker 143*5a6e8488SAndroid Build Coastguard Worker#### `CC` 144*5a6e8488SAndroid Build Coastguard Worker 145*5a6e8488SAndroid Build Coastguard WorkerC compiler for the target system. `CC` must be compatible with POSIX `c99` 146*5a6e8488SAndroid Build Coastguard Workerbehavior and options. However, **I encourage users to use any C99 or C11 147*5a6e8488SAndroid Build Coastguard Workercompatible compiler they wish.** 148*5a6e8488SAndroid Build Coastguard Worker 149*5a6e8488SAndroid Build Coastguard WorkerIf there is a space in the basename of the compiler, the items after the first 150*5a6e8488SAndroid Build Coastguard Workerspace are assumed to be compiler flags, and in that case, the flags are 151*5a6e8488SAndroid Build Coastguard Workerautomatically moved into CFLAGS. 152*5a6e8488SAndroid Build Coastguard Worker 153*5a6e8488SAndroid Build Coastguard WorkerDefaults to `c99`. 154*5a6e8488SAndroid Build Coastguard Worker 155*5a6e8488SAndroid Build Coastguard Worker#### `HOSTCC` or `HOST_CC` 156*5a6e8488SAndroid Build Coastguard Worker 157*5a6e8488SAndroid Build Coastguard WorkerC compiler for the host system, used only in [cross compiling][6]. Must be 158*5a6e8488SAndroid Build Coastguard Workercompatible with POSIX `c99` behavior and options. 159*5a6e8488SAndroid Build Coastguard Worker 160*5a6e8488SAndroid Build Coastguard WorkerIf there is a space in the basename of the compiler, the items after the first 161*5a6e8488SAndroid Build Coastguard Workerspace are assumed to be compiler flags, and in that case, the flags are 162*5a6e8488SAndroid Build Coastguard Workerautomatically moved into HOSTCFLAGS. 163*5a6e8488SAndroid Build Coastguard Worker 164*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$CC`. 165*5a6e8488SAndroid Build Coastguard Worker 166*5a6e8488SAndroid Build Coastguard Worker#### `CFLAGS` 167*5a6e8488SAndroid Build Coastguard Worker 168*5a6e8488SAndroid Build Coastguard WorkerCommand-line flags that will be passed verbatim to `CC`. 169*5a6e8488SAndroid Build Coastguard Worker 170*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 171*5a6e8488SAndroid Build Coastguard Worker 172*5a6e8488SAndroid Build Coastguard Worker#### `HOSTCFLAGS` or `HOST_CFLAGS` 173*5a6e8488SAndroid Build Coastguard Worker 174*5a6e8488SAndroid Build Coastguard WorkerCommand-line flags that will be passed verbatim to `HOSTCC` or `HOST_CC`. 175*5a6e8488SAndroid Build Coastguard Worker 176*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$CFLAGS`. 177*5a6e8488SAndroid Build Coastguard Worker 178*5a6e8488SAndroid Build Coastguard Worker#### `CPPFLAGS` 179*5a6e8488SAndroid Build Coastguard Worker 180*5a6e8488SAndroid Build Coastguard WorkerCommand-line flags for the C preprocessor. These are also passed verbatim to 181*5a6e8488SAndroid Build Coastguard Workerboth compilers (`CC` and `HOSTCC`); they are supported just for legacy reasons. 182*5a6e8488SAndroid Build Coastguard Worker 183*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 184*5a6e8488SAndroid Build Coastguard Worker 185*5a6e8488SAndroid Build Coastguard Worker#### `LDFLAGS` 186*5a6e8488SAndroid Build Coastguard Worker 187*5a6e8488SAndroid Build Coastguard WorkerCommand-line flags for the linker. These are also passed verbatim to both 188*5a6e8488SAndroid Build Coastguard Workercompilers (`CC` and `HOSTCC`); they are supported just for legacy reasons. 189*5a6e8488SAndroid Build Coastguard Worker 190*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 191*5a6e8488SAndroid Build Coastguard Worker 192*5a6e8488SAndroid Build Coastguard Worker#### `LDLIBS` 193*5a6e8488SAndroid Build Coastguard Worker 194*5a6e8488SAndroid Build Coastguard WorkerLibraries to link to. These are also passed verbatim to both compilers (`CC` and 195*5a6e8488SAndroid Build Coastguard Worker`HOSTCC`); they are supported just for legacy reasons and for cross compiling 196*5a6e8488SAndroid Build Coastguard Workerwith different C standard libraries (like [musl][3]). 197*5a6e8488SAndroid Build Coastguard Worker 198*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 199*5a6e8488SAndroid Build Coastguard Worker 200*5a6e8488SAndroid Build Coastguard Worker#### `PREFIX` 201*5a6e8488SAndroid Build Coastguard Worker 202*5a6e8488SAndroid Build Coastguard WorkerThe prefix to install to. 203*5a6e8488SAndroid Build Coastguard Worker 204*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--prefix` option to `configure.sh`. 205*5a6e8488SAndroid Build Coastguard Worker 206*5a6e8488SAndroid Build Coastguard WorkerDefaults to `/usr/local`. 207*5a6e8488SAndroid Build Coastguard Worker 208*5a6e8488SAndroid Build Coastguard Worker***WARNING***: Locales ignore the prefix because they *must* be installed at a 209*5a6e8488SAndroid Build Coastguard Workerfixed location to work at all. If you do not want that to happen, you must 210*5a6e8488SAndroid Build Coastguard Workerdisable locales (NLS) completely. 211*5a6e8488SAndroid Build Coastguard Worker 212*5a6e8488SAndroid Build Coastguard Worker#### `DESTDIR` 213*5a6e8488SAndroid Build Coastguard Worker 214*5a6e8488SAndroid Build Coastguard WorkerPath to prepend onto `PREFIX`. This is mostly for distro and package 215*5a6e8488SAndroid Build Coastguard Workermaintainers. 216*5a6e8488SAndroid Build Coastguard Worker 217*5a6e8488SAndroid Build Coastguard WorkerThis can be passed either to `configure.sh` or `make install`. If it is passed 218*5a6e8488SAndroid Build Coastguard Workerto both, the one given to `configure.sh` takes precedence. 219*5a6e8488SAndroid Build Coastguard Worker 220*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 221*5a6e8488SAndroid Build Coastguard Worker 222*5a6e8488SAndroid Build Coastguard Worker#### `BINDIR` 223*5a6e8488SAndroid Build Coastguard Worker 224*5a6e8488SAndroid Build Coastguard WorkerThe directory to install binaries in. 225*5a6e8488SAndroid Build Coastguard Worker 226*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--bindir` option to `configure.sh`. 227*5a6e8488SAndroid Build Coastguard Worker 228*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$PREFIX/bin`. 229*5a6e8488SAndroid Build Coastguard Worker 230*5a6e8488SAndroid Build Coastguard Worker#### `INCLUDEDIR` 231*5a6e8488SAndroid Build Coastguard Worker 232*5a6e8488SAndroid Build Coastguard WorkerThe directory to install header files in. 233*5a6e8488SAndroid Build Coastguard Worker 234*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--includedir` option to `configure.sh`. 235*5a6e8488SAndroid Build Coastguard Worker 236*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$PREFIX/include`. 237*5a6e8488SAndroid Build Coastguard Worker 238*5a6e8488SAndroid Build Coastguard Worker#### `LIBDIR` 239*5a6e8488SAndroid Build Coastguard Worker 240*5a6e8488SAndroid Build Coastguard WorkerThe directory to install libraries in. 241*5a6e8488SAndroid Build Coastguard Worker 242*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--libdir` option to `configure.sh`. 243*5a6e8488SAndroid Build Coastguard Worker 244*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$PREFIX/lib`. 245*5a6e8488SAndroid Build Coastguard Worker 246*5a6e8488SAndroid Build Coastguard Worker#### `DATAROOTDIR` 247*5a6e8488SAndroid Build Coastguard Worker 248*5a6e8488SAndroid Build Coastguard WorkerThe root directory to install data files in. 249*5a6e8488SAndroid Build Coastguard Worker 250*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--datarootdir` option to `configure.sh`. 251*5a6e8488SAndroid Build Coastguard Worker 252*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$PREFIX/share`. 253*5a6e8488SAndroid Build Coastguard Worker 254*5a6e8488SAndroid Build Coastguard Worker#### `DATADIR` 255*5a6e8488SAndroid Build Coastguard Worker 256*5a6e8488SAndroid Build Coastguard WorkerThe directory to install data files in. 257*5a6e8488SAndroid Build Coastguard Worker 258*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--datadir` option to `configure.sh`. 259*5a6e8488SAndroid Build Coastguard Worker 260*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$DATAROOTDIR`. 261*5a6e8488SAndroid Build Coastguard Worker 262*5a6e8488SAndroid Build Coastguard Worker#### `MANDIR` 263*5a6e8488SAndroid Build Coastguard Worker 264*5a6e8488SAndroid Build Coastguard WorkerThe directory to install manpages in. 265*5a6e8488SAndroid Build Coastguard Worker 266*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--mandir` option to `configure.sh`. 267*5a6e8488SAndroid Build Coastguard Worker 268*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$DATADIR/man` 269*5a6e8488SAndroid Build Coastguard Worker 270*5a6e8488SAndroid Build Coastguard Worker#### `MAN1DIR` 271*5a6e8488SAndroid Build Coastguard Worker 272*5a6e8488SAndroid Build Coastguard WorkerThe directory to install Section 1 manpages in. Because both `bc` and `dc` are 273*5a6e8488SAndroid Build Coastguard WorkerSection 1 commands, this is the only relevant section directory. 274*5a6e8488SAndroid Build Coastguard Worker 275*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--man1dir` option to `configure.sh`. 276*5a6e8488SAndroid Build Coastguard Worker 277*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$MANDIR/man1`. 278*5a6e8488SAndroid Build Coastguard Worker 279*5a6e8488SAndroid Build Coastguard Worker#### `MAN3DIR` 280*5a6e8488SAndroid Build Coastguard Worker 281*5a6e8488SAndroid Build Coastguard WorkerThe directory to install Section 3 manpages in. 282*5a6e8488SAndroid Build Coastguard Worker 283*5a6e8488SAndroid Build Coastguard WorkerCan be overridden by passing the `--man3dir` option to `configure.sh`. 284*5a6e8488SAndroid Build Coastguard Worker 285*5a6e8488SAndroid Build Coastguard WorkerDefaults to `$MANDIR/man3`. 286*5a6e8488SAndroid Build Coastguard Worker 287*5a6e8488SAndroid Build Coastguard Worker#### `EXECSUFFIX` 288*5a6e8488SAndroid Build Coastguard Worker 289*5a6e8488SAndroid Build Coastguard WorkerThe suffix to append onto the executable names *when installing*. This is for 290*5a6e8488SAndroid Build Coastguard Workerpackagers and distro maintainers who want this `bc` as an option, but do not 291*5a6e8488SAndroid Build Coastguard Workerwant to replace the default `bc`. 292*5a6e8488SAndroid Build Coastguard Worker 293*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 294*5a6e8488SAndroid Build Coastguard Worker 295*5a6e8488SAndroid Build Coastguard Worker#### `EXECPREFIX` 296*5a6e8488SAndroid Build Coastguard Worker 297*5a6e8488SAndroid Build Coastguard WorkerThe prefix to append onto the executable names *when building and installing*. 298*5a6e8488SAndroid Build Coastguard WorkerThis is for packagers and distro maintainers who want this `bc` as an option, 299*5a6e8488SAndroid Build Coastguard Workerbut do not want to replace the default `bc`. 300*5a6e8488SAndroid Build Coastguard Worker 301*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 302*5a6e8488SAndroid Build Coastguard Worker 303*5a6e8488SAndroid Build Coastguard Worker#### `LONG_BIT` 304*5a6e8488SAndroid Build Coastguard Worker 305*5a6e8488SAndroid Build Coastguard WorkerThe number of bits in a C `long` type. This is mostly for the embedded space. 306*5a6e8488SAndroid Build Coastguard Worker 307*5a6e8488SAndroid Build Coastguard WorkerThis `bc` uses `long`s internally for overflow checking. In C99, a `long` is 308*5a6e8488SAndroid Build Coastguard Workerrequired to be 32 bits. For this reason, on 8-bit and 16-bit microcontrollers, 309*5a6e8488SAndroid Build Coastguard Workerthe generated code to do math with `long` types may be inefficient. 310*5a6e8488SAndroid Build Coastguard Worker 311*5a6e8488SAndroid Build Coastguard WorkerFor most normal desktop systems, setting this is unnecessary, except that 32-bit 312*5a6e8488SAndroid Build Coastguard Workerplatforms with 64-bit longs may want to set it to `32`. 313*5a6e8488SAndroid Build Coastguard Worker 314*5a6e8488SAndroid Build Coastguard WorkerDefaults to the default value of `LONG_BIT` for the target platform. For 315*5a6e8488SAndroid Build Coastguard Workercompliance with the `bc` spec, the minimum allowed value is `32`. 316*5a6e8488SAndroid Build Coastguard Worker 317*5a6e8488SAndroid Build Coastguard WorkerIt is an error if the specified value is greater than the default value of 318*5a6e8488SAndroid Build Coastguard Worker`LONG_BIT` for the target platform. 319*5a6e8488SAndroid Build Coastguard Worker 320*5a6e8488SAndroid Build Coastguard Worker#### `GEN_HOST` 321*5a6e8488SAndroid Build Coastguard Worker 322*5a6e8488SAndroid Build Coastguard WorkerWhether to use `gen/strgen.c`, instead of `gen/strgen.sh`, to produce the C 323*5a6e8488SAndroid Build Coastguard Workerfiles that contain the help texts as well as the math libraries. By default, 324*5a6e8488SAndroid Build Coastguard Worker`gen/strgen.c` is used, compiled by `$HOSTCC` and run on the host machine. Using 325*5a6e8488SAndroid Build Coastguard Worker`gen/strgen.sh` removes the need to compile and run an executable on the host 326*5a6e8488SAndroid Build Coastguard Workermachine since `gen/strgen.sh` is a POSIX shell script. However, `gen/lib2.bc` is 327*5a6e8488SAndroid Build Coastguard Workerperilously close to 4095 characters, the max supported length of a string 328*5a6e8488SAndroid Build Coastguard Workerliteral in C99 (and it could be added to in the future), and `gen/strgen.sh` 329*5a6e8488SAndroid Build Coastguard Workergenerates a string literal instead of an array, as `gen/strgen.c` does. For most 330*5a6e8488SAndroid Build Coastguard Workerproduction-ready compilers, this limit probably is not enforced, but it could 331*5a6e8488SAndroid Build Coastguard Workerbe. Both options are still available for this reason. 332*5a6e8488SAndroid Build Coastguard Worker 333*5a6e8488SAndroid Build Coastguard WorkerIf you are sure your compiler does not have the limit and do not want to compile 334*5a6e8488SAndroid Build Coastguard Workerand run a binary on the host machine, set this variable to "0". Any other value, 335*5a6e8488SAndroid Build Coastguard Workeror a non-existent value, will cause the build system to compile and run 336*5a6e8488SAndroid Build Coastguard Worker`gen/strgen.c`. 337*5a6e8488SAndroid Build Coastguard Worker 338*5a6e8488SAndroid Build Coastguard WorkerDefault is "". 339*5a6e8488SAndroid Build Coastguard Worker 340*5a6e8488SAndroid Build Coastguard Worker#### `GEN_EMU` 341*5a6e8488SAndroid Build Coastguard Worker 342*5a6e8488SAndroid Build Coastguard WorkerThe emulator to run bootstrap binaries under. This is only if the binaries 343*5a6e8488SAndroid Build Coastguard Workerproduced by `HOSTCC` (or `HOST_CC`) need to be run under an emulator to work. 344*5a6e8488SAndroid Build Coastguard Worker 345*5a6e8488SAndroid Build Coastguard WorkerDefaults to empty. 346*5a6e8488SAndroid Build Coastguard Worker 347*5a6e8488SAndroid Build Coastguard Worker### Build Options 348*5a6e8488SAndroid Build Coastguard Worker 349*5a6e8488SAndroid Build Coastguard WorkerThis `bc` comes with several build options, all of which are enabled by default. 350*5a6e8488SAndroid Build Coastguard Worker 351*5a6e8488SAndroid Build Coastguard WorkerAll options can be used with each other, with a few exceptions that will be 352*5a6e8488SAndroid Build Coastguard Workernoted below. 353*5a6e8488SAndroid Build Coastguard Worker 354*5a6e8488SAndroid Build Coastguard Worker**NOTE**: All long options with mandatory argumenst accept either one of the 355*5a6e8488SAndroid Build Coastguard Workerfollowing forms: 356*5a6e8488SAndroid Build Coastguard Worker 357*5a6e8488SAndroid Build Coastguard Worker``` 358*5a6e8488SAndroid Build Coastguard Worker--option arg 359*5a6e8488SAndroid Build Coastguard Worker--option=arg 360*5a6e8488SAndroid Build Coastguard Worker``` 361*5a6e8488SAndroid Build Coastguard Worker 362*5a6e8488SAndroid Build Coastguard Worker#### Predefined Builds 363*5a6e8488SAndroid Build Coastguard Worker 364*5a6e8488SAndroid Build Coastguard WorkerTo quickly get a release build of a `bc` and `dc` that is (by default) 365*5a6e8488SAndroid Build Coastguard Workercompatible with the BSD `bc` and `dc`, use the `-p` or `--predefined-build-type` 366*5a6e8488SAndroid Build Coastguard Workeroptions: 367*5a6e8488SAndroid Build Coastguard Worker 368*5a6e8488SAndroid Build Coastguard Worker``` 369*5a6e8488SAndroid Build Coastguard Worker./configure.sh -pBSD 370*5a6e8488SAndroid Build Coastguard Worker./configure.sh --predefined-build-type=BSD 371*5a6e8488SAndroid Build Coastguard Worker``` 372*5a6e8488SAndroid Build Coastguard Worker 373*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 374*5a6e8488SAndroid Build Coastguard Worker 375*5a6e8488SAndroid Build Coastguard WorkerTo quickly get a release build of a `bc` and `dc` that is (by default) 376*5a6e8488SAndroid Build Coastguard Workercompatible with the GNU `bc` and `dc`, use the `-p` or `--predefined-build-type` 377*5a6e8488SAndroid Build Coastguard Workeroptions: 378*5a6e8488SAndroid Build Coastguard Worker 379*5a6e8488SAndroid Build Coastguard Worker``` 380*5a6e8488SAndroid Build Coastguard Worker./configure.sh -pGNU 381*5a6e8488SAndroid Build Coastguard Worker./configure.sh --predefined-build-type=GNU 382*5a6e8488SAndroid Build Coastguard Worker``` 383*5a6e8488SAndroid Build Coastguard Worker 384*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 385*5a6e8488SAndroid Build Coastguard Worker 386*5a6e8488SAndroid Build Coastguard Worker#### Library 387*5a6e8488SAndroid Build Coastguard Worker 388*5a6e8488SAndroid Build Coastguard WorkerTo build the math library, use the following commands for the configure step: 389*5a6e8488SAndroid Build Coastguard Worker 390*5a6e8488SAndroid Build Coastguard Worker``` 391*5a6e8488SAndroid Build Coastguard Worker./configure.sh -a 392*5a6e8488SAndroid Build Coastguard Worker./configure.sh --library 393*5a6e8488SAndroid Build Coastguard Worker``` 394*5a6e8488SAndroid Build Coastguard Worker 395*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 396*5a6e8488SAndroid Build Coastguard Worker 397*5a6e8488SAndroid Build Coastguard WorkerWhen the library is built, history and locales are disabled, and the 398*5a6e8488SAndroid Build Coastguard Workerfunctionality for `bc` and `dc` are both enabled, though the executables are 399*5a6e8488SAndroid Build Coastguard Worker*not* built. This is because the library's options clash with the executables. 400*5a6e8488SAndroid Build Coastguard Worker 401*5a6e8488SAndroid Build Coastguard WorkerTo build an optimized version of the library, users can pass optimization 402*5a6e8488SAndroid Build Coastguard Workeroptions to `configure.sh` or include them in `CFLAGS`. 403*5a6e8488SAndroid Build Coastguard Worker 404*5a6e8488SAndroid Build Coastguard WorkerThe library API can be found in `manuals/bcl.3.md` or `man bcl` once the library 405*5a6e8488SAndroid Build Coastguard Workeris installed. 406*5a6e8488SAndroid Build Coastguard Worker 407*5a6e8488SAndroid Build Coastguard WorkerThe library is built as `bin/libbcl.a`. 408*5a6e8488SAndroid Build Coastguard Worker 409*5a6e8488SAndroid Build Coastguard Worker#### `bc` Only 410*5a6e8488SAndroid Build Coastguard Worker 411*5a6e8488SAndroid Build Coastguard WorkerTo build `bc` only (no `dc`), use any one of the following commands for the 412*5a6e8488SAndroid Build Coastguard Workerconfigure step: 413*5a6e8488SAndroid Build Coastguard Worker 414*5a6e8488SAndroid Build Coastguard Worker``` 415*5a6e8488SAndroid Build Coastguard Worker./configure.sh -b 416*5a6e8488SAndroid Build Coastguard Worker./configure.sh --bc-only 417*5a6e8488SAndroid Build Coastguard Worker./configure.sh -D 418*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-dc 419*5a6e8488SAndroid Build Coastguard Worker``` 420*5a6e8488SAndroid Build Coastguard Worker 421*5a6e8488SAndroid Build Coastguard WorkerThose commands are all equivalent. 422*5a6e8488SAndroid Build Coastguard Worker 423*5a6e8488SAndroid Build Coastguard Worker***Warning***: It is an error to use those options if `bc` has also been 424*5a6e8488SAndroid Build Coastguard Workerdisabled (see below). 425*5a6e8488SAndroid Build Coastguard Worker 426*5a6e8488SAndroid Build Coastguard Worker#### `dc` Only 427*5a6e8488SAndroid Build Coastguard Worker 428*5a6e8488SAndroid Build Coastguard WorkerTo build `dc` only (no `bc`), use either one of the following commands for the 429*5a6e8488SAndroid Build Coastguard Workerconfigure step: 430*5a6e8488SAndroid Build Coastguard Worker 431*5a6e8488SAndroid Build Coastguard Worker``` 432*5a6e8488SAndroid Build Coastguard Worker./configure.sh -d 433*5a6e8488SAndroid Build Coastguard Worker./configure.sh --dc-only 434*5a6e8488SAndroid Build Coastguard Worker./configure.sh -B 435*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-bc 436*5a6e8488SAndroid Build Coastguard Worker``` 437*5a6e8488SAndroid Build Coastguard Worker 438*5a6e8488SAndroid Build Coastguard WorkerThose commands are all equivalent. 439*5a6e8488SAndroid Build Coastguard Worker 440*5a6e8488SAndroid Build Coastguard Worker***Warning***: It is an error to use those options if `dc` has also been 441*5a6e8488SAndroid Build Coastguard Workerdisabled (see above). 442*5a6e8488SAndroid Build Coastguard Worker 443*5a6e8488SAndroid Build Coastguard Worker#### History 444*5a6e8488SAndroid Build Coastguard Worker 445*5a6e8488SAndroid Build Coastguard WorkerTo disable hisory, pass either the `-H` flag or the `--disable-history` option 446*5a6e8488SAndroid Build Coastguard Workerto `configure.sh`, as follows: 447*5a6e8488SAndroid Build Coastguard Worker 448*5a6e8488SAndroid Build Coastguard Worker``` 449*5a6e8488SAndroid Build Coastguard Worker./configure.sh -H 450*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-history 451*5a6e8488SAndroid Build Coastguard Worker``` 452*5a6e8488SAndroid Build Coastguard Worker 453*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 454*5a6e8488SAndroid Build Coastguard Worker 455*5a6e8488SAndroid Build Coastguard Worker***WARNING***: Of all of the code in the `bc`, this is the only code that is not 456*5a6e8488SAndroid Build Coastguard Workercompletely portable. If the `bc` does not work on your platform, your first step 457*5a6e8488SAndroid Build Coastguard Workershould be to retry with history disabled. 458*5a6e8488SAndroid Build Coastguard Worker 459*5a6e8488SAndroid Build Coastguard WorkerThis option affects the [build type][7]. 460*5a6e8488SAndroid Build Coastguard Worker 461*5a6e8488SAndroid Build Coastguard Worker##### Editline 462*5a6e8488SAndroid Build Coastguard Worker 463*5a6e8488SAndroid Build Coastguard WorkerHistory support can be provided by editline, in order to implement `vi`-like 464*5a6e8488SAndroid Build Coastguard Workerkeybindings and other features. 465*5a6e8488SAndroid Build Coastguard Worker 466*5a6e8488SAndroid Build Coastguard WorkerTo enable editline support, pass either the `-e` flag or the `--enable-editline` 467*5a6e8488SAndroid Build Coastguard Workeroption to `configure.sh`, as follows: 468*5a6e8488SAndroid Build Coastguard Worker 469*5a6e8488SAndroid Build Coastguard Worker``` 470*5a6e8488SAndroid Build Coastguard Worker./configure.sh -e 471*5a6e8488SAndroid Build Coastguard Worker./configure.sh --enable-editline 472*5a6e8488SAndroid Build Coastguard Worker``` 473*5a6e8488SAndroid Build Coastguard Worker 474*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 475*5a6e8488SAndroid Build Coastguard Worker 476*5a6e8488SAndroid Build Coastguard WorkerThis is ignored if history is disabled. 477*5a6e8488SAndroid Build Coastguard Worker 478*5a6e8488SAndroid Build Coastguard WorkerThis option is only used if it is after any other `-e`/`--enable-editline` 479*5a6e8488SAndroid Build Coastguard Workeroptions, any `-r`/`--enable-readline` options, and any 480*5a6e8488SAndroid Build Coastguard Worker`-i`/`--enable-internal-history` options. 481*5a6e8488SAndroid Build Coastguard Worker 482*5a6e8488SAndroid Build Coastguard Worker##### Readline 483*5a6e8488SAndroid Build Coastguard Worker 484*5a6e8488SAndroid Build Coastguard WorkerHistory support can be provided by readline, in order to implement `vi`-like 485*5a6e8488SAndroid Build Coastguard Workerkeybindings and other features. 486*5a6e8488SAndroid Build Coastguard Worker 487*5a6e8488SAndroid Build Coastguard WorkerTo enable readline support, pass either the `-r` flag or the `--enable-readline` 488*5a6e8488SAndroid Build Coastguard Workeroption to `configure.sh`, as follows: 489*5a6e8488SAndroid Build Coastguard Worker 490*5a6e8488SAndroid Build Coastguard Worker``` 491*5a6e8488SAndroid Build Coastguard Worker./configure.sh -r 492*5a6e8488SAndroid Build Coastguard Worker./configure.sh --enable-readline 493*5a6e8488SAndroid Build Coastguard Worker``` 494*5a6e8488SAndroid Build Coastguard Worker 495*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 496*5a6e8488SAndroid Build Coastguard Worker 497*5a6e8488SAndroid Build Coastguard WorkerThis is ignored if history is disabled. 498*5a6e8488SAndroid Build Coastguard Worker 499*5a6e8488SAndroid Build Coastguard WorkerThis option is only used if it is after any other `-r`/`--enable-readline` 500*5a6e8488SAndroid Build Coastguard Workeroptions, any `-e`/`--enable-editline` options, and any 501*5a6e8488SAndroid Build Coastguard Worker`-i`/`--enable-internal-history` options. 502*5a6e8488SAndroid Build Coastguard Worker 503*5a6e8488SAndroid Build Coastguard Worker##### Internal History 504*5a6e8488SAndroid Build Coastguard Worker 505*5a6e8488SAndroid Build Coastguard WorkerHistory support is also available as an internal implementation with no 506*5a6e8488SAndroid Build Coastguard Workerdependencies. This is the default if editline and readline are not selected. 507*5a6e8488SAndroid Build Coastguard Worker 508*5a6e8488SAndroid Build Coastguard WorkerHowever, if `-p` option is used, then this option can be useful for selecting 509*5a6e8488SAndroid Build Coastguard Workerthe internal history regardless of what the predefined build has. 510*5a6e8488SAndroid Build Coastguard Worker 511*5a6e8488SAndroid Build Coastguard WorkerTo enable the internal history, pass either the `-i` flag or the 512*5a6e8488SAndroid Build Coastguard Worker`--enable-internal-history` option to `configure.sh` as follows: 513*5a6e8488SAndroid Build Coastguard Worker 514*5a6e8488SAndroid Build Coastguard Worker``` 515*5a6e8488SAndroid Build Coastguard Worker./configure.sh -i 516*5a6e8488SAndroid Build Coastguard Worker./configure.sh --enable-internal-history 517*5a6e8488SAndroid Build Coastguard Worker``` 518*5a6e8488SAndroid Build Coastguard Worker 519*5a6e8488SAndroid Build Coastguard WorkerThis option is only used if it is after any other 520*5a6e8488SAndroid Build Coastguard Worker`-i`/`--enable-internal-history` options, any `-e`/`--enable-editline` options, 521*5a6e8488SAndroid Build Coastguard Workerand any `-r`/`--enable-readline` options. 522*5a6e8488SAndroid Build Coastguard Worker 523*5a6e8488SAndroid Build Coastguard Worker#### NLS (Locale Support) 524*5a6e8488SAndroid Build Coastguard Worker 525*5a6e8488SAndroid Build Coastguard WorkerTo disable locale support (use only English), pass either the `-N` flag or the 526*5a6e8488SAndroid Build Coastguard Worker`--disable-nls` option to `configure.sh`, as follows: 527*5a6e8488SAndroid Build Coastguard Worker 528*5a6e8488SAndroid Build Coastguard Worker``` 529*5a6e8488SAndroid Build Coastguard Worker./configure.sh -N 530*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-nls 531*5a6e8488SAndroid Build Coastguard Worker``` 532*5a6e8488SAndroid Build Coastguard Worker 533*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 534*5a6e8488SAndroid Build Coastguard Worker 535*5a6e8488SAndroid Build Coastguard WorkerNLS (locale support) is automatically disabled when building for Windows or on 536*5a6e8488SAndroid Build Coastguard Workeranother platform that does not support the POSIX locale API or utilities. 537*5a6e8488SAndroid Build Coastguard Worker 538*5a6e8488SAndroid Build Coastguard WorkerThis option affects the [build type][7]. 539*5a6e8488SAndroid Build Coastguard Worker 540*5a6e8488SAndroid Build Coastguard Worker***WARNING***: Locales ignore the prefix because they *must* be installed at a 541*5a6e8488SAndroid Build Coastguard Workerfixed location to work at all. If you do not want that to happen, you must 542*5a6e8488SAndroid Build Coastguard Workerdisable locales (NLS) completely. 543*5a6e8488SAndroid Build Coastguard Worker 544*5a6e8488SAndroid Build Coastguard Worker#### Extra Math 545*5a6e8488SAndroid Build Coastguard Worker 546*5a6e8488SAndroid Build Coastguard WorkerThis `bc` has 7 extra operators: 547*5a6e8488SAndroid Build Coastguard Worker 548*5a6e8488SAndroid Build Coastguard Worker* `$` (truncation to integer) 549*5a6e8488SAndroid Build Coastguard Worker* `@` (set precision) 550*5a6e8488SAndroid Build Coastguard Worker* `@=` (set precision and assign) 551*5a6e8488SAndroid Build Coastguard Worker* `<<` (shift number left, shifts radix right) 552*5a6e8488SAndroid Build Coastguard Worker* `<<=` (shift number left and assign) 553*5a6e8488SAndroid Build Coastguard Worker* `>>` (shift number right, shifts radix left) 554*5a6e8488SAndroid Build Coastguard Worker* `>>=` (shift number right and assign) 555*5a6e8488SAndroid Build Coastguard Worker 556*5a6e8488SAndroid Build Coastguard WorkerThere is no assignment version of `$` because it is a unary operator. 557*5a6e8488SAndroid Build Coastguard Worker 558*5a6e8488SAndroid Build Coastguard WorkerThe assignment versions of the above operators are not available in `dc`, but 559*5a6e8488SAndroid Build Coastguard Workerthe others are, as the operators `$`, `@`, `H`, and `h`, respectively. 560*5a6e8488SAndroid Build Coastguard Worker 561*5a6e8488SAndroid Build Coastguard WorkerIn addition, this `bc` has the option of outputting in scientific notation or 562*5a6e8488SAndroid Build Coastguard Workerengineering notation. It can also take input in scientific or engineering 563*5a6e8488SAndroid Build Coastguard Workernotation. On top of that, it has a pseudo-random number generator. (See the 564*5a6e8488SAndroid Build Coastguard Workerfull manual for more details.) 565*5a6e8488SAndroid Build Coastguard Worker 566*5a6e8488SAndroid Build Coastguard WorkerExtra operators, scientific notation, engineering notation, and the 567*5a6e8488SAndroid Build Coastguard Workerpseudo-random number generator can be disabled by passing either the `-E` flag 568*5a6e8488SAndroid Build Coastguard Workeror the `--disable-extra-math` option to `configure.sh`, as follows: 569*5a6e8488SAndroid Build Coastguard Worker 570*5a6e8488SAndroid Build Coastguard Worker``` 571*5a6e8488SAndroid Build Coastguard Worker./configure.sh -E 572*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-extra-math 573*5a6e8488SAndroid Build Coastguard Worker``` 574*5a6e8488SAndroid Build Coastguard Worker 575*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 576*5a6e8488SAndroid Build Coastguard Worker 577*5a6e8488SAndroid Build Coastguard WorkerThis `bc` also has a larger library that is only enabled if extra operators and 578*5a6e8488SAndroid Build Coastguard Workerthe pseudo-random number generator are. More information about the functions can 579*5a6e8488SAndroid Build Coastguard Workerbe found in the Extended Library section of the full manual. 580*5a6e8488SAndroid Build Coastguard Worker 581*5a6e8488SAndroid Build Coastguard WorkerThis option affects the [build type][7]. 582*5a6e8488SAndroid Build Coastguard Worker 583*5a6e8488SAndroid Build Coastguard Worker#### Karatsuba Length 584*5a6e8488SAndroid Build Coastguard Worker 585*5a6e8488SAndroid Build Coastguard WorkerThe Karatsuba length is the point at which `bc` and `dc` switch from Karatsuba 586*5a6e8488SAndroid Build Coastguard Workermultiplication to brute force, `O(n^2)` multiplication. It can be set by passing 587*5a6e8488SAndroid Build Coastguard Workerthe `-k` flag or the `--karatsuba-len` option to `configure.sh` as follows: 588*5a6e8488SAndroid Build Coastguard Worker 589*5a6e8488SAndroid Build Coastguard Worker``` 590*5a6e8488SAndroid Build Coastguard Worker./configure.sh -k32 591*5a6e8488SAndroid Build Coastguard Worker./configure.sh --karatsuba-len 32 592*5a6e8488SAndroid Build Coastguard Worker``` 593*5a6e8488SAndroid Build Coastguard Worker 594*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 595*5a6e8488SAndroid Build Coastguard Worker 596*5a6e8488SAndroid Build Coastguard WorkerDefault is `32`. 597*5a6e8488SAndroid Build Coastguard Worker 598*5a6e8488SAndroid Build Coastguard Worker***WARNING***: The Karatsuba Length must be a **integer** greater than or equal 599*5a6e8488SAndroid Build Coastguard Workerto `16` (to prevent stack overflow). If it is not, `configure.sh` will give an 600*5a6e8488SAndroid Build Coastguard Workererror. 601*5a6e8488SAndroid Build Coastguard Worker 602*5a6e8488SAndroid Build Coastguard Worker#### Settings 603*5a6e8488SAndroid Build Coastguard Worker 604*5a6e8488SAndroid Build Coastguard WorkerThis `bc` and `dc` have a few settings to override default behavior. 605*5a6e8488SAndroid Build Coastguard Worker 606*5a6e8488SAndroid Build Coastguard WorkerThe defaults for these settings can be set by package maintainers, and the 607*5a6e8488SAndroid Build Coastguard Workersettings themselves can be overriden by users. 608*5a6e8488SAndroid Build Coastguard Worker 609*5a6e8488SAndroid Build Coastguard WorkerTo set a default to **on**, use the `-s` or `--set-default-on` option to 610*5a6e8488SAndroid Build Coastguard Worker`configure.sh`, with the name of the setting, as follows: 611*5a6e8488SAndroid Build Coastguard Worker 612*5a6e8488SAndroid Build Coastguard Worker``` 613*5a6e8488SAndroid Build Coastguard Worker./configure.sh -s bc.banner 614*5a6e8488SAndroid Build Coastguard Worker./configure.sh --set-default-on=bc.banner 615*5a6e8488SAndroid Build Coastguard Worker``` 616*5a6e8488SAndroid Build Coastguard Worker 617*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 618*5a6e8488SAndroid Build Coastguard Worker 619*5a6e8488SAndroid Build Coastguard WorkerTo set a default to **off**, use the `-S` or `--set-default-off` option to 620*5a6e8488SAndroid Build Coastguard Worker`configure.sh`, with the name of the setting, as follows: 621*5a6e8488SAndroid Build Coastguard Worker 622*5a6e8488SAndroid Build Coastguard Worker``` 623*5a6e8488SAndroid Build Coastguard Worker./configure.sh -S bc.banner 624*5a6e8488SAndroid Build Coastguard Worker./configure.sh --set-default-off=bc.banner 625*5a6e8488SAndroid Build Coastguard Worker``` 626*5a6e8488SAndroid Build Coastguard Worker 627*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 628*5a6e8488SAndroid Build Coastguard Worker 629*5a6e8488SAndroid Build Coastguard WorkerUsers can override the default settings set by packagers with environment 630*5a6e8488SAndroid Build Coastguard Workervariables. If the environment variable has an integer, then the setting is 631*5a6e8488SAndroid Build Coastguard Workerturned **on** for a non-zero integer, and **off** for zero. 632*5a6e8488SAndroid Build Coastguard Worker 633*5a6e8488SAndroid Build Coastguard WorkerThe table of the available settings, along with their defaults and the 634*5a6e8488SAndroid Build Coastguard Workerenvironment variables to override them, is below: 635*5a6e8488SAndroid Build Coastguard Worker 636*5a6e8488SAndroid Build Coastguard Worker``` 637*5a6e8488SAndroid Build Coastguard Worker| Setting | Description | Default | Env Variable | 638*5a6e8488SAndroid Build Coastguard Worker| =============== | ==================== | ============ | ==================== | 639*5a6e8488SAndroid Build Coastguard Worker| bc.banner | Whether to display | 0 | BC_BANNER | 640*5a6e8488SAndroid Build Coastguard Worker| | the bc version | | | 641*5a6e8488SAndroid Build Coastguard Worker| | banner when in | | | 642*5a6e8488SAndroid Build Coastguard Worker| | interactive mode. | | | 643*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 644*5a6e8488SAndroid Build Coastguard Worker| bc.sigint_reset | Whether SIGINT will | 1 | BC_SIGINT_RESET | 645*5a6e8488SAndroid Build Coastguard Worker| | reset bc, instead of | | | 646*5a6e8488SAndroid Build Coastguard Worker| | exiting, when in | | | 647*5a6e8488SAndroid Build Coastguard Worker| | interactive mode. | | | 648*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 649*5a6e8488SAndroid Build Coastguard Worker| dc.sigint_reset | Whether SIGINT will | 1 | DC_SIGINT_RESET | 650*5a6e8488SAndroid Build Coastguard Worker| | reset dc, instead of | | | 651*5a6e8488SAndroid Build Coastguard Worker| | exiting, when in | | | 652*5a6e8488SAndroid Build Coastguard Worker| | interactive mode. | | | 653*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 654*5a6e8488SAndroid Build Coastguard Worker| bc.tty_mode | Whether TTY mode for | 1 | BC_TTY_MODE | 655*5a6e8488SAndroid Build Coastguard Worker| | bc should be on when | | | 656*5a6e8488SAndroid Build Coastguard Worker| | available. | | | 657*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 658*5a6e8488SAndroid Build Coastguard Worker| dc.tty_mode | Whether TTY mode for | 0 | BC_TTY_MODE | 659*5a6e8488SAndroid Build Coastguard Worker| | dc should be on when | | | 660*5a6e8488SAndroid Build Coastguard Worker| | available. | | | 661*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 662*5a6e8488SAndroid Build Coastguard Worker| bc.prompt | Whether the prompt | $BC_TTY_MODE | BC_PROMPT | 663*5a6e8488SAndroid Build Coastguard Worker| | for bc should be on | | | 664*5a6e8488SAndroid Build Coastguard Worker| | in tty mode. | | | 665*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 666*5a6e8488SAndroid Build Coastguard Worker| dc.prompt | Whether the prompt | $DC_TTY_MODE | DC_PROMPT | 667*5a6e8488SAndroid Build Coastguard Worker| | for dc should be on | | | 668*5a6e8488SAndroid Build Coastguard Worker| | in tty mode. | | | 669*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 670*5a6e8488SAndroid Build Coastguard Worker| bc.expr_exit | Whether to exit bc | 1 | BC_EXPR_EXIT | 671*5a6e8488SAndroid Build Coastguard Worker| | if an expression or | | | 672*5a6e8488SAndroid Build Coastguard Worker| | expression file is | | | 673*5a6e8488SAndroid Build Coastguard Worker| | given with the -e or | | | 674*5a6e8488SAndroid Build Coastguard Worker| | -f options. | | | 675*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 676*5a6e8488SAndroid Build Coastguard Worker| dc.expr_exit | Whether to exit dc | 1 | DC_EXPR_EXIT | 677*5a6e8488SAndroid Build Coastguard Worker| | if an expression or | | | 678*5a6e8488SAndroid Build Coastguard Worker| | expression file is | | | 679*5a6e8488SAndroid Build Coastguard Worker| | given with the -e or | | | 680*5a6e8488SAndroid Build Coastguard Worker| | -f options. | | | 681*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 682*5a6e8488SAndroid Build Coastguard Worker| bc.digit_clamp | Whether to have bc | 0 | BC_DIGIT_CLAMP | 683*5a6e8488SAndroid Build Coastguard Worker| | clamp digits that | | | 684*5a6e8488SAndroid Build Coastguard Worker| | are greater than or | | | 685*5a6e8488SAndroid Build Coastguard Worker| | equal to the current | | | 686*5a6e8488SAndroid Build Coastguard Worker| | ibase when parsing | | | 687*5a6e8488SAndroid Build Coastguard Worker| | numbers. | | | 688*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 689*5a6e8488SAndroid Build Coastguard Worker| dc.digit_clamp | Whether to have dc | 0 | DC_DIGIT_CLAMP | 690*5a6e8488SAndroid Build Coastguard Worker| | clamp digits that | | | 691*5a6e8488SAndroid Build Coastguard Worker| | are greater than or | | | 692*5a6e8488SAndroid Build Coastguard Worker| | equal to the current | | | 693*5a6e8488SAndroid Build Coastguard Worker| | ibase when parsing | | | 694*5a6e8488SAndroid Build Coastguard Worker| | numbers. | | | 695*5a6e8488SAndroid Build Coastguard Worker| --------------- | -------------------- | ------------ | -------------------- | 696*5a6e8488SAndroid Build Coastguard Worker``` 697*5a6e8488SAndroid Build Coastguard Worker 698*5a6e8488SAndroid Build Coastguard WorkerThese settings are not meant to be changed on a whim. They are meant to ensure 699*5a6e8488SAndroid Build Coastguard Workerthat this bc and dc will conform to the expectations of the user on each 700*5a6e8488SAndroid Build Coastguard Workerplatform. 701*5a6e8488SAndroid Build Coastguard Worker 702*5a6e8488SAndroid Build Coastguard Worker#### Install Options 703*5a6e8488SAndroid Build Coastguard Worker 704*5a6e8488SAndroid Build Coastguard WorkerThe relevant `autotools`-style install options are supported in `configure.sh`: 705*5a6e8488SAndroid Build Coastguard Worker 706*5a6e8488SAndroid Build Coastguard Worker* `--prefix` 707*5a6e8488SAndroid Build Coastguard Worker* `--bindir` 708*5a6e8488SAndroid Build Coastguard Worker* `--datarootdir` 709*5a6e8488SAndroid Build Coastguard Worker* `--datadir` 710*5a6e8488SAndroid Build Coastguard Worker* `--mandir` 711*5a6e8488SAndroid Build Coastguard Worker* `--man1dir` 712*5a6e8488SAndroid Build Coastguard Worker* `--man3dir` 713*5a6e8488SAndroid Build Coastguard Worker 714*5a6e8488SAndroid Build Coastguard WorkerAn example is: 715*5a6e8488SAndroid Build Coastguard Worker 716*5a6e8488SAndroid Build Coastguard Worker``` 717*5a6e8488SAndroid Build Coastguard Worker./configure.sh --prefix=/usr 718*5a6e8488SAndroid Build Coastguard Workermake 719*5a6e8488SAndroid Build Coastguard Workermake install 720*5a6e8488SAndroid Build Coastguard Worker``` 721*5a6e8488SAndroid Build Coastguard Worker 722*5a6e8488SAndroid Build Coastguard WorkerThey correspond to the environment variables `$PREFIX`, `$BINDIR`, 723*5a6e8488SAndroid Build Coastguard Worker`$DATAROOTDIR`, `$DATADIR`, `$MANDIR`, `$MAN1DIR`, `$MAN3DIR`, and respectively. 724*5a6e8488SAndroid Build Coastguard Worker 725*5a6e8488SAndroid Build Coastguard Worker***WARNING***: Locales ignore the prefix because they *must* be installed at a 726*5a6e8488SAndroid Build Coastguard Workerfixed location to work at all. If you do not want that to happen, you must 727*5a6e8488SAndroid Build Coastguard Workerdisable locales (NLS) completely. 728*5a6e8488SAndroid Build Coastguard Worker 729*5a6e8488SAndroid Build Coastguard Worker***WARNING***: If the option is given, the value of the corresponding 730*5a6e8488SAndroid Build Coastguard Workerenvironment variable is overridden. 731*5a6e8488SAndroid Build Coastguard Worker 732*5a6e8488SAndroid Build Coastguard Worker***WARNING***: If any long command-line options are used, the long form of all 733*5a6e8488SAndroid Build Coastguard Workerother command-line options must be used. Mixing long and short options is not 734*5a6e8488SAndroid Build Coastguard Workersupported. 735*5a6e8488SAndroid Build Coastguard Worker 736*5a6e8488SAndroid Build Coastguard Worker##### Manpages 737*5a6e8488SAndroid Build Coastguard Worker 738*5a6e8488SAndroid Build Coastguard WorkerTo disable installing manpages, pass either the `-M` flag or the 739*5a6e8488SAndroid Build Coastguard Worker`--disable-man-pages` option to `configure.sh` as follows: 740*5a6e8488SAndroid Build Coastguard Worker 741*5a6e8488SAndroid Build Coastguard Worker``` 742*5a6e8488SAndroid Build Coastguard Worker./configure.sh -M 743*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-man-pages 744*5a6e8488SAndroid Build Coastguard Worker``` 745*5a6e8488SAndroid Build Coastguard Worker 746*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 747*5a6e8488SAndroid Build Coastguard Worker 748*5a6e8488SAndroid Build Coastguard Worker##### Locales 749*5a6e8488SAndroid Build Coastguard Worker 750*5a6e8488SAndroid Build Coastguard WorkerBy default, `bc` and `dc` do not install all locales, but only the enabled 751*5a6e8488SAndroid Build Coastguard Workerlocales. If `DESTDIR` exists and is not empty, then they will install all of 752*5a6e8488SAndroid Build Coastguard Workerthe locales that exist on the system. The `-l` flag or `--install-all-locales` 753*5a6e8488SAndroid Build Coastguard Workeroption skips all of that and just installs all of the locales that `bc` and `dc` 754*5a6e8488SAndroid Build Coastguard Workerhave, regardless. To enable that behavior, you can pass the `-l` flag or the 755*5a6e8488SAndroid Build Coastguard Worker`--install-all-locales` option to `configure.sh`, as follows: 756*5a6e8488SAndroid Build Coastguard Worker 757*5a6e8488SAndroid Build Coastguard Worker``` 758*5a6e8488SAndroid Build Coastguard Worker./configure.sh -l 759*5a6e8488SAndroid Build Coastguard Worker./configure.sh --install-all-locales 760*5a6e8488SAndroid Build Coastguard Worker``` 761*5a6e8488SAndroid Build Coastguard Worker 762*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 763*5a6e8488SAndroid Build Coastguard Worker 764*5a6e8488SAndroid Build Coastguard Worker***WARNING***: Locales ignore the prefix because they *must* be installed at a 765*5a6e8488SAndroid Build Coastguard Workerfixed location to work at all. If you do not want that to happen, you must 766*5a6e8488SAndroid Build Coastguard Workerdisable locales (NLS) completely. 767*5a6e8488SAndroid Build Coastguard Worker 768*5a6e8488SAndroid Build Coastguard Worker### Optimization 769*5a6e8488SAndroid Build Coastguard Worker 770*5a6e8488SAndroid Build Coastguard WorkerThe `configure.sh` script will accept an optimization level to pass to the 771*5a6e8488SAndroid Build Coastguard Workercompiler. Because `bc` is orders of magnitude faster with optimization, I 772*5a6e8488SAndroid Build Coastguard Worker***highly*** recommend package and distro maintainers pass the highest 773*5a6e8488SAndroid Build Coastguard Workeroptimization level available in `CC` to `configure.sh` with the `-O` flag or 774*5a6e8488SAndroid Build Coastguard Worker`--opt` option, as follows: 775*5a6e8488SAndroid Build Coastguard Worker 776*5a6e8488SAndroid Build Coastguard Worker``` 777*5a6e8488SAndroid Build Coastguard Worker./configure.sh -O3 778*5a6e8488SAndroid Build Coastguard Worker./configure.sh --opt 3 779*5a6e8488SAndroid Build Coastguard Worker``` 780*5a6e8488SAndroid Build Coastguard Worker 781*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 782*5a6e8488SAndroid Build Coastguard Worker 783*5a6e8488SAndroid Build Coastguard WorkerThe build and install can then be run as normal: 784*5a6e8488SAndroid Build Coastguard Worker 785*5a6e8488SAndroid Build Coastguard Worker``` 786*5a6e8488SAndroid Build Coastguard Workermake 787*5a6e8488SAndroid Build Coastguard Workermake install 788*5a6e8488SAndroid Build Coastguard Worker``` 789*5a6e8488SAndroid Build Coastguard Worker 790*5a6e8488SAndroid Build Coastguard WorkerAs usual, `configure.sh` will also accept additional `CFLAGS` on the command 791*5a6e8488SAndroid Build Coastguard Workerline, so for SSE4 architectures, the following can add a bit more speed: 792*5a6e8488SAndroid Build Coastguard Worker 793*5a6e8488SAndroid Build Coastguard Worker``` 794*5a6e8488SAndroid Build Coastguard WorkerCFLAGS="-march=native -msse4" ./configure.sh -O3 795*5a6e8488SAndroid Build Coastguard Workermake 796*5a6e8488SAndroid Build Coastguard Workermake install 797*5a6e8488SAndroid Build Coastguard Worker``` 798*5a6e8488SAndroid Build Coastguard Worker 799*5a6e8488SAndroid Build Coastguard WorkerBuilding with link-time optimization (`-flto` in clang) can further increase the 800*5a6e8488SAndroid Build Coastguard Workerperformance. I ***highly*** recommend doing so. 801*5a6e8488SAndroid Build Coastguard Worker 802*5a6e8488SAndroid Build Coastguard WorkerI do ***NOT*** recommend building with `-march=native`; doing so reduces this 803*5a6e8488SAndroid Build Coastguard Worker`bc`'s performance. 804*5a6e8488SAndroid Build Coastguard Worker 805*5a6e8488SAndroid Build Coastguard WorkerManual stripping is not necessary; non-debug builds are automatically stripped 806*5a6e8488SAndroid Build Coastguard Workerin the link stage. 807*5a6e8488SAndroid Build Coastguard Worker 808*5a6e8488SAndroid Build Coastguard Worker### Debug Builds 809*5a6e8488SAndroid Build Coastguard Worker 810*5a6e8488SAndroid Build Coastguard WorkerDebug builds (which also disable optimization if no optimization level is given 811*5a6e8488SAndroid Build Coastguard Workerand if no extra `CFLAGS` are given) can be enabled with either the `-g` flag or 812*5a6e8488SAndroid Build Coastguard Workerthe `--debug` option, as follows: 813*5a6e8488SAndroid Build Coastguard Worker 814*5a6e8488SAndroid Build Coastguard Worker``` 815*5a6e8488SAndroid Build Coastguard Worker./configure.sh -g 816*5a6e8488SAndroid Build Coastguard Worker./configure.sh --debug 817*5a6e8488SAndroid Build Coastguard Worker``` 818*5a6e8488SAndroid Build Coastguard Worker 819*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 820*5a6e8488SAndroid Build Coastguard Worker 821*5a6e8488SAndroid Build Coastguard WorkerThe build and install can then be run as normal: 822*5a6e8488SAndroid Build Coastguard Worker 823*5a6e8488SAndroid Build Coastguard Worker``` 824*5a6e8488SAndroid Build Coastguard Workermake 825*5a6e8488SAndroid Build Coastguard Workermake install 826*5a6e8488SAndroid Build Coastguard Worker``` 827*5a6e8488SAndroid Build Coastguard Worker 828*5a6e8488SAndroid Build Coastguard Worker### Stripping Binaries 829*5a6e8488SAndroid Build Coastguard Worker 830*5a6e8488SAndroid Build Coastguard WorkerBy default, when `bc` and `dc` are not built in debug mode, the binaries are 831*5a6e8488SAndroid Build Coastguard Workerstripped. Stripping can be disabled with either the `-T` or the 832*5a6e8488SAndroid Build Coastguard Worker`--disable-strip` option, as follows: 833*5a6e8488SAndroid Build Coastguard Worker 834*5a6e8488SAndroid Build Coastguard Worker``` 835*5a6e8488SAndroid Build Coastguard Worker./configure.sh -T 836*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-strip 837*5a6e8488SAndroid Build Coastguard Worker``` 838*5a6e8488SAndroid Build Coastguard Worker 839*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 840*5a6e8488SAndroid Build Coastguard Worker 841*5a6e8488SAndroid Build Coastguard WorkerThe build and install can then be run as normal: 842*5a6e8488SAndroid Build Coastguard Worker 843*5a6e8488SAndroid Build Coastguard Worker``` 844*5a6e8488SAndroid Build Coastguard Workermake 845*5a6e8488SAndroid Build Coastguard Workermake install 846*5a6e8488SAndroid Build Coastguard Worker``` 847*5a6e8488SAndroid Build Coastguard Worker 848*5a6e8488SAndroid Build Coastguard Worker### Build Type 849*5a6e8488SAndroid Build Coastguard Worker 850*5a6e8488SAndroid Build Coastguard Worker`bc` and `dc` have 8 build types, affected by the [History][8], [NLS (Locale 851*5a6e8488SAndroid Build Coastguard WorkerSupport)][9], and [Extra Math][10] build options. 852*5a6e8488SAndroid Build Coastguard Worker 853*5a6e8488SAndroid Build Coastguard WorkerThe build types are as follows: 854*5a6e8488SAndroid Build Coastguard Worker 855*5a6e8488SAndroid Build Coastguard Worker* `A`: Nothing disabled. 856*5a6e8488SAndroid Build Coastguard Worker* `E`: Extra math disabled. 857*5a6e8488SAndroid Build Coastguard Worker* `H`: History disabled. 858*5a6e8488SAndroid Build Coastguard Worker* `N`: NLS disabled. 859*5a6e8488SAndroid Build Coastguard Worker* `EH`: Extra math and History disabled. 860*5a6e8488SAndroid Build Coastguard Worker* `EN`: Extra math and NLS disabled. 861*5a6e8488SAndroid Build Coastguard Worker* `HN`: History and NLS disabled. 862*5a6e8488SAndroid Build Coastguard Worker* `EHN`: Extra math, History, and NLS all disabled. 863*5a6e8488SAndroid Build Coastguard Worker 864*5a6e8488SAndroid Build Coastguard WorkerThese build types correspond to the generated manuals in `manuals/bc` and 865*5a6e8488SAndroid Build Coastguard Worker`manuals/dc`. 866*5a6e8488SAndroid Build Coastguard Worker 867*5a6e8488SAndroid Build Coastguard Worker### Binary Size 868*5a6e8488SAndroid Build Coastguard Worker 869*5a6e8488SAndroid Build Coastguard WorkerWhen built with both calculators, all available features, and `-Os` using 870*5a6e8488SAndroid Build Coastguard Worker`clang` and `musl`, the executable is 140.4 kb (140,386 bytes) on `x86_64`. That 871*5a6e8488SAndroid Build Coastguard Workerisn't much for what is contained in the binary, but if necessary, it can be 872*5a6e8488SAndroid Build Coastguard Workerreduced. 873*5a6e8488SAndroid Build Coastguard Worker 874*5a6e8488SAndroid Build Coastguard WorkerThe single largest user of space is the `bc` calculator. If just `dc` is needed, 875*5a6e8488SAndroid Build Coastguard Workerthe size can be reduced to 107.6 kb (107,584 bytes). 876*5a6e8488SAndroid Build Coastguard Worker 877*5a6e8488SAndroid Build Coastguard WorkerThe next largest user of space is history support. If that is not needed, size 878*5a6e8488SAndroid Build Coastguard Workercan be reduced (for a build with both calculators) to 119.9 kb (119,866 bytes). 879*5a6e8488SAndroid Build Coastguard Worker 880*5a6e8488SAndroid Build Coastguard WorkerThere are several reasons that history is a bigger user of space than `dc` 881*5a6e8488SAndroid Build Coastguard Workeritself: 882*5a6e8488SAndroid Build Coastguard Worker 883*5a6e8488SAndroid Build Coastguard Worker* `dc`'s lexer and parser are *tiny* compared to `bc`'s because `dc` code is 884*5a6e8488SAndroid Build Coastguard Worker almost already in the form that it is executed in, while `bc` has to not only 885*5a6e8488SAndroid Build Coastguard Worker adjust the form to be executable, it has to parse functions, loops, `if` 886*5a6e8488SAndroid Build Coastguard Worker statements, and other extra features. 887*5a6e8488SAndroid Build Coastguard Worker* `dc` does not have much extra code in the interpreter. 888*5a6e8488SAndroid Build Coastguard Worker* History has a lot of const data for supporting `UTF-8` terminals. 889*5a6e8488SAndroid Build Coastguard Worker* History pulls in a bunch of more code from the `libc`. 890*5a6e8488SAndroid Build Coastguard Worker 891*5a6e8488SAndroid Build Coastguard WorkerThe next biggest user is extra math support. Without it, the size is reduced to 892*5a6e8488SAndroid Build Coastguard Worker124.0 kb (123,986 bytes) with history and 107.6 kb (107,560 bytes) without 893*5a6e8488SAndroid Build Coastguard Workerhistory. 894*5a6e8488SAndroid Build Coastguard Worker 895*5a6e8488SAndroid Build Coastguard WorkerThe reasons why extra math support is bigger than `dc`, besides the fact that 896*5a6e8488SAndroid Build Coastguard Worker`dc` is small already, are: 897*5a6e8488SAndroid Build Coastguard Worker 898*5a6e8488SAndroid Build Coastguard Worker* Extra math supports adds an extra math library that takes several kilobytes of 899*5a6e8488SAndroid Build Coastguard Worker constant data space. 900*5a6e8488SAndroid Build Coastguard Worker* Extra math support includes support for a pseudo-random number generator, 901*5a6e8488SAndroid Build Coastguard Worker including the code to convert a series of pseudo-random numbers into a number 902*5a6e8488SAndroid Build Coastguard Worker of arbitrary size. 903*5a6e8488SAndroid Build Coastguard Worker* Extra math support adds several operators. 904*5a6e8488SAndroid Build Coastguard Worker 905*5a6e8488SAndroid Build Coastguard WorkerThe next biggest user is `dc`, so if just `bc` is needed, the size can be 906*5a6e8488SAndroid Build Coastguard Workerreduced to 128.1 kb (128,096 bytes) with history and extra math support, 107.6 907*5a6e8488SAndroid Build Coastguard Workerkb (107,576 bytes) without history and with extra math support, and 95.3 kb 908*5a6e8488SAndroid Build Coastguard Worker(95,272 bytes) without history and without extra math support. 909*5a6e8488SAndroid Build Coastguard Worker 910*5a6e8488SAndroid Build Coastguard Worker*Note*: all of these binary sizes were compiled using `musl` `1.2.0` as the 911*5a6e8488SAndroid Build Coastguard Worker`libc`, making a fully static executable, with `clang` `9.0.1` (well, 912*5a6e8488SAndroid Build Coastguard Worker`musl-clang` using `clang` `9.0.1`) as the compiler and using `-Os` 913*5a6e8488SAndroid Build Coastguard Workeroptimizations. These builds were done on an `x86_64` machine running Gentoo 914*5a6e8488SAndroid Build Coastguard WorkerLinux. 915*5a6e8488SAndroid Build Coastguard Worker 916*5a6e8488SAndroid Build Coastguard Worker### Testing 917*5a6e8488SAndroid Build Coastguard Worker 918*5a6e8488SAndroid Build Coastguard WorkerThe default test suite can be run with the following command: 919*5a6e8488SAndroid Build Coastguard Worker 920*5a6e8488SAndroid Build Coastguard Worker``` 921*5a6e8488SAndroid Build Coastguard Workermake test 922*5a6e8488SAndroid Build Coastguard Worker``` 923*5a6e8488SAndroid Build Coastguard Worker 924*5a6e8488SAndroid Build Coastguard WorkerTo test `bc` only, run the following command: 925*5a6e8488SAndroid Build Coastguard Worker 926*5a6e8488SAndroid Build Coastguard Worker``` 927*5a6e8488SAndroid Build Coastguard Workermake test_bc 928*5a6e8488SAndroid Build Coastguard Worker``` 929*5a6e8488SAndroid Build Coastguard Worker 930*5a6e8488SAndroid Build Coastguard WorkerTo test `dc` only, run the following command: 931*5a6e8488SAndroid Build Coastguard Worker 932*5a6e8488SAndroid Build Coastguard Worker``` 933*5a6e8488SAndroid Build Coastguard Workermake test_dc 934*5a6e8488SAndroid Build Coastguard Worker``` 935*5a6e8488SAndroid Build Coastguard Worker 936*5a6e8488SAndroid Build Coastguard WorkerThis `bc`, if built, assumes a working, GNU-compatible `bc`, installed on the 937*5a6e8488SAndroid Build Coastguard Workersystem and in the `PATH`, to generate some tests, unless the `-G` flag or 938*5a6e8488SAndroid Build Coastguard Worker`--disable-generated-tests` option is given to `configure.sh`, as follows: 939*5a6e8488SAndroid Build Coastguard Worker 940*5a6e8488SAndroid Build Coastguard Worker``` 941*5a6e8488SAndroid Build Coastguard Worker./configure.sh -G 942*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-generated-tests 943*5a6e8488SAndroid Build Coastguard Worker``` 944*5a6e8488SAndroid Build Coastguard Worker 945*5a6e8488SAndroid Build Coastguard WorkerAfter running `configure.sh`, build and run tests as follows: 946*5a6e8488SAndroid Build Coastguard Worker 947*5a6e8488SAndroid Build Coastguard Worker``` 948*5a6e8488SAndroid Build Coastguard Workermake 949*5a6e8488SAndroid Build Coastguard Workermake test 950*5a6e8488SAndroid Build Coastguard Worker``` 951*5a6e8488SAndroid Build Coastguard Worker 952*5a6e8488SAndroid Build Coastguard WorkerThis `dc` also assumes a working, GNU-compatible `dc`, installed on the system 953*5a6e8488SAndroid Build Coastguard Workerand in the `PATH`, to generate some tests, unless one of the above options is 954*5a6e8488SAndroid Build Coastguard Workergiven to `configure.sh`. 955*5a6e8488SAndroid Build Coastguard Worker 956*5a6e8488SAndroid Build Coastguard WorkerTo generate test coverage, pass the `-c` flag or the `--coverage` option to 957*5a6e8488SAndroid Build Coastguard Worker`configure.sh` as follows: 958*5a6e8488SAndroid Build Coastguard Worker 959*5a6e8488SAndroid Build Coastguard Worker``` 960*5a6e8488SAndroid Build Coastguard Worker./configure.sh -c 961*5a6e8488SAndroid Build Coastguard Worker./configure.sh --coverage 962*5a6e8488SAndroid Build Coastguard Worker``` 963*5a6e8488SAndroid Build Coastguard Worker 964*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 965*5a6e8488SAndroid Build Coastguard Worker 966*5a6e8488SAndroid Build Coastguard Worker***WARNING***: Both `bc` and `dc` must be built for test coverage. Otherwise, 967*5a6e8488SAndroid Build Coastguard Worker`configure.sh` will give an error. 968*5a6e8488SAndroid Build Coastguard Worker 969*5a6e8488SAndroid Build Coastguard Worker#### Problematic Tests 970*5a6e8488SAndroid Build Coastguard Worker 971*5a6e8488SAndroid Build Coastguard WorkerSome tests are problematic, in that they can cause `SIGKILL` on FreeBSD or 972*5a6e8488SAndroid Build Coastguard Worker`SIGSEGV` on Linux from being killed by the "OOM Killer" part of the kernel. On 973*5a6e8488SAndroid Build Coastguard WorkerLinux, these tests are usually fine, but on FreeBSD, they are usually a problem. 974*5a6e8488SAndroid Build Coastguard Worker 975*5a6e8488SAndroid Build Coastguard WorkerTo disable problematic tests, pass the `-P` flag or the 976*5a6e8488SAndroid Build Coastguard Worker`--disable-problematic-tests` option to `configure.sh` as follows: 977*5a6e8488SAndroid Build Coastguard Worker 978*5a6e8488SAndroid Build Coastguard Worker``` 979*5a6e8488SAndroid Build Coastguard Worker./configure.sh -P 980*5a6e8488SAndroid Build Coastguard Worker./configure.sh --disable-problematic-tests 981*5a6e8488SAndroid Build Coastguard Worker``` 982*5a6e8488SAndroid Build Coastguard Worker 983*5a6e8488SAndroid Build Coastguard WorkerBoth commands are equivalent. 984*5a6e8488SAndroid Build Coastguard Worker 985*5a6e8488SAndroid Build Coastguard Worker[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html 986*5a6e8488SAndroid Build Coastguard Worker[2]: https://www.gnu.org/software/bc/ 987*5a6e8488SAndroid Build Coastguard Worker[3]: https://www.musl-libc.org/ 988*5a6e8488SAndroid Build Coastguard Worker[4]: #build-environment-variables 989*5a6e8488SAndroid Build Coastguard Worker[5]: #build-options 990*5a6e8488SAndroid Build Coastguard Worker[6]: #cross-compiling 991*5a6e8488SAndroid Build Coastguard Worker[7]: #build-type 992*5a6e8488SAndroid Build Coastguard Worker[8]: #history 993*5a6e8488SAndroid Build Coastguard Worker[9]: #nls-locale-support 994*5a6e8488SAndroid Build Coastguard Worker[10]: #extra-math 995*5a6e8488SAndroid Build Coastguard Worker[11]: #settings 996