Setting up the 8086 toolchain (C86 compiler and tools) - ghaerr/elks GitHub Wiki
This topic covers getting the 8086 toolchain compiled on the host, and using it to cross-compile applications for ELKS.
Compiling the toolchain, then cross-compiling an example, require some setup, as there are three compilers involved:
- ia16-elf-gcc (GCC): used to compile ELKS and some ELKS applications. Setup with
. env.sh
in ELKS root. - Open Watcom (OWC): used to compile most of the 8086 toolchain. Setup with
. wcenv.sh
in ELKS libc. - 8086 Toolchain (C86): used to both cross-compile and natively compile ELKS apps. Setup with
. c86env.sh
in ELKS libc.
First, the location of the OWC installation directory (WATCOM=) must be set by editing libc/wcenv.sh. Second, the location of the C86 repo (C86=) must be set by editing libc/c86.sh. Then the following steps are used to build each piece in order:
$ cd ELKS
$ . env.sh # setup TOPDIR= needed for using GCC
$ cd libc
$ . wcenv.sh # setup WATCOM= need for using OWC
$ . c86env.sh # setup C86= needed for using C86 (when built)
(TOPDIR=, WATCOM= and C86= now set)
$ cd ELKS
$ make # normal ELKS full build
$ cd 8086-toolchain
$ make host # make host version of C86 using host OWC and GCC
(host c86 cross compiler toolchain now in 8086-toolchain/host-bin)
$ cd ELKS
$ make owc # make native OWC library libc/libc.a using OWC
$ cd 8086-toolchain
$ make elks # make ELKS version of C86 using host OWC and native OWC libc
(native c86 compiler toolchain now in 8086-toolchain/elks-bin)
$ cd ELKS
$ make c86 # make native C86 library libc/libc86.a using host C86
$ cd 8086-toolchain/examples
$ make # make ELKS example apps using host C86 and native C86 libc
(native chess and test examples are now in 8086-toolchain/examples)
After all this, in the 8086-toolchain directory, you will have the host C86 toolchain executables in 8086-toolchain/host-bin, and the ELKS native C86 toolchain executables in 8086-toolchain/elks-bin. The native C library is in ELKS/libc/libc86.a.
After the three environment variables are setup and all repos have been made at least once, the update cycle is quite a bit simpler, since one doesn't need to bootstrap the process as above.
When either repo is updated and the three environment variables set, only the following needs to be done:
$ cd ELKS
$ git pull ...
$ make
$ make owc c86 # builds OWC and C86 libraries
$ cd 8086-toolchain
$ git pull ...
$ make clean
$ make # builds both host and elks C86
$ cd examples; make # builds examples