Difference between revisions of "Unix"

From RogueBasin
Jump to navigation Jump to search
(The start of a Unix page. Mostly I explain that Unix has almost no binary compatibility.)
 
(Clean up, shorten, remove unnecessary details.)
Line 1: Line 1:
'''Unix''' is a family of operating systems that includes [[BSD]], [[Linux]], [[Solaris]], commercial Unix and other Unix clones. [[Mac OS X]] is also a Unix clone at its core. Unix is the origin of [[Rogue]] and [[Definition|roguelikes]]; the [[curses library]] also comes from Unix. The world has gradually tired of calling it '''UNIX''' with all uppercase letters. In the 1980s, players would sit at their video screens and command lines, type "rogue" or "[[hack]]" or "[[larn]]" or another game, and enjoy the keyboard action and ASCII graphics. They still do it today. FreeBSD, NetBSD, OpenBSD, OpenSolaris and several GNU/Linux distributions are freely available; many programmers and skilled players use them.
'''Unix''' is a family of operating systems conforming to the ''Single Unix Specification'', ultimately based on the original AT&T Unix. Unix clones such as [[BSD]] and [[Linux]] follow most of the specification. Unix is a [http://www.unix.org/trademark.html trademark of The Open Group]; most Unix clones are [http://www.netbsd.org/Misc/call-it-a-duck.html not Unix].


(Unix is actually someone's trademark, but commonly refers also to Unix clones like BSD and Linux.)
<div class="floatright">__TOC__</div>
== Origin of the roguelike genre ==
Unix is the origin of the [[C]] programming language, the [[curses library]] and the roguelike genre of games. ''[[Rogue]]'' is a Unix program in C and curses; so are ''[[Hack]]'' and ''[[Larn]]'' and ''[[Umoria]]''. Today, both ''[[Angband]]'' and ''[[NetHack]]'' have Unix and curses as one of the supported platforms.


== How Unix is ==
Today, the Unix clones called [http://www.freebsd.org FreeBSD], [http://www.netbsd.org NetBSD], [http://www.openbsd.org OpenBSD], [http://www.minix3.org Minix], [http://www.opensolaris.org OpenSolaris] and [http://www.gnu.org GNU/Linux] are freely available. Many players and developers use them.
'''Unix is several binary-incompatible operating systems and releases over multiple


A roguelike developer who has shipped binaries of his or her game for [[Macintosh]], [[Windows]], AmigaOS, BeOS and handhelds might be uncomfortable with Unix. The realm of Unix is nearly void of binary compatibility. A program compiled on one Unix operating system will not run on another. The FreeBSD operating system and the OpenSolaris operating system, for example, have different kernels and C libraries (though the C libraries contain mostly the same C functions).
== Source-compatible ==
The source code of a C and curses program made for Linux should compile above FreeBSD, and vice versa, with at most minor changes.


: There are exceptions to this. Some operating systems provide ''binary emulation''. For example, some NetBSD/i386 kernels can load Linux/i386 binaries, providing a way to play [[ADOM]] upon NetBSD. This requires some setup, including the installation of certain Linux packages (like the GNU C library for Linux) on the NetBSD system.
In the 1980s, the many BSD and SYSV variants introduced incompatibilities to Unix, but the ''Single Unix Specification'' has brought more uniformity to things. Most functions that a roguelike programmer needs should be everywhere. For example, you can use the <tt>random</tt> function to generate random numbers, and <tt>srandom</tt> and <tt>time</tt> to seed the random number generator; you would include stdlib.h and time.h. '''A roguelike developer can program for one flavor of Unix and not worry about the others.'''


Unix runs on multiple processor architectures. At the extreme, NetBSD does at least [http://www.netbsd.org/Ports/#ports-by-cpu 17 architectures]. Ubuntu provides Linux for [http://www.ubuntu.com/download/releasenotes/606#head-e15a51f7ff4cac464dfd54cbed7506ef13814de3 4 architectures], but Linux can also run elsewhere. Ubuntu/PowerPC will ''not'' run programs from Ubuntu/SPARC. Further, some systems are not even binary compatible between releases; OpenBSD 3.9 will ''not'' run any OpenBSD 3.8 programs, unless the user installs 3.8 libraries. Unix vendors deal with this by building popular packages themselves. What the roguelike developer needs to do is to make available the roguelike's ''source code'' and permit the public to run their C (or other language) compilers on the program.
The main difference is that Linux and Darwin users will link with <tt>-lncurses</tt> while most other Unix users will link with <tt>-lcurses</tt>. Obviously this is irrelevant if the program does not use curses.


: Thanks to the [http://www.freestandards.org/en/LSB Linux Standards Base] and to the stability of the [http://www.gnu.org/software/libc/ GNU C Library], ''some'' Linux distributions have a great deal of binary compatibility. Thus some roguelikes support Linux/x86 and ''no other'' Unix, and some provide Linux binaries without source code. This of course is an exclusion of the minority who has Linux on certain Apple or Sun hardware.
The worst portability problems happen if you need to create a pseudo-terminal (as sshd and xterm do) or networking interface. Roguelike games can avoid this mess.


Further, Unix has a diverse set of libraries and environments to program in. [[NetHack]] can display on the terminal, with Xaw widgets, or with Qt widgets, all on Unix. This often causes ''[[Wikipedia:dependency hell|dependency hell]]'', a situation during which users must install libraries (such as Qt, and all of the libraries that Qt uses) before they can install a program. Fortunately, most roguelike games use common libraries. A copy of [[Angband]], built with only the "gcu" interface, needs only libc (the [[C]] library) and libcurses (the [[curses library]]) to run.
== Not binary-compatible ==
'''There is no single Unix binary format. If you want Unix users to play your roguelike game, then you should provide source code.'''


== Porting ''to'' Unix ==
OpenSolaris and Minix users cannot run Linux binaries. Most Linux binaries are usually Linux/x86 binaries, so Linux users with Alpha, PowerPC Macintosh, or Sparc hardware cannot run them either.


To do.
: Some NetBSD/x86 users can load Linux/x86 binaries through ''binary emulation''. This requires some setup, including the installation of many GNU/Linux packages on the NetBSD system. Users of NetBSD's [http://www.netbsd.org/Ports/#ports-by-cpu 16 other architectures] cannot do this.


== Porting ''from'' Unix ==
== Diversity of interfaces ==
Unix has a diverse set of libraries and environments to program in. ''[[Angband]]'' ''[[Angband]]'', ''[[NetHack]]'', and their variants take the most advantage of this, providing multiple frontends or window ports.


== Porting ''within'' Unix ==
The graphical environment on most Unix systems is the [http://www.x.org X Window System, Version 11]. The ''main-x11.c'' frontend for Angband draws the game using X11, enabling new features like tiles and multiple windows. The ''x11'' window port of NetHack provides similar features, but requires the Xaw widget set bundled with XFree86 or Xorg.
 
[[Qt]] and [[SDL]] interfaces to both Angband and NetHack also exist. Both Qt an SDL are portable across X11, Mac OS, and Microsoft Windows! Qt and SDL also add features that plain ancient X11 lacks.

Revision as of 01:17, 13 December 2006

Unix is a family of operating systems conforming to the Single Unix Specification, ultimately based on the original AT&T Unix. Unix clones such as BSD and Linux follow most of the specification. Unix is a trademark of The Open Group; most Unix clones are not Unix.

Origin of the roguelike genre

Unix is the origin of the C programming language, the curses library and the roguelike genre of games. Rogue is a Unix program in C and curses; so are Hack and Larn and Umoria. Today, both Angband and NetHack have Unix and curses as one of the supported platforms.

Today, the Unix clones called FreeBSD, NetBSD, OpenBSD, Minix, OpenSolaris and GNU/Linux are freely available. Many players and developers use them.

Source-compatible

The source code of a C and curses program made for Linux should compile above FreeBSD, and vice versa, with at most minor changes.

In the 1980s, the many BSD and SYSV variants introduced incompatibilities to Unix, but the Single Unix Specification has brought more uniformity to things. Most functions that a roguelike programmer needs should be everywhere. For example, you can use the random function to generate random numbers, and srandom and time to seed the random number generator; you would include stdlib.h and time.h. A roguelike developer can program for one flavor of Unix and not worry about the others.

The main difference is that Linux and Darwin users will link with -lncurses while most other Unix users will link with -lcurses. Obviously this is irrelevant if the program does not use curses.

The worst portability problems happen if you need to create a pseudo-terminal (as sshd and xterm do) or networking interface. Roguelike games can avoid this mess.

Not binary-compatible

There is no single Unix binary format. If you want Unix users to play your roguelike game, then you should provide source code.

OpenSolaris and Minix users cannot run Linux binaries. Most Linux binaries are usually Linux/x86 binaries, so Linux users with Alpha, PowerPC Macintosh, or Sparc hardware cannot run them either.

Some NetBSD/x86 users can load Linux/x86 binaries through binary emulation. This requires some setup, including the installation of many GNU/Linux packages on the NetBSD system. Users of NetBSD's 16 other architectures cannot do this.

Diversity of interfaces

Unix has a diverse set of libraries and environments to program in. Angband Angband, NetHack, and their variants take the most advantage of this, providing multiple frontends or window ports.

The graphical environment on most Unix systems is the X Window System, Version 11. The main-x11.c frontend for Angband draws the game using X11, enabling new features like tiles and multiple windows. The x11 window port of NetHack provides similar features, but requires the Xaw widget set bundled with XFree86 or Xorg.

Qt and SDL interfaces to both Angband and NetHack also exist. Both Qt an SDL are portable across X11, Mac OS, and Microsoft Windows! Qt and SDL also add features that plain ancient X11 lacks.