Hi,
I recently ported Newlib to my OS and I'm currently writing a BSD-like socket API. I have implemented some syscalls (socket, connect, bind, ...) in a source file and created some headers (netinet/in.h, arpa/inet.h, sys/socket.h).
Let's refer to the tutorial OS Specific Toolchain on the Wiki and use its notations. My system-specific header files are in newlib/libc/sys/myos/include/ (these files will eventually go into $PREFIX/i586-pc-myos/include/) and newlib/libc/sys/myos/sys/ (these ones will go into $PREFIX/i586-pc-myos/include/sys/). A problem occurs with netinet/in.h and arpa/inet.h. If I put these files respectively in newlib/libc/sys/myos/include/netinet/ and newlib/libc/sys/myos/include/arpa/, they are not copied on install.
I've remarked that if I previously create the directories netinet and arpa in $PREFIX/i586-pc-myos/include, the files netinet/in.h and arpa/inet.h are copied.
Consequently, I guess that netinet and arpa subdirectories should be created before doing make install (to install Newlib). The question is: shall I do it by hand or does Newlib allow me to do it automatically at make install if I modify some config file?
Thanks in advance for your help.
[Newlib] Include subdirectories in Newlib
Re: [Newlib] Include subdirectories in Newlib
Hi,
I'm not familiar with newlib. I bet you need to modify some configuration file and possibly reconfigure the package with autoconf. If you track down exactly what happens during make install and how that make target got created by ./configure, it'll lead you to the answer. Keep in mind you'll need to look at lots of autotools magic, but that's a skill you need to learn at some point anyway.
Note that your use of some terminology seems confused, I'll clear them up for you:
System root - This is the directory that is the root directory of your target system. Your cross-compiler searches this for includes and libraries because you specified it when passing --with-sysroot.
DESTDIR - This is an additional prefix used when installing packages. If you gave --prefix=/foo/bar to a package, then if you do make DESTDIR=/baz/qux install and the package normally installs $PREFIX/include/spam.h then it installs $DESTDIR$PREFIX/include/spam.h, that is, /bar/qux/foo/bar/include/spam.h. You give this environmental variable when running make install. This is very useful for package management where you want to install the package somewhere else (so you can easily archive it up) rather than directly installing it into the desired prefix.
PREFIX (when cross-compiling to your OS) - This is the prefix of where the software will be run. This is not where the software will be installed. For instance, if you set --prefix=/home/karuon/myos-sysroot/usr then any programs you cross-compile thinks they run from /home/karuon/myos-sysroot/usr/bin rather than /usr/bin. This causes trouble on your OS because you might not have a /home/karuon directory, but also that the executable files are in /usr/bin. You might argue that programs shouldn't remember their prefix, but it's actually a feature, and a lot of software does this. This means that you should give the --prefix of where your cross-compiled software should be installed on your OS and then set DESTDIR to $MYOS_SYSROOT.
PREFIX (when building your cross-compiler) - This location is completely unrelated to the PREFIX when cross-compiling to your OS and it is also completely unrelated to your sysroot. For instance your cross-compiler might have been installed to /usr/local/cross but your system root is /home/karuon/myos-sysroot.
I'm not familiar with newlib. I bet you need to modify some configuration file and possibly reconfigure the package with autoconf. If you track down exactly what happens during make install and how that make target got created by ./configure, it'll lead you to the answer. Keep in mind you'll need to look at lots of autotools magic, but that's a skill you need to learn at some point anyway.
Note that your use of some terminology seems confused, I'll clear them up for you:
System root - This is the directory that is the root directory of your target system. Your cross-compiler searches this for includes and libraries because you specified it when passing --with-sysroot.
DESTDIR - This is an additional prefix used when installing packages. If you gave --prefix=/foo/bar to a package, then if you do make DESTDIR=/baz/qux install and the package normally installs $PREFIX/include/spam.h then it installs $DESTDIR$PREFIX/include/spam.h, that is, /bar/qux/foo/bar/include/spam.h. You give this environmental variable when running make install. This is very useful for package management where you want to install the package somewhere else (so you can easily archive it up) rather than directly installing it into the desired prefix.
PREFIX (when cross-compiling to your OS) - This is the prefix of where the software will be run. This is not where the software will be installed. For instance, if you set --prefix=/home/karuon/myos-sysroot/usr then any programs you cross-compile thinks they run from /home/karuon/myos-sysroot/usr/bin rather than /usr/bin. This causes trouble on your OS because you might not have a /home/karuon directory, but also that the executable files are in /usr/bin. You might argue that programs shouldn't remember their prefix, but it's actually a feature, and a lot of software does this. This means that you should give the --prefix of where your cross-compiled software should be installed on your OS and then set DESTDIR to $MYOS_SYSROOT.
PREFIX (when building your cross-compiler) - This location is completely unrelated to the PREFIX when cross-compiling to your OS and it is also completely unrelated to your sysroot. For instance your cross-compiler might have been installed to /usr/local/cross but your system root is /home/karuon/myos-sysroot.
Re: [Newlib] Include subdirectories in Newlib
Ok, so I guess I'll have to read a tutorial about autoconf.
Thanks for the definitions. I knew what DESTDIR and PREFIX (when building a cross-compiler) mean but I didn't know about PREFIX (when cross-compiling to my OS) ; it may be useful in the future.
Thanks for the definitions. I knew what DESTDIR and PREFIX (when building a cross-compiler) mean but I didn't know about PREFIX (when cross-compiling to my OS) ; it may be useful in the future.