1.\" $NetBSD: compat_freebsd.8,v 1.3 1997/11/13 03:39:34 thorpej Exp $ 2.\" from: compat_linux.8,v 1.1 1995/03/05 23:30:36 fvdl Exp 3.\" 4.\" Copyright (c) 1995 Frank van der Linden 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed for the NetBSD Project 18.\" by Frank van der Linden 19.\" 4. The name of the author may not be used to endorse or promote products 20.\" derived from this software without specific prior written permission 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32.\" 33.Dd June 4, 1995 34.Dt COMPAT_FREEBSD 8 35.Os NetBSD 36.Sh NAME 37.Nm compat_freebsd 38.Nd setup procedure for running FreeBSD binaries 39.Sh DESCRIPTION 40NetBSD supports running FreeBSD binaries. Most binaries should work, 41except programs that use FreeBSD-specific features. These include 42i386-specific calls, such as syscons utilities, and audio devices. 43The FreeBSD compatibility feature is active for kernels compiled 44with the 45.Dv COMPAT_FREEBSD 46option enabled. 47.Pp 48A lot of programs are dynamically linked. This means, that you will 49also need the FreeBSD shared libraries that the program depends on, and 50the runtime linker. Also, you will need to create a "shadow root" 51directory for FreeBSD binaries on your NetBSD system. This directory 52is named /emul/freebsd. Any file operations done by FreeBSD programs 53run under NetBSD will look in this directory first. So, if a FreeBSD 54program opens, for example, /etc/passwd, NetBSD will 55first try to open /emul/freebsd/etc/passwd, and if that does not exist 56open the 'real' /etc/passwd file. It is recommended that you install 57FreeBSD packages that include configuration files, etc under /emul/freebsd, 58to avoid naming conflicts with possible NetBSD counterparts. Shared 59libraries should also be installed in the shadow tree. 60.Pp 61Generally, you will need to look for the shared libraries that FreeBSD 62binaries depend on only the first few times that you install a FreeBSD 63program on your NetBSD system. After a while, you will have a sufficient 64set of FreeBSD shared libraries on your system to be able to run newly 65imported FreeBSD binaries without any extra work. 66 67.Ss Setting up shared libraries 68How to get to know which shared libraries FreeBSD binaries need, and where 69to get them? Basically, there are 2 possibilities (when following 70these instructions: you will need to be root on your NetBSD system to 71do the necessary installation steps). 72 73.Bl -tag -width 123 -compact 74.It 1. 75You have access to a FreeBSD system. In this case you can 76temporarily install the binary there, see what shared libraries 77it needs, and copy them to your NetBSD system. Example: you have 78just ftp-ed the FreeBSD binary of SimCity. Put it on the FreeBSD 79system you have access to, and check which shared libraries it 80needs by running `ldd sim': 81.Pp 82.Bl -tag -width 123 -compact -offset indent 83.It me@freebsd% ldd /usr/local/lib/SimCity/res/sim 84.nf 85/usr/local/lib/SimCity/res/sim: 86 -lXext.6 => /usr/X11R6/lib/libXext.so.6.0 (0x100c1000) 87 -lX11.6 => /usr/X11R6/lib/libX11.so.6.0 (0x100c9000) 88 -lc.2 => /usr/lib/libc.so.2.1 (0x10144000) 89 -lm.2 => /usr/lib/libm.so.2.0 (0x101a7000) 90 -lgcc.261 => /usr/lib/libgcc.so.261.0 (0x101bf000) 91.fi 92.El 93.Pp 94You would need go get all the files from the last column, and 95put them under /emul/freebsd. This means you eventually have 96these files on your NetBSD system: 97.Pp 98.nf 99/emul/freebsd/usr/X11R6/lib/libXext.so.6.0 100/emul/freebsd/usr/X11R6/lib/libX11.so.6.0 101/emul/freebsd/usr/lib/libc.so.2.1 102/emul/freebsd/usr/lib/libm.so.2.0 103/emul/freebsd/usr/lib/libgcc.so.261.0 104.fi 105.Pp 106Note that if you already have a FreeBSD shared library with a 107matching major revision number to the first column of the 'ldd' 108output, you won't need to copy the file named in the last column 109to your system, the one you already have should work. It is 110advisable to copy the shared library anyway if it is a newer version, 111though. You can remove the old one. So, if you have these libraries 112on your system: 113.Pp 114.nf 115/emul/freebsd/usr/lib/libc.so.2.0 116.fi 117.Pp 118and you find that the ldd output for a new binary you want to 119install is: 120.nf 121.Pp 122 -lc.2 => /usr/lib/libc.so.2.1 (0x10144000) 123.fi 124.Pp 125you won't need to worry about copying /usr/lib/libc.so.2.1 too, 126because the program should work fine with the slightly older version. 127You can decide to replace the libc.so anyway, and that should leave 128you with: 129.Pp 130.nf 131/emul/freebsd/usr/lib/libc.so.2.1 132.fi 133.Pp 134Finally, you must make sure that you have the FreeBSD runtime linker 135and its config files on your system. You should copy these 136files from the FreeBSD system to their appropriate place on your 137NetBSD system (in the /emul/freebsd tree): 138.Pp 139.nf 140usr/libexec/ld.so 141var/run/ld.so.hints 142.fi 143.Pp 144.It 2. 145You don't have access to a FreeBSD system. In that case, you 146should get the extra files you need from various ftp sites. 147Information on where to look for the various files is appended 148below. For now, let's assume you know where to get the files. 149.Pp 150Retrieve the following files (from _one_ ftp site to avoid 151any version mismatches), and install them under /emul/freebsd 152(i.e. foo/bar is installed as /emul/freebsd/foo/bar): 153.Pp 154.nf 155sbin/ldconfig 156usr/bin/ldd 157usr/lib/libc.so.x.y.z 158usr/libexec/ld.so 159.fi 160.Pp 161ldconfig and ldd don't necessarily need to be under /emul/freebsd, 162you can install them elsewhere in the system too. Just make sure 163they don't conflict with their NetBSD counterparts. A good idea 164would be to install them in /usr/local/bin as ldconfig-freebsd and 165ldd-freebsd. 166.Pp 167Run the FreeBSD ldconfig program with directory arguments in 168which the FreeBSD runtime linker should look for shared libs. 169/usr/lib are standard, you could run like the following: 170.Pp 171.Bl -tag -width 123 -compact -offset indent 172.It me@netbsd% mkdir -p /emul/freebsd/var/run 173.It me@netbsd% touch /emul/freebsd/var/run/ld.so.hints 174.It me@netbsd% ldconfig-freebsd /usr/X11R6/lib /usr/local/lib 175.El 176.Pp 177Note that argument directories of ldconfig are 178mapped to /emul/freebsd/XXXX by 179NetBSD's compat code, and should exist as such on your system. 180Make sure /emul/freebsd/var/run/ld.so.hints is exist when you run 181FreeBSD's ldconfig, if not, you may lose NetBSD's /var/run/ld.so.hints. 182 183FreeBSD ldconfig should be statically 184linked, so it doesn't need any shared libraries by itself. 185It will create the file /emul/freebsd/var/run/ld.so.hints. 186You should rerun the FreeBSD version of the ldconfig program 187each time you add a new shared library. 188.Pp 189You should now be set up for FreeBSD binaries which only need 190a shared libc. You can test this by running the FreeBSD ldd 191on itself. Suppose that you have it installed as ldd-freebsd, it 192should produce something like: 193.Pp 194.Bl -tag -width 123 -compact -offset indent 195.It me@netbsd% ldd-freebsd `which ldd-freebsd` 196.nf 197/usr/local/bin/ldd-freebsd: 198 -lc.2 => /usr/lib/libc.so.2.1 (0x1001a000) 199.fi 200.El 201.Pp 202This being done, you are ready to install new FreeBSD binaries. 203Whenever you install a new FreeBSD program, you should check 204if it needs shared libraries, and if so, whether you have 205them installed in the /emul/freebsd tree. To do this, you run 206the FreeBSD version ldd on the new program, and watch its output. 207ldd (see also the manual page for ldd(1)) will print a list 208of shared libraries that the program depends on, in the 209form -l<majorname> => <fullname>. 210.Pp 211If it prints "not found" in stead of <fullname> it means that 212you need an extra library. Which library this is, is shown 213in <majorname>, which will be of the form XXXX.<N> 214You will need to find a libXXXX.so.<N>.<mm> on a FreeBSD ftp site, 215and install it on your system. The XXXX (name) and <N> (major 216revision number) should match; the minor number(s) <mm> are 217less important, though it is advised to take the most 218recent version. 219.El 220 221.Ss Finding the necessary files. 222.Em Note: 223the information below is valid as of the time this 224document was written (June, 1995), but certain details 225such as names of ftp sites, directories and distribution names 226may have changed by the time you read this. 227.Pp 228The FreeBSD distribution is 229available on a lot of ftp sites. Sometimes the files are unpacked, 230and you can get the individual files you need, but mostly they 231are stored in distribution sets, usually consisting of subdirectories 232with gzipped tar files in them. The primary ftp sites for the 233distributions are: 234.Pp 235.nf 236ftp.freebsd.org:/pub/FreeBSD 237.fi 238.Pp 239Mirror sites are described on: 240.Pp 241.nf 242ftp.freebsd.org:/pub/FreeBSD/MIRROR.SITES 243.fi 244.Pp 245This distribution consists of a number of tar-ed and gzipped files, 246Normally, they're controlled by an install program, but you can 247retrieve files "by hand" too. The way to look something up is to retrieve all 248the files in the distribution, and ``tar ztvf'' through them for the file 249you need. Here is an example of a list of files that you might need. 250.Pp 251.Bd -unfilled -offset indent 252Needed Files 253 254ld.so 2.0-RELEASE/bindist/bindist.?? 255ldconfig 2.0-RELEASE/bindist/bindist.?? 256ldd 2.0-RELEASE/bindist/bindist.?? 257libc.so.2 2.0-RELEASE/bindist/bindist.?? 258libX11.so.6.0 2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz 259libX11.so.6.0 XFree86-3.1.1/X311bin.tgz 260libXt.so.6.0 2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz 261libXt.so.6.0 XFree86-3.1.1/X311bin.tgz 262.\" libX11.so.3 oldlibs 263.\" libXt.so.3 oldlibs 264.Ed 265.Pp 266The Files called ``bindist.??'' are tar-ed, gzipped and split, 267so you can extract contents by ``cat bindist.?? | tar zpxf -''. 268.Pp 269Extract the files from these gzipped tarfiles in your /emul/freebsd directory 270(possibly omitting or afterwards removing files you don't need), and you 271are done. 272.Sh BUGS 273The information about FreeBSD distributions may become outdated. 274