xref: /netbsd-src/share/man/man8/compat_freebsd.8 (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1.\"	$NetBSD: compat_freebsd.8,v 1.9 2001/04/04 11:21:13 wiz 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
36.Sh NAME
37.Nm compat_freebsd
38.Nd setup procedure for running FreeBSD binaries
39.Sh DESCRIPTION
40.Nx
41supports running
42.Fx
43binaries.
44Most binaries should work, except programs that use
45.Fx Ns -specific
46features.
47These include i386-specific calls, such as syscons utilities.
48The
49.Fx
50compatibility feature is active for kernels compiled
51with the
52.Dv COMPAT_FREEBSD
53option enabled.
54.Pp
55A lot of programs are dynamically linked. This means, that you will
56also need the
57.Fx
58shared libraries that the program depends on, and the runtime
59linker.
60Also, you will need to create a "shadow root" directory for
61.Fx
62binaries on your
63.Nx
64system. This directory
65is named
66.Pa /emul/freebsd .
67Any file operations done by
68.Fx
69programs run under
70.Nx
71will look in this directory first.
72So, if a
73.Fx
74program opens, for example,
75.Pa /etc/passwd ,
76.Nx
77will
78first try to open
79.Pa /emul/freebsd/etc/passwd ,
80and if that does not exist open the 'real'
81.Pa /etc/passwd
82file.
83It is recommended that you install
84.Fx
85packages that include configuration files, etc under
86.Pa /emul/freebsd ,
87to avoid naming conflicts with possible
88.Nx
89counterparts. Shared
90libraries should also be installed in the shadow tree.
91.Pp
92Generally, you will need to look for the shared libraries that
93.Fx
94binaries depend on only the first few times that you install a
95.Fx
96program on your
97.Nx
98system. After a while, you will have a sufficient
99set of
100.Fx
101shared libraries on your system to be able to run newly
102imported
103.Fx
104binaries without any extra work.
105
106.Ss Setting up shared libraries
107How to get to know which shared libraries
108.Fx
109binaries need, and where
110to get them? Basically, there are 2 possibilities (when following
111these instructions: you will need to be root on your
112.Nx
113system to do the necessary installation steps).
114
115.Bl -tag -width 123 -compact
116.It 1.
117You have access to a
118.Fx
119system.
120In this case you can temporarily install the binary there, see what
121shared libraries it needs, and copy them to your
122.Nx
123system.
124Example: you have just ftp-ed the
125.Fx
126binary of SimCity.
127Put it on the
128.Fx
129system you have access to, and check which shared libraries it
130needs by running `ldd sim':
131.Pp
132.Bl -tag -width 123 -compact -offset indent
133.It me@freebsd% ldd /usr/local/lib/SimCity/res/sim
134.nf
135/usr/local/lib/SimCity/res/sim:
136	-lXext.6 => /usr/X11R6/lib/libXext.so.6.0 (0x100c1000)
137	-lX11.6 => /usr/X11R6/lib/libX11.so.6.0 (0x100c9000)
138	-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
139	-lm.2 => /usr/lib/libm.so.2.0 (0x101a7000)
140	-lgcc.261 => /usr/lib/libgcc.so.261.0 (0x101bf000)
141.fi
142.El
143.Pp
144You would need go get all the files from the last column, and
145put them under
146.Pa /emul/freebsd .
147This means you eventually have these files on your
148.Nx
149system:
150.Pp
151.nf
152.Pa /emul/freebsd/usr/X11R6/lib/libXext.so.6.0
153.Pa /emul/freebsd/usr/X11R6/lib/libX11.so.6.0
154.Pa /emul/freebsd/usr/lib/libc.so.2.1
155.Pa /emul/freebsd/usr/lib/libm.so.2.0
156.Pa /emul/freebsd/usr/lib/libgcc.so.261.0
157.fi
158.Pp
159Note that if you already have a
160.Fx
161shared library with a matching major revision number to the first
162column of the 'ldd' output, you won't need to copy the file named
163in the last column to your system, the one you already have should
164work.
165It is advisable to copy the shared library anyway if it is a newer version,
166though.
167You can remove the old one.
168So, if you have these libraries on your system:
169.Pp
170.nf
171.Pa /emul/freebsd/usr/lib/libc.so.2.0
172.fi
173.Pp
174and you find that the ldd output for a new binary you want to
175install is:
176.Pp
177.nf
178\-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
179.fi
180.Pp
181You won't need to worry about copying
182.Pa /usr/lib/libc.so.2.1 too ,
183because the program should work fine with the slightly older version.
184You can decide to replace the libc.so anyway, and that should leave
185you with:
186.Pp
187.nf
188.Pa /emul/freebsd/usr/lib/libc.so.2.1
189.fi
190.Pp
191Finally, you must make sure that you have the
192.Fx
193runtime linker and its config files on your system.
194You should copy these files from the
195.Fx
196system to their appropriate place on your
197.Nx
198system (in the
199.Pa /emul/freebsd
200tree):
201.Pp
202.nf
203.Pa usr/libexec/ld.so
204.Pa var/run/ld.so.hints
205.fi
206.Pp
207.It 2.
208You don't have access to a
209.Fx
210system. In that case, you
211should get the extra files you need from various ftp sites.
212Information on where to look for the various files is appended
213below. For now, let's assume you know where to get the files.
214.Pp
215Retrieve the following files (from _one_ ftp site to avoid
216any version mismatches), and install them under /emul/freebsd
217(i.e. foo/bar is installed as /emul/freebsd/foo/bar):
218.Pp
219.nf
220.Pa sbin/ldconfig
221.Pa usr/bin/ldd
222.Pa usr/lib/libc.so.x.y.z
223.Pa usr/libexec/ld.so
224.fi
225.Pp
226ldconfig and ldd don't necessarily need to be under
227.Pa /emul/freebsd ,
228you can install them elsewhere in the system too. Just make sure
229they don't conflict with their
230.Nx
231counterparts.
232A good idea would be to install them in
233.Pa /usr/local/bin
234as ldconfig-freebsd and ldd-freebsd.
235.Pp
236Run the
237.Fx
238ldconfig program with directory arguments in which the
239.Fx
240runtime linker should look for shared libs.
241.Pa /usr/lib
242are standard, you could run like the following:
243.Pp
244.Bl -tag -width 123 -compact -offset indent
245.It me@netbsd% mkdir -p /emul/freebsd/var/run
246.It me@netbsd% touch /emul/freebsd/var/run/ld.so.hints
247.It me@netbsd% ldconfig-freebsd /usr/X11R6/lib /usr/local/lib
248.El
249.Pp
250Note that argument directories of ldconfig are
251mapped to
252.Pa /emul/freebsd/XXXX
253by
254.Nx Ns 's
255compat code, and should exist as such on your system.
256Make sure
257.Pa /emul/freebsd/var/run/ld.so.hints
258is existing when you run
259.Fx Ns 's
260ldconfig, if not, you may lose
261.Nx Ns 's
262.Pa /var/run/ld.so.hints .
263.Fx
264ldconfig should be statically
265linked, so it doesn't need any shared libraries by itself.
266It will create the file
267.Pa /emul/freebsd/var/run/ld.so.hints .
268You should rerun the
269.Fx
270version of the ldconfig program each time you add a new shared library.
271.Pp
272You should now be set up for
273.Fx
274binaries which only need a shared libc.
275You can test this by running the
276.Fx
277ldd on itself.
278Suppose that you have it installed as ldd-freebsd, it
279should produce something like:
280.Pp
281.Bl -tag -width 123 -compact -offset indent
282.It me@netbsd% ldd-freebsd `which ldd-freebsd`
283.nf
284/usr/local/bin/ldd-freebsd:
285	-lc.2 => /usr/lib/libc.so.2.1 (0x1001a000)
286.fi
287.El
288.Pp
289This being done, you are ready to install new
290.Fx
291binaries.
292Whenever you install a new
293.Fx
294program, you should check if it needs shared libraries, and if so,
295whether you have them installed in the
296.Pa /emul/freebsd
297tree.
298To do this, you run the
299.Fx
300version ldd on the new program, and watch its output.
301ldd (see also the manual page for
302.Xr ldd 1 )
303will print a list
304of shared libraries that the program depends on, in the
305form -l<majorname> => <fullname>.
306.Pp
307If it prints "not found" in stead of <fullname> it means that
308you need an extra library.
309Which library this is, is shown
310in <majorname>, which will be of the form XXXX.<N>
311You will need to find a libXXXX.so.<N>.<mm> on a
312.Fx
313ftp site,
314and install it on your system.
315The XXXX (name) and <N> (major
316revision number) should match; the minor number(s) <mm> are
317less important, though it is advised to take the most
318recent version.
319.Pp
320.It 3.
321In some cases,
322.Fx
323binary needs access to certain device file.
324For example,
325.Fx
326X server software needs
327.Fx
328.Pa /dev/ttyv0
329for
330.Xr pcvt 4
331ioctls.
332In this case, create a symbolic link from
333.Pa /emul/freebsd/dev/ttyv0
334to
335.Xr wscons 4
336device file like
337.Pa /dev/ttyE0 ,
338or to similar device file which provides
339.Xr pcvt 4
340ioctls.
341.El
342.Ss Finding the necessary files
343.Em Note :
344the information below is valid as of the time this
345document was written (June, 1995), but certain details
346such as names of ftp sites, directories and distribution names
347may have changed by the time you read this.
348.Pp
349The
350.Fx
351distribution is available on a lot of ftp sites.
352Sometimes the files are unpacked, and you can get the individual
353files you need, but mostly they are stored in distribution sets,
354usually consisting of subdirectories with gzipped tar files in them.
355The primary ftp sites for the distributions are:
356.Pp
357.nf
358ftp.freebsd.org:/pub/FreeBSD
359.fi
360.Pp
361Mirror sites are described on:
362.Pp
363.nf
364ftp.freebsd.org:/pub/FreeBSD/MIRROR.SITES
365.fi
366.Pp
367This distribution consists of a number of tar-ed and gzipped files,
368Normally, they're controlled by an install program, but you can
369retrieve files "by hand" too.
370The way to look something up is to retrieve all the files in the
371distribution, and ``tar ztvf'' through them for the file you need.
372Here is an example of a list of files that you might need.
373.Pp
374.Bd -unfilled -offset indent
375Needed                 Files
376
377ld.so                  2.0-RELEASE/bindist/bindist.??
378ldconfig               2.0-RELEASE/bindist/bindist.??
379ldd                    2.0-RELEASE/bindist/bindist.??
380libc.so.2              2.0-RELEASE/bindist/bindist.??
381libX11.so.6.0          2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz
382libX11.so.6.0          XFree86-3.1.1/X311bin.tgz
383libXt.so.6.0           2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz
384libXt.so.6.0           XFree86-3.1.1/X311bin.tgz
385.\" libX11.so.3            oldlibs
386.\" libXt.so.3             oldlibs
387.Ed
388.Pp
389The Files called ``bindist.??'' are tar-ed, gzipped and split,
390so you can extract contents by ``cat bindist.?? | tar zpxf -''.
391.Pp
392Extract the files from these gzipped tarfiles in your
393.Pa /emul/freebsd
394directory (possibly omitting or afterwards removing files you don't
395need), and you are done.
396.Sh BUGS
397The information about
398.Fx
399distributions may become outdated.
400