- Install autoconf (I used 2.69, newest on Ubuntu Focal)
- Install
automake1.11
(this is not the default anymore, but newer versions are broken for newlib, you'll get automake errors)
- Added
nautilus*
entry toconfig.sub
in top-level dir - Modified
newlib/configure.host
as per docs to add anautilus
target and create a newsys_dir
path. Note that I had to add-D_FORTIFY_SOURCE=0
to thenewlib_cflags
var here since-O2
will automatically set this to 2 on newer versions of gcc, thus breaking the newlib build. - Modified
newlib/libc/sys/configure.in
as per the docs to add a subdir entry, then ranautoconf
- Created
newlib/libc/sys/nautilus
dir - Added stub implementations for syscalls (
*.c
) in that dir based onsys/rdos
andsys/linux
which will link against Nautilussys_*
syscall (not really syscall) stubs. - Created a
configure.in
andMakefile.am
insys/nautilus
based on linux/rdos entries. - Ran
aclocal
,autoconf
, andautomake
as per docs. Encountered issues here because of newer automake version. Worked after forced downgrade to automake 1.11. - Set up a fake cross-compiler toolchain with symlinks to please newlib build toolchain (see below).
- Configured and built newlib as below, then copied over the install files to Nautilus to link directly.
First I set up a dummy cross toolchain for binutils on the first run:
$ for i in ar as cc g++ gcc ld nm objcopy objdump ranlib readelf strip; do ln -s /usr/bin/$i /usr/bin/x86_64--nautilus-$i; done;
If you've already got a cross-compiler built, just make sure the binaries (in my case in /opt/nautilus/cross/bin/
)
are on your PATH
.
Then you can configure, from the top-level newlib dir:
$ mkdir bld-nautilus
$ cd bld-nautilus
$ ../configure --target=x86_64-nautilus --with-newlib --disable-multilib --prefix=/usr
$ make all-target-newlib -j
$ make -j
$ make DESTDIR=$SYSROOT install
Where SYSROOT
for me is /opt/nautilus/sysroot
. This was also passed to the gcc/binutils build.
newlib does not install in quite the right place. You have to move things over to sysroot/usr/{include,lib}
rather than sysroot/usr/TARGET/{include,lib}
.
See naut-scripts/fixup.sh
Note that Nautilus must point directly to these libraries and the cross-compiler toolchain binaries.
These StackOverflow questions were helpful in finding out what was going on with automake
- Official newlib documentation for adding a new target
- SO post 1
- SO post 2