Skip to content

Commit

Permalink
Merge branch 'jpellegrini-cross-compile'
Browse files Browse the repository at this point in the history
  • Loading branch information
egallesio committed Oct 14, 2024
2 parents 52db864 + d7aaacc commit 65f33eb
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 9 deletions.
36 changes: 36 additions & 0 deletions INSTALL-cross-compile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Cross-compiling STklos

## How to cross-compile

Cross-compilation is just like compilation

```
./configure prefix=some-tmp-dir CC=some-C-compiler CFLAGS=your-c-flags ...
make
make install
```

The relevant environment variables are described in the output
of `configure --help`.

***However:***

* You *need* a STklos binary in order to compile STklos. When not
cross-compiling,
- the binary is generated as `src/stklos`
- the build proceeds using `src/stklos` as the STklos binary that
can be used to compile `.stk` files
However, when cross-compiling `src/stklos` will be a binary for a
different (target) architecture, and the build will fail, unless we
have a native STklos in the system that can be used instead.

* Put the full path of the STklos binary in the `STKLOS_BINARY`
variable when calling `make`:

```
./configure --prefix=/usr/some/place
make `STKLOS_BINARY=/usr/local/bin/stklos`
make install
```

Now you can copy the `usr/some/place` directory to the target machine.
7 changes: 5 additions & 2 deletions lib/scheme/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ SUFFIXES = .stk .ostk .stk -incl.c .$(SO) .c

stream.ostk: ../streams/primitive.ostk ../streams/derived.ostk

../streams/derived.ostk ../streams/primitive.ostk:
(cd ../streams && $(MAKE) $@)
../streams/derived.ostk:
(cd ../streams && $(MAKE) derived.ostk)

../streams/primitive.ostk:
(cd ../streams && $(MAKE) primitive.ostk)

set.ostk: ../srfi/69.ostk comparator.ostk

Expand Down
7 changes: 5 additions & 2 deletions lib/scheme/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,11 @@ STKLOS_BINARY ?= ../../src/stklos

stream.ostk: ../streams/primitive.ostk ../streams/derived.ostk

../streams/derived.ostk ../streams/primitive.ostk:
(cd ../streams && $(MAKE) $@)
../streams/derived.ostk:
(cd ../streams && $(MAKE) derived.ostk)

../streams/primitive.ostk:
(cd ../streams && $(MAKE) primitive.ostk)

set.ostk: ../srfi/69.ostk comparator.ostk

Expand Down
4 changes: 3 additions & 1 deletion utils/tmpcomp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ case $# in
esac

prefix="$(cd -- "$(dirname "$0")/.." >/dev/null 2>&1 && pwd)"
[ "x$STKLOS_BINARY" != "x" ] || STKLOS_BINARY=${prefix}/src/stklos

STKLOS_LOAD_PATH=".:../lib:${prefix}/lib:"
STKLOS_BUILDING=1
export STKLOS_LOAD_PATH STKLOS_BUILDING

${prefix}/src/stklos -c -q -f ${prefix}/utils/stklos-compile.stk -- \

${STKLOS_BINARY} -c -q -f ${prefix}/utils/stklos-compile.stk -- \
--no-time $Copt --output=$out $in

status=$?
Expand Down
9 changes: 5 additions & 4 deletions utils/tmpgenlex
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
# Creation date: 1-Jan-2002 18:57 (eg)
#

prefix="$(cd -- "$(dirname "$0")/.." >/dev/null 2>&1 && pwd)"
[ "x$STKLOS_BINARY" != "x" ] || STKLOS_BINARY=${prefix}/src/stklos

STKLOS_LOAD_PATH="../lib"
export STKLOS_LOAD_PATH

../src/stklos -c -q -b ../src/boot.img -f ../utils/stklos-genlex -- $*
STKLOS_LOAD_PATH=".:../lib:${prefix}/lib:"
export STKLOS_LOAD_PATH


${STKLOS_BINARY} -c -q -b ../src/boot.img -f ../utils/stklos-genlex -- $*

0 comments on commit 65f33eb

Please sign in to comment.