Skip to content

Commit

Permalink
package: involve $CCFLAGS when determing 64-bit arch (re: 9a48ba1)
Browse files Browse the repository at this point in the history
bin/package, src/cmd/INIT/package.sh:
- It can depend on the compiler flags passed whether the compiler
  produces code for a 64-bit architecture, so pass $CCFLAGS to
  the compiler when testing whether it creates 64-bit object code.

README.md:
- Copy-edit of build instructions.
  • Loading branch information
McDutchie committed Jan 18, 2021
1 parent 580ff61 commit 4cfe49a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,27 @@ improved release out there.

## Build

After cloning this repo, cd to the top directory of it and run:
After downloading a release or cloning the ksh git repository, cd to the top
directory of it and run:
```sh
bin/package make
```
If you have trouble or want to tune the binaries, you may pass additional
compiler and linker flags by appending it to the command shown above. E.g.:
compiler and linker flags. It is usually best to export these as environment
variables *before* running `bin/package` as they could change the name of
the build subdirectory of the `arch` directory, so exporting them is a
convenient way to keep them consistent between build and test commands.
**Note that this system uses `CCFLAGS` instead of the usual `CFLAGS`.**
An example that makes Solaris Studio cc produce a 64-bit binary:
```sh
bin/package make \
SHELL=/bin/bash CCFLAGS="-xc99 -D_XPG6 -m64 -xO4" LDFLAGS="-m64"
export CCFLAGS="-xc99 -m64 -O2" LDFLAGS="-m64"
bin/package make
```
Alternatively you can append these to the command, and they will only be
used for that command. You can also specify an alternative shell in which
to run the build scripts this way. For example:
```sh
bin/package make SHELL=/bin/bash CCFLAGS="-O2 -I/opt/local/include" LDFLAGS="-L/opt/local/lib"
```
For more information run
```sh
Expand Down
2 changes: 1 addition & 1 deletion bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,7 @@ int b() { return 0; }
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
echo 'int main() { return 0; }' > $tmp.a.c
$cc -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
$cc $CCFLAGS -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" `
case $bits in
*64*) bits=64 ;;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/INIT/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ int b() { return 0; }
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
echo 'int main() { return 0; }' > $tmp.a.c
$cc -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
$cc $CCFLAGS -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" `
case $bits in
*64*) bits=64 ;;
Expand Down

0 comments on commit 4cfe49a

Please sign in to comment.