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