Component Compilation Notes

By Paul A. Whittaker

Last Update: 21 October 2009

WARNING: This page is out-of-date. DIET-PC 3 compilation automation is now provided with the source code.

This file contains my instructions for compiling DIET-PC binaries. This is a work in progress; if you are viewing a copy of this file included with a DIET-PC source code bundle, please check the online version for updates. Instructions provided are intended for DIET-PC 2; software versions actually deployed in DIET-PC 1.1 may differ, and may require different workarounds or configuration parameters when building.

You're no doubt wondering why I don't have a complete CVS source code tree and a master Makefile that just builds everything. Well, there are two reasons for this: (i) it's difficult, and (ii) it would slow the rate of change such that DIET-PC would have to use older versions of most software components. As you'll see below, DIET-PC builds of most software components are heavily modified, by DIET-PC-specific patches (I try to get my patches rolled in to the official releases in cases where the issue isn't DIET-PC-specific), or modified build procedures to produce "embedded-friendly" binaries, or both. In many cases, automation provided with the software distribution is too inaccurate for this sort of work, and binaries need to be relinked by hand without bogus dependencies introduced by "shotgun" automation. Needless to say, writing my own automation to resolve all of these issues would be immensely time consuming, so you're going to have to do some of the work manually instead.

The official build environment for DIET-PC is Debian: Woody (3.0) for DIET-PC 1.1, Etch (4.0) for DIET-PC 2, and Lenny (5.0) for DIET-PC 3. If you choose not to use Debian, pay particular attention to the glibc requirements for each DIET-PC release: not greater than glibc 2.2.5 for DIET-PC 1.1, 2.3.6 for DIET-PC 2, and 2.7 for DIET-PC 3.

Ultimately I will ensure that all code compiles cleanly under gcc 4.x (although I use g++ 2.x to produce smaller C++ binaries), but at present gcc 3.x may still be required for some compilations.

One of the aims of DIET-PC is to be developer friendly; I don't want to force developers to use a dedicated build environment if this can be avoided. I try to keep DIET-PC reasonably up-to-date with current software versions (even if this causes some bloat), so that straightforward transplantation of binaries compiled on the likewise reasonably-up-to-date Linux distro that you are hopefully using stands the best possible chance of success.

Nevertheless, it's likely that in some places my instructions are not going to work for distros other than Debian. If you're reasonably familiar with compilation tools you should be able to sort out any minor differences. Pay close attention to shared library dependencies - DIET-PC does not have a full range of shared libraries. If you end up with a binary that needs a library that DIET-PC doesn't have (use "ldd" to show dependencies), either recompile it without the feature that introduces that dependency (typically using a --without-xyz or --disable-xyz GNU configure option), or if you can't do that, link the binary manually with that particular library static, using "-Wl,-Bstatic -llibrary -Wl,-Bdynamic". In some cases, such as when a library is loaded by an application rather than via the dynamic linker (eg. libdvdcss), it may prove necessary to compile and include that shared library in your DIET-PC build. Beware of dynamic linkage of under some circumstances and with certain versions of gcc (I want to avoid adding this library to DIET-PC (or DIET-PC 2, at least)). This behaviour can be suppressed by adding the "-static-libgcc" option to CFLAGS or similar.

Gentoo might not be a suitable choice for a development environment if you intend to deploy to a diverse range of hardware. This is because any static library that you link against is likely to have been compiled for the specific instruction set of the Gentoo host's CPU (i.e. -march=xxx) and consequently the code you produce will not run on older hardware.

It is assumed that ~/diet-pc-src contains all relevant downloadable source code objects (tarballs, DIET-PC patches, config file templates). The target directory tree is assumed to be located at ~/diet-pc. For best performance, I recommend performing the actual compilation in a tmpfs filesystem (/tmp or /dev/shm).

I have not provided URLs for most source code distributions, as this is too much of a moving target. You can almost always find the source by doing a project search at In cases where you can't, I will endeavour to provide a URL.

The current user is assumed to be root, with a BASH shell. The shell's umask is assumed to be 022. It isn't necessary to compile as root, it's just more convenient for installing. If your distro's root shell environment aliases the cp, mv and rm commands to force usage of the "-i" (interactive) flag for safety, you you should remove these aliases (eg. "unalias cp") before attempting to cut and paste multiple lines from this webpage.

To avoid repeating myself, all of the instructions below now assume that you have set CFLAGS and CXXFLAGS environment variables appropriately for embedded compilation for your platform. The easiest way to do this is to add the following to your ~/.bashrc file:

case "`uname -m`" in
    # DIET-PC 3: use '-march=i486 -mtune=i686' instead
    # ARM EABI: use '-mabi=aapcs-linux' instead
    # DIET-PC 3: use '-mtune=xscale' instead
export CFLAGS="-Os $TUNING"
[ "`which g++-2.95`" ] && export CXX='g++-2.95'

In comments in the build procedure, I use $CFLAGS as shorthand for what is set above, even in contexts where the literal string "$CFLAGS" is not understood. When editing files, substitute what $CFLAGS evaluates to (i.e. the output of the shell command "echo $CFLAGS") rather than the literal string "$CFLAGS". Failure to set $CFLAGS correctly will not prevent compilation from succeeding, it will just result in a binary that is suboptimal for DIET-PC use (-Os avoids optimisations that result in bigger binaries; -mtune=XXX tries to make the code run most efficiently for the named processor class while not excluding other processor types (which is what -march=XXX does)).

Instructions assume Intel 80x86 architecture by default. Where the above environment variable differences are not sufficient to cater to other platforms and there is a platform-specific variation to the procedure, obey the comments provided.

It shouldn't make any difference, but FYI, my ARM build platform is a ThinLinx Hot-e HL200 (an ARM920T-based SBC), my PowerPC build platform is an Aluminium G4 Powerbook (7400 series CPU), and my x86/x86_64 build platform is an Intel Core 2 Duo 2.66 GHz based on an ASUS P5KC mainboard. It is possible to use cross-compilers, but I have a strong preference for native or emulated compilation, to avoid oversights and complications. Native compilation can be emulated using QEMU ("integratorcp926" for ARM, "prep" for PPC and "mips" for MIPSEL); if you have a fast x86 CPU this may even be faster than using real hardware in some cases (eg. ARM and MIPSEL).


acpid 1.0.6

tar xzf ~/diet-pc-src/acpid-1.0.6.tar.gz
cd acpid-1.0.6
vi Makefile	# Substitute $CFLAGS for "-g" in CFLAGS
strip -R .note -R .comment acpid
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp acpid ~/diet-pc/shell/files/usr/sbin/
~/diet-pc/tools/man2txt acpid.8 >~/diet-pc/shell/acpid.txt

alsa-lib 1.0.21a

tar xjf ~/diet-pc-src/alsa-lib-1.0.21a.tar.bz2
cd alsa-lib-1.0.21a
./configure --prefix=/usr --sysconfdir=/etc
strip -R .note -R .comment src/.libs/
mkdir -p ~/diet-pc/mmedia_xine/files/usr/lib
cp src/.libs/ ~/diet-pc/mmedia_xine/files/usr/lib/
mkdir -p ~/diet-pc/mmedia_xine/files/usr/share/alsa
cd src/conf
cp -r * ~/diet-pc/mmedia_xine/files/usr/share/alsa/
find  ~/diet-pc/mmedia_xine/files/usr/share/alsa -name Makefile\* -exec rm {} \;
cd ../../..
rm -rf alsa-lib-1.0.21a

alsa-utils 1.0.21

tar xjf ~/diet-pc-src/alsa-utils-1.0.21.tar.bz2
cd alsa-utils-1.0.21
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-nls \
make -C amixer
gcc -o amixer/amixer amixer/amixer.o -lasound
make -C alsamixer
gcc -o alsamixer/alsamixer alsamixer/*.o -Wl,-Bstatic -lform -lmenu -lpanel \
	-lncurses -Wl,-Bdynamic -lasound
strip -R .note -R .comment amixer/amixer alsamixer/alsamixer

apmd 3.2.2

Debian has taken responsibility for this otherwise defunct project. Official sources are available at

tar xzf ~/diet-pc-src/apmd_3.2.2.orig.tar.gz
cd apmd-3.2.2.orig
gcc -o apm .libs/apm.o .libs/libapm.a
gcc -o apmd .libs/apmd.o .libs/libapm.a
strip -R .note -R .comment apm apmd
mkdir -p ~/diet-pc/shell/extras
cp apm apmd ~/diet-pc/shell/extras/
~/diet-pc/tools/man2txt apm.1 >~/diet-pc/shell/extras/apm.txt
~/diet-pc/tools/man2txt apmd.8 >~/diet-pc/shell/extras/apmd.txt
cd ..
rm -rf apmd-3.2.2.orig

aumix 2.8

tar xjf ~/diet-pc-src/aumix-2.8.tar.bz2
cd aumix-2.8
# DIET-PC 3: use --prefix='' instead.
./configure --prefix=/usr --sysconfdir=/etc --without-gtk --without-gtk1 \
	--without-gpm --without-ncurses --disable-nls
# Note that aumix 2.8 will not use ALSA hardware mute support regardless of
# configure finds, so the format and version of your libasound is not relevant
# here.
strip -R .note -R .comment src/aumix
mkdir -p ~/diet-pc/shell/files/usr/bin
cp src/aumix ~/diet-pc/shell/files/usr/bin/
cd ..
rm -rf aumix-2.8

autofs 4.1.4

tar xjf ~/diet-pc-src/autofs-4.1.4.tar.bz2
cd autofs-4.1.4
for patch in  ~/diet-pc-src/autofs-4.1.4-*.patch.bz2; do
	bunzip2 -c $patch | patch -p1 -E
vi Makefile.rules	# modify CFLAGS as required (-O3 to -Os, add -mtune=xxx)
./configure --prefix=/usr --sysconfdir=/etc
strip -R .note -R .comment daemon/automount modules/*.so
mkdir -p ~/diet-pc/storageserver/files/usr/sbin
mkdir -p ~/diet-pc/storageserver/files/usr/lib/autofs
cp daemon/automount ~/diet-pc/storageserver/files/usr/sbin/
cp modules/{lookup_file,mount_bind,mount_generic,mount_nfs,parse_sun}.so \
~/diet-pc/tools/man2txt man/autofs.5 >~/diet-pc/storageserver/autofs.txt
~/diet-pc/tools/man2txt man/automount.8 >~/diet-pc/storageserver/automount.txt
cd ..
rm -rf autofs-4.1.4

binutils 2.19

tar xjf ~/diet-pc-src/binutils-2.19.tar.bz2
cd binutils-2.19
./configure --prefix=/usr --sysconfdir=/etc --build=i386-dietpc-linux-gnu
# (ARM: use --build=arm-dietpc-linux-gnu, add --without-fp)
# (ARMEL: use --build=arm-dietpc-linux-gnueabi)
# (x86_64: use --build=x86_64-dietpc-linux-gnu)
# (DIET-PC 3: use --build=i486-dietpc-linux-gnu)
make configure-bfd
make -C bfd
make -C libiberty
make configure-binutils
make -C binutils strip-new
strip -R .note -R .comment binutils/strip-new
mkdir -p ~/diet-pc/assembler_installer/files/usr/bin
cp binutils/strip-new ~/diet-pc/assembler_installer/files/usr/bin/strip
cd ..
rm -rf binutils-2.19

bootsplash 3.1

Previously I had used the fork because was not being updated, but this situation has now reversed, so I have reverted to the latter.

The bootsplash project has now been superceded by splashy, but DIET-PC 2 must continue to use bootsplash for backward compatibility.

tar xjf ~/diet-pc-src/bootsplash-3.1.tar.bz2
cd bootsplash-3.1/Utilities
make splash CFLAGS="$CFLAGS"
strip -R .note -R .comment splash
mkdir -p ~/diet-pc/tools
cp splash ~/diet-pc/tools/
cd ../..
rm -rf bootsplash-3.1

busybox 1.10.4

N.B. requires libncurses5-dev.

tar xjf ~/diet-pc-src/busybox-1.10.4.tar.bz2
cd busybox-1.9.1
bunzip2 -c ~/diet-pc-src/busybox-1.9.1-dietpc-patch.bz2 | patch -p1
cp ~/diet-pc-src/dietpc_bbconfig-1.10.4 .config
make menuconfig		# Just save and exit unless you wish to change anything
mkdir -p ~/diet-pc/shell/files/bin
cp busybox ~/diet-pc/shell/files/bin/
chmod u+s ~/diet-pc/shell/files/bin/busybox
cd ..
rm -rf busybox-1.10.4

cdrtools 2.01

tar xjf ~/diet-pc-src/cdrtools-2.01.tar.bz2
cd cdrtools-2.01
chmod u+w RULES/i686-linux-gcc.rul
vi RULES/i686-linux-gcc.rul	# change COPTOPT=$CFLAGS
# (PPC: Modify RULES/ppc-linux-gcc.rul instead)
# (ARM: Modify RULES/armv4l-linux-gcc.rul instead)
# (x86_64: Modify RULES/x86_64-linux-gcc.rul instead)
# (MIPSEL: Modify RULES/mipsel-linux-gcc-rul instead)
vi DEFAULTS/Defaults.linux	# set DEFCCOM=gcc LDPATH= RUNPATH=
				# INS_BASE=/usr)
# (ARM: the above command may fail, if so create a symbolic link to
# RULES/armv4l-linux-gcc.rul for the required name and run make again, eg.
# "ln -s armv4l-linux-gcc.rul RULES/armv4tl-linux-gcc.rul".)
strip -R .note -R .comment rscsi/OBJ/*/rscsi cdrecord/OBJ/*/cdrecord \
mkdir -p ~/diet-pc/storageserver/files/usr/sbin
mkdir -p ~/diet-pc/storageserver/files/opt
cp rscsi/OBJ/*/rscsi ~/diet-pc/storageserver/files/usr/sbin/
chmod 4755 ~/diet-pc/storageserver/files/usr/sbin/rscsi
ln -s ../usr ~/diet-pc/storageserver/files/opt/schily
mkdir -p ~/diet-pc/assembler_installer/files/usr/bin
cp cdrecord/OBJ/*/cdrecord mkisofs/OBJ/*/mkisofs \
cd ..
rm -rf cdrtools-2.01


This is a homegrown helper utility. Source code is available from the DIET-PC downloads area.

gcc $CFLAGS -Wall -o checkhostname ~/diet-pc-src/checkhostname.c
strip -R .note -R .comment checkhostname
mkdir -p ~/diet-pc/shell/files/bin
mv checkhostname ~/diet-pc/shell/files/bin/

console-data 1999.08.29

Prerequisite: Compile and install Busybox first.

Appears as "linuxconsoledata" on Freshmeat.

tar xzf ~/diet-pc-src/console-data_1999.08.29.orig.tar.gz
cd console-data-1999.08.29
mkdir -p ~/diet-pc/shell/files/lib/kbd/consolefonts
cp consolefonts/default8x16.psf \
	# or other file as required for your locale
cd keymaps/i386
for kmap in `find . -name \*.kmap -print`; do
    sudo loadkeys $kmap
    sudo ~/diet-pc/shell/files/bin/busybox dumpkmap >\
	    `echo $kmap | sed 's/kmap$/bkmap/'`
done; sudo loadkeys -d
mkdir -p ~/diet-pc/shell/extras/kmaps
find .  -name \*.bkmap -print | tar cTf - - | tar xCf \
        ~/diet-pc/shell/extras/kmaps -
mkdir -p ~/diet-pc/shell/files/lib/kbd/kmaps
cp qwerty/us.bkmap ~/diet-pc/shell/files/lib/kbd/kmaps/default.bkmap
    # or other file as required for your locale
cd ../../..
rm -rf console-data-1999.08.29

coreutils 7.6

tar xzf ~/diet-pc-src/coreutils-7.6.tar.gz
cd coreutils-7.6
./configure --prefix=/usr --sysconfdir=/etc --disable-nls
make -C lib
make -C src version.h
make -C src df
make -C src tsort
strip -R .note -R .comment src/df src/tsort
mkdir -p ~/diet-pc/assembler_installer/files/bin
cp src/df ~/diet-pc/assembler_installer/files/bin/
cd ..
rm -rf coreutils-7.6

cpio 2.9

Note to self: lib/argp-help.c exposes what appears to be a gcc 4.3.x bug, had to compile this with gcc-4.1 instead.

tar xjf ~/diet-pc-src/cpio-2.9.tar.bz2
cd cpio-2.9
./configure --prefix='' --with-rmt=/etc/rmt --disable-nls
strip -R .note -R .comment src/cpio
mkdir -p ~/diet-pc/assembler_installer/files/bin
cp src/cpio ~/diet-pc/assembler_installer/files/bin/
cd ..
rm -rf cpio-2.9

curl 7.18.1

This produces a slimmed-down libcurl.a that we can link against for anything that absolutely must use curl.

tar xjf ~/diet-pc-src/curl-7.18.1.tar.bz2
cd curl-7.18.1
./configure --prefix=/usr/local --sysconfdir=/etc --enable-http --enable-ftp \
	--disable-file --disable-ldap --disable-ldaps --disable-dict \
	--disable-telnet --disable-tftp --disable-manual --disable-ipv6 \
	--enable-nonblocking --enable-thread --disable-verbose --disable-sspi \
	--disable-debug --enable-cookies --enable-hidden-symbols \
	--without-libidn --disable-shared --with-ca-path=/usr/openssl/certs
sudo make install
cd ..
rm -rf curl-7.18.1

dosfstools 2.11

Dosfstools seems to lack an authoritative home page. SUSE Linux claims that is the offical site.
tar xzf ~/diet-pc-src/dosfstools-2.11.src.tar.gz
cd dosfstools-2.11
vi Makefile		# change OPTFLAGS as required (-O2 to -Os, add
			# -mtune=xxx)
strip -R .note -R .comment dosfsck/dosfsck mkdosfs/mkdosfs
mkdir -p ~/diet-pc/persistfs/files/sbin
cp dosfsck/dosfsck ~/diet-pc/persistfs/files/sbin/fsck.vfat
cp mkdosfs/mkdosfs ~/diet-pc/persistfs/files/sbin/mkfs.vfat
cd ..
rm -rf dosfstools-2.11

dropbear 0.52

tar xjf ~/diet-pc-src/dropbear-0.52.tar.bz2
cd dropbear-0.52
# DIET-PC 3: use --prefix='' instead.
./configure --prefix=/usr --sysconfdir=/etc
vi Makefile	# change "-lutil" to "-Wl,-Bstatic -lutil -Wl,-Bdynamic" in LIBS
# DIET-PC 3 only:
#vi options.h	# change XAUTH_COMMAND to "/usr/bin/xauth -q",
		# _PATH_SSH_PROGRAM to "/bin/dbclient", DEFAULT_PATH to
		# "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"
		# and comment out SFTPSERVER_PATH
make scp
strip -R .note -R .comment dropbear dropbearconvert dropbearkey dbclient scp
mkdir -p ~/diet-pc/sshserver/files/usr/sbin ~/diet-pc/sshserver/extras \
# DIET-PC 3: install dropbear to files/sbin instead of files/usr/sbin
cp dropbear ~/diet-pc/sshserver/files/usr/sbin/
cp scp ~/diet-pc/sshserver/files/sbin/
cp dropbearconvert dropbearkey dbclient ~/diet-pc/sshserver/extras/
~/diet-pc/tools/man2txt dropbear.8 >~/diet-pc/sshserver/dropbear.txt
~/diet-pc/tools/man2txt dropbearkey.8 \
~/diet-pc/tools/man2txt dbclient.1 >~/diet-pc/sshserver/extras/dbclient.txt
cd ..
rm -rf dropbear-0.52

dump 0.4b42

N.B. requires e2fslibs-dev and libreadline5-dev.

tar xzf ~/diet-pc-src/dump-0.4b42.tar.gz
cd dump-0.4b42
./configure --prefix='' --with-cc-opts="$CFLAGS" --enable-rmt
make -C compat/lib
make -C rmt GLIBS='-L../compat/lib -lcompat'
strip -R .note -R .comment rmt/rmt
mkdir -p ~/diet-pc/storageserver/files/usr/sbin
mkdir -p ~/diet-pc/storageserver/files/etc
cp rmt/rmt ~/diet-pc/storageserver/files/usr/sbin/
ln -s ../usr/sbin/rmt ~/diet-pc/storageserver/files/etc/rmt
cd ..
rm -rf dump-0.4b42

e2fsprogs 1.41.9

The patch to add ext2 compression support is available from

tar xzf ~/diet-pc-src/e2fsprogs-1.41.9.tar.gz
cd e2fsprogs-1.41.9
bunzip2 -c ~/diet-pc-src/e2fsprogs-1.41.9-e2compr-0.4.12-0.diff.bz2 | patch \
	-p1 -b
bunzip2 -c ~/diet-pc-src/e2fsprogs-1.41.9-dietpc-patch.bz2 | patch -p1 -b
./configure --prefix=/usr --sbindir=/sbin --with-ccopts="$CFLAGS" \
	--enable-compression --enable-fsck --disable-nls
# DIET-PC 3: use --prefix='' instead.
strip -R .note -R .comment e2fsck/e2fsck resize/resize2fs \
mkdir -p ~/diet-pc/assembler_installer/files/sbin
mkdir -p ~/diet-pc/persistfs/files/sbin ~/diet-pc/persistfs/extras
mkdir -p ~/diet-pc/persistfs/files/usr/bin
mkdir -p ~/diet-pc/storageserver/files/usr/sbin
mkdir -p ~/diet-pc/tools ~/diet-pc/tools-doc
cp e2fsck/e2fsck ~/diet-pc/persistfs/files/sbin/fsck.ext2
ln -s fsck.ext2 ~/diet-pc/persistfs/files/sbin/fsck.ext3
cp misc/fsck ~/diet-pc/persistfs/files/sbin/
cp misc/mke2fs ~/diet-pc/assembler_installer/files/sbin/mkfs.ext2
ln -s mkfs.ext2 ~/diet-pc/assembler_installer/files/sbin/mke2fs
cp misc/mke2fs ~/diet-pc/persistfs/files/sbin/mkfs.ext2
ln -s mkfs.ext2 ~/diet-pc/persistfs/files/sbin/mkfs.ext3
cp misc/{lsattr,chattr} ~/diet-pc/persistfs/files/usr/bin/
cp misc/{lsattr,chattr} ~/diet-pc/tools/
cp misc/{badblocks,dumpe2fs,e2image,tune2fs} ~/diet-pc/persistfs/extras/
cp resize/resize2fs ~/diet-pc/persistfs/extras/
cp misc/blkid ~/diet-pc/storageserver/files/usr/sbin/
~/diet-pc/tools/man2txt misc/chattr.1 >\
~/diet-pc/tools/man2txt misc/lsattr.1 >\
cd ..
rm -rf e2fsprogs-1.41.9

e3 2.7.0

N.B. requires nasm.

FIXME: Endian fix required for PowerPC.

tar xzf ~/diet-pc-src/e3-2.7.0.tar.gz
cd e3-2.7.0
# (PPC, ARM, x86_64 and MIPSEL: build the alternate C version as follows:
# vi e3c/e3.c	# Change "#define POP(arg) arg=(typeof(arg))(*esp--)"
		# Change line 1306 to "ebp=(unsigned char *)((long)ebp+eax);"
# make -C e3c PREFIX=/usr CFLAGS="$CFLAGS"
# strip -R .note -R .comment e3c/e3c
# ln -s e3c/e3c e3
mkdir -p ~/diet-pc/assembler_installer/files/bin
mkdir -p ~/diet-pc/shell/extras
cp e3 ~/diet-pc/assembler_installer/files/bin/
cp e3 ~/diet-pc/shell/extras/
~/diet-pc/tools/man2txt >~/diet-pc/assembler_installer/e3.txt
cd ..
rm -rf e3-2.7.0

ed 1.4

Busybox's ed applet is not quite up to the task ...

tar xzf ~/diet-pc-src/ed-1.4.tar.gz
cd ed-1.4
./configure --prefix=''
strip -R .note -R .comment ed
mkdir -p ~/diet-pc/assembler_installer/files/bin
cp ed ~/diet-pc/assembler_installer/files/bin/
cd ..
rm -rf ed-1.4

EsounD 0.2.41

N.B. requires libaudiofile-dev.

tar xjf ~/diet-pc-src/esound-0.2.41.tar.bz2
cd esound-0.2.41
./configure --prefix=/usr --sysconfdir=/etc --disable-shared --with-libwrap \
	--disable-alsa  	# ALSA causes too much bloat - sorry!
make esd AUDIOFILE_LIBS='/usr/lib/libaudiofile.a -lm' LIBS=''
strip -R .note -R .comment esd
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp esd ~/diet-pc/shell/files/usr/sbin/
~/diet-pc/tools/man2txt docs/esd.1 >~/diet-pc/shell/esd.txt
cd ..
rm -rf esound-0.2.41

ethtool 6

tar xzf ~/diet-pc-src/ethtool-6.tar.gz
cd ethtool-6
./configure --prefix=''
strip -R .note -R .comment ethtool
mkdir -p ~/diet-pc/shell/files/sbin
cp ethtool ~/diet-pc/shell/files/sbin/
~/diet-pc/tools/man2txt ethtool.8 >~/diet-pc/shell/ethtool.txt
cd ..
rm -rf ethtool-6

evilwm 0.99.17

N.B. requires lesstif2-dev.

FIXME: ensure patch is up-to-date - recent ctrl-alt-something fix?

tar xzf ~/diet-pc-src/evilwm_0.99.17.orig.tar.gz
cd evilwm-0.99.17.orig
bunzip2 -c ~/diet-pc-src/evilwm-0.99.17-dietpc-patch.bz2 | patch -p1 -b
vi Makefile	# change CFLAGS as required
strip -R .note -R .comment evilwm
mkdir -p ~/diet-pc/xcore/files/usr/X11R6/bin
cp evilwm ~/diet-pc/xcore/files/usr/X11R6/bin/
~/diet-pc/tools/man2txt evilwm.1 >~/diet-pc/xcore/evilwm.txt
cd ..
rm -rf evilwm-0.99.17.orig

fontconfig 2.6.0

tar xzf ~/diet-pc-src/fontconfig-2.6.0.tar.gz
cd fontconfig-2.6.0
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
strip -R .note -R .comment src/.libs/ \

freetype 2.3.9

tar xjf ~/diet-pc-src/freetype-2.3.9.tar.bz2
cd freetype-2.3.9
./configure --prefix=/usr --sysconfdir=/etc --disable-static
vi +302 builds/unix/ftconfig.h		# Change "asm" to "__asm__"
strip -R .note -R .comment src/.libs/


This is a homegrown helper utility. Source code is available from the DIET-PC downloads area.

gcc $CFLAGS -Wall -o getnetmask ~/diet-pc-src/getnetmask.c
strip -R .note -R .comment getnetmask
mkdir -p ~/diet-pc/shell/files/bin
mv getnetmask ~/diet-pc/shell/files/bin/

glibc 2.3.6

If you are compiling under Debian Etch, please install gawk and ensure that /etc/alternatives/awk points to this. Mawk will not work with some of the complex awk scripts that the glibc build automation uses.

Debian glibc patches can be found in the debian/pool/main/g/glibc/ subdirectory on any Debian mirror.

tar xjf ~/diet-pc-src/glibc-2.3.6.tar.bz2
cd glibc-2.3.6
tar xjf ~/diet-pc-src/glibc-linuxthreads-2.3.6.tar.bz2
# In earlier versions, it was necessary to move "#include <useldt.h>"
# outside the #ifdef in linuxthreads/sysdeps/i386/tls.h.  2.3.5 and later
# don't need this.
# Unfortunately most non-x86 architectures need a lot of unofficial patches.
# Since Debian is one of the most portable distros, and also the reference
# DIET-PC development platform, we'll use their patch set.  Ensure that you
# have "quilt" installed before proceeding.
gunzip -c ~/diet-pc-src/glibc_2.3.6.ds1-13etch4.diff.gz | patch -p1
ln -s debian/patches
vi patches/series	# Change "-p1" to "-p2" on "hppa/cvs-clone.diff" line
# ARM platform only:
#mkdir .pc.arm-softfloat
#cp patches/series.arm-softfloat .pc.arm-softfloat/series
#env QUILT_PC=.pc.arm-softfloat quilt upgrade
#env QUILT_PC=.pc.arm-softfloat quilt push -a
mv manual/Makefile manual/Makefile.old
quilt push -a
mkdir ../glibc-build
cd ../glibc-build
../glibc-2.3.6/configure --prefix=/usr --enable-add-ons=linuxthreads \
	--disable-profile --enable-kernel=2.2.0 --with-tls --without-__thread \
	--with-headers=/usr/include --build=i386-dietpc-linux-gnu
# (x86_64: omit --without-__thread, change --build=x86_64-dietpc-linux-gnu
# (PPC: omit --without-__thread, change --build=ppc-dietpc-linux-gnu)
# (ARM: omit --without-__thread, change --build=arm-dietpc-linux-gnu, add
# --without-fp)
# (MIPSEL: omit --without-__thread, change --build=mipsel-dietpc-linux-gnu)
strip -R .note -R .comment elf/{ldconfig,} \
	crypt/ dlfcn/ math/ nis/ \
	resolv/{,} nss/ \
	linuxthreads/ rt/
# (PPC and MIPSEL: change to
# (ARM EABI: change to
# (x86_64: change to
mkdir -p ~/diet-pc/shell/files/lib ~/diet-pc/shell/extras
mkdir -p ~/diet-pc/shell/files/usr/bin
mkdir -p ~/diet-pc/assembler_installer/files/sbin
mkdir -p ~/diet-pc/mmedia_xine/files/lib
mkdir -p ~/diet-pc/xserver_xorg/files/lib
cp elf/ crypt/ dlfcn/ \
	math/ nis/ resolv/{,} \
	nss/ linuxthreads/ \
# (PPC and MIPSEL: change to
# (ARM EABI: change to
# (x86_64: change to
chmod u+w elf/ldd
vi elf/ldd	# Substitute "true" for "set -o pipefail".
		# Inconsiderate bastards.
cp elf/ldd ~/diet-pc/shell/files/usr/bin/
cp elf/ldconfig rt/ ~/diet-pc/shell/extras/
cp rt/ ~/diet-pc/mmedia_xine/files/lib/
cp rt/ ~/diet-pc/xserver_xorg/files/lib/
cp elf/ldconfig ~/diet-pc/assembler_installer/files/sbin/
cd ..
tar cjf glibc-build.tar.bz2 glibc-build	# Retain a copy of this in case you
					# need to borrow more libraries from it
					# at a later date
rm -rf glibc-build glibc-2.3.6

glibc 2.7

These intructions are for DIET-PC 3 (experimental) only. Please use glibc 2.3.6 for DIET-PC 2.

Note that compilation will fail if AWK=mawk. Install gawk instead!

tar xjf ~/diet-pc-src/glibc-2.7.tar.bz2
cd glibc-2.7
tar xjf ~/diet-pc-src/glibc-ports-2.7.tar.bz2
ln -s glibc-ports-2.7 ports
gunzip -c ~/diet-pc-src/glibc_2.7-18.diff.gz | patch -p1
ln -s debian/patches
mv manual/Makefile manual/Makefile.old
quilt delete hppa/submitted-lt.diff
quilt delete i386/local-linuxthreads-gscope.diff
quilt delete amd64/local-linuxthreads-gscope.diff
quilt delete m68k/local-pthread_lock.diff
quilt delete all/local-pthread-manpages.diff
quilt delete any/local-linuxthreads-gscope.diff
quilt delete any/local-linuxthreads-fd.diff
quilt delete any/local-linuxthreads-signals.diff
quilt delete any/local-linuxthreads-semaphore_h.diff
quilt delete any/local-linuxthreads-tst-sighandler.diff
quilt delete any/local-linuxthreads-weak.diff
quilt push -a
# Fails on: hurd-i386/submitted-libc_once.diff
quilt push -f
quilt refresh
quilt push -a
# Fails on: any/local-notls.diff
quilt push -f
quilt refresh
quilt push -a
# Fails on: any/local-sysctl.diff
quilt push -f
quilt refresh
quilt push -a
vi io/Makefile		# Remove "fstatat64" from "static-only-routines"
mkdir ../glibc-build
cd ../glibc-build
../glibc-2.7/configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
	--enable-add-ons=nptl --disable-profile --enable-kernel=2.2.0 \
	--with-tls --with-headers=/usr/include --build=i486-dietpc-linux-gnu
# (X86_64: --build=x86_64-dietpc-linux-gnu)
# (PPC: --enable-add-ons=glibc-ports-2.7,nptl --build=ppc-dietpc-linux-gnu)
# (ARM: --enable-add-ons=glibc-ports-2.7,nptl --without-fp
#	--build=arm-dietpc-linux-gnu)
# (ARM EABI: --enable-add-ons=glibc-ports-2.7,nptl
#	--build=arm-dietpc-linux-gnueabi)
# (MIPSEL: --enable-add-ons=glibc-ports-2.7,nptl
#	--build=mipsel-dietpc-linux-gnu)
strip -R .note -R .comment elf/{ldconfig,} \
	crypt/ dlfcn/ math/ nis/ \
	resolv/{,} nss/ \
	nptl/ rt/
# (PPC and MIPSEL: change to
# (ARM EABI: change to
# (x86_64: change to
mkdir -p ~/diet-pc/shell/files/lib ~/diet-pc/shell/extras
mkdir -p ~/diet-pc/shell/files/bin
mkdir -p ~/diet-pc/assembler_installer/files/sbin
cp /lib/ ~/diet-pc/shell/files/lib
strip -R .note -R .comment ~/diet-pc/shell/files/lib/
cp elf/ crypt/ dlfcn/ \
	math/ nis/ resolv/{,} \
	nss/ nptl/ rt/ \
# (PPC and MIPSEL: change to
# (ARM EABI: change to
# (x86_64: change to
chmod u+w elf/ldd
vi elf/ldd	# Change first line to "#! /bin/sh"
		# Substitute "true" for "set -o pipefail".
cp elf/ldd ~/diet-pc/shell/files/bin
cp elf/ldconfig ~/diet-pc/shell/extras
cp elf/ldconfig ~/diet-pc/assembler_installer/files/sbin
cd ..
tar cjf glibc-build.tar.bz2 glibc-build	# Retain a copy of this in case you
					# need to borrow more libraries from it
					# at a later date
rm -rf glibc-build glibc-2.7

gpm 1.20.6

N.B. requires yacc/bison.

tar xjf ~/diet-pc-src/gpm-1.20.6.tar.bz2
cd gpm-1.20.6
./configure --prefix=/usr --sysconfdir=/etc --without-ncurses
# DIET-PC 3: configure with --prefix='' instead.
make -C src gpm LIBS=-lm
strip -R .note -R .comment src/gpm
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp src/gpm ~/diet-pc/shell/files/usr/sbin/
cd ..
rm -rf gpm-1.20.6

grub 0.97

The DIET-PC GRUB build uses Debian patches, primarily for the splash graphic feature. I have further modified GRUB with a patch by Sylvain Fourmanoit sourced from a bugtracker on Savannah (possibly still available here) to add a Vendor Class Identifier - "GRUBClient" - to its DHCP requests, so that you can configure DHCP servers to limit or customise responses to GRUB clients.

The grub_netdriver_list.txt file can be found in the DIET-PC source code tarball or separately here.

GRUB is specific to the x86 and x86_64 ports of DIET-PC. It is not 64-bit safe and must be compiled 32-bit. Nor is it gcc4-safe, apparently!

FIXME: add application of vendor class id patch.

tar xzf ~/diet-pc-src/grub-0.97.tar.gz
cd grub-0.97
gunzip -c ~/diet-pc-src/grub_0.97-31.diff.gz | patch -p1
sed -e '/^#/d' -e '/^$/d' debian/patches/00list | while read patch; do
    patch -p1 < debian/patches/$patch
bunzip2 -c ~/diet-pc-src/grub-0.97-3c90x_9058.patch.bz2 | patch -p1 -b
CC=gcc-2.95 CFLAGS=-Os ./configure --prefix='' --disable-auto-linux-mem-opt \
vi +57 netboot/main.c   # Fix needed for gcc 4.x:
			# change global variables bootp_data (line 57) and
			# end_of_rfc1533 (line 59) to non-static, by removing
			# the word "static" from the relevant lines
vi +3708 stage2/builtins.c	# Fix needed for gcc 2.x:
				# Enclose "char *tmp;" and the if statement
				# that follows it in a block (ie. { ... })
strip -R .note -R .comment grub/grub
mkdir -p ~/diet-pc/tools ~/diet-pc/tools-doc
mkdir -p ~/diet-pc/templates/grub/boot/grub
cp grub/grub ~/diet-pc/tools/
cp docs/ ~/diet-pc/tools-doc/
~/diet-pc/tools/man2txt docs/grub.8 >~/diet-pc/tools-doc/grub.txt
cp stage1/stage1 stage2/{stage2,e2fs_stage1_5,fat_stage1_5} \
cat >menu.lst <<EOF
default 0
fallback 1
timeout 0
title netboot
	dhcp --with-configfile
title fail
	halt --no-apm
mkdir -p ~/diet-pc/templates/netgrub/diet-pc/grub
unalias cp	# If required
while read SUFFIX EXTRA_ARGS; do
    make clean
    ./configure --prefix='' --disable-linux-auto-mem-opt --enable-diskless \
	    --enable-preset-menu=menu.lst ${EXTRA_ARGS}
    make -C netboot libdrivers.a
    make -C stage2 diskless
    make -C stage2 nbgrub
    make -C stage2 pxegrub
    cp stage2/nbgrub \
    cp stage2/pxegrub \
done < ~/diet-pc-src/grub_netdriver_list.txt
cd ..
rm -rf grub-0.97

hfsplus 1.0.4

hfsplus is specific to the PowerPC port of DIET-PC. Copies can be found at, although this no longer appears to be an authoritative page.

FIXME: This appears not to work for GCC 4.x.

tar xjf ~/diet-pc-src/hfsplus_1.0.4.src.tar.bz2
cd hfsplus-1.0.4
ln -s /usr/bin/libtool
ln -s /usr/share/libtool/
make -f Makefile.cvs
CC=gcc-3.4 ./configure --prefix=/usr --sysconfdir=/etc --disable-shared
vi +19 libhfsp/src/unicode.c	# Change "<linux/string.h>" to "<string.h>"
vi +51 src/glob.c		# Change "case NULL:" to "case '\0':"
vi src/hpmkdir.c		# Add "#include <errno.h>"
make -C libhfsp/src CFLAGS="$CFLAGS"
make -C src CFLAGS="$CFLAGS"
cd src
strip -R .note -R .comment hpcd hpcopy hpfsck hpls hpmkdir hpmount hppwd hprm \
mkdir -p ~/diet-pc/assembler_installer/files/usr/bin
mkdir -p ~/diet-pc/persistfs/files/sbin
cp hpcd hpcopy hpls hpmkdir hpmount hppwd hprm hpumount \
cp hpfsck ~/diet-pc/persistfs/files/sbin/fsck.hfsplus
cd ../..
rm -rf hfsplus-1.0.4

hfsutils 3.2.6

hfsutils is specific to the PowerPC port of DIET-PC.

tar xzf ~/diet-pc-src/hfsutils-3.2.6.tar.gz
cd hfsutils-3.2.6
./configure --prefix=/usr --sysconfdir=/etc
make -C hfsck
strip -R .note -R .comment hfsutil hfsck/hfsck
mkdir -p ~/diet-pc/assembler_installer/files/usr/bin
mkdir -p ~/diet-pc/persistfs/files/sbin
cp hfsutil ~/diet-pc/assembler_installer/files/usr/bin/
for link in hattrib hcd hcopy hdel hdir hformat hls hmkdir hmount hpwd \
	hrename hrmdir humount hvol; do
    ln -s hfsutil ~/diet-pc/assembler_installer/files/usr/bin/$link
cp hfsck/hfsck ~/diet-pc/persistfs/files/sbin/fsck.hfs
cd ..
rm -rf hfsutils-3.2.6

hiawatha 6.17.1

tar xzf ~/diet-pc-src/hiawatha-6.17.1.tar.gz
cd hiawatha-6.17.1
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl \
strip -R .note -R .comment hiawatha cgi-wrapper php-fcgi

ipkg 0.99.163

FIXME: patch to fix error output

FIXME: workarounds for incorrect HOST_CPU_STR default for armel and amd64

cvs -d login	# password is "anoncvs"
cvs -z3 -d co familiar/dist/ipkg
cd familiar/dist/ipkg/C
libtoolize --force --copy
automake -a -c
./configure --prefix='' --sysconfdir=/etc --datadir=/lib --disable-shared \
	--with-ipkglibdir=/var/lib --build=i386-dietpc-linux-gnu
vi Makefile libbb/Makefile	# Remove "-g" and "-O" from ALL_CFLAGS, add
				# $CFLAGS
strip -R .note -R .comment ipkg-cl
mkdir -p ~/diet-pc/shell/files/bin
cp ipkg-cl ~/diet-pc/shell/files/bin/ipkg
cd ../../../../..
rm -rf familiar

ipkg-utils 1.7


iptables 1.4.5

The build automation in this source bundle requires exact header files for the running kernel (e.g. apt-get install linux-headers-`uname -r`).

tar xjf ~/diet-pc-src/iptables-1.4.5.tar.bz2
cd iptables-1.4.5
./configure --prefix='' --enable-static --disable-shared
strip -R .note -R .comment iptables-multi
mkdir -p ~/diet-pc/shell/files/sbin
cp iptables-multi ~/diet-pc/shell/files/sbin/iptables
~/diet-pc/tools/man2txt iptables.8 >~/diet-pc/shell/iptables.txt
cd ..
rm -rf iptables-1.4.5

iscsitarget 1.4.18

tar xzf ~/diet-pc-src/iscsitarget-1.4.18.tar.gz
cd iscsitarget-1.4.18
vi usr/Makefile		# Remove -g from CFLAGS, change -O2 to $CFLAGS
make usr LIBS='-Wl,-Bstatic -L/usr/local/lib -lcrypto -Wl,-Bdynamic'
strip -R .note -R .comment usr/{ietd,ietadm}
#make kernel KSRC=/some/where

jpegsrc 6b

Appears as "libjpeg" on Freshmeat.

tar xzf ~/diet-pc-src/jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr --enable-shared
# (ARM and x86_64: make LIBTOOL=libtool)
strip -R .note -R .comment .libs/
mkdir -p ~/diet-pc/ica/files/usr/lib
mkdir -p ~/diet-pc/rfb/files/usr/lib
mkdir -p ~/diet-pc/xserver_xorg_vnc/files/usr/lib
mkdir -p ~/diet-pc/xserver_xvnc/files/usr/lib
cp .libs/ ~/diet-pc/ica/files/usr/lib/
cp .libs/ ~/diet-pc/rfb/files/usr/lib/
cp .libs/ ~/diet-pc/xserver_xorg_vnc/files/usr/lib/
cp .libs/ ~/diet-pc/xserver_xvnc/files/usr/lib/
cd ..
rm -rf jpeg-6b

kbd 1.15.1

If anyone can give me a convincing explanation as to why console-tools is superior to kbd, I'll consider using that instead. Mainstream Linux distros seem divided on this issue for no obvious reason.

tar xzf ~/diet-pc-src/kbd-1.15.1.tar.gz
cd kbd-1.15.1
./configure --prefix=/usr
make -C src setleds
strip -R .note -R .comment src/setleds
mkdir -p ~/diet-pc/shell/files/usr/bin
cp src/setleds ~/diet-pc/shell/files/usr/bin/
cd ..
rm -rf kbd-1.15.1

libdvdcss 1.2.9

tar xjf ~/diet-pc-src/libdvdcss-1.2.9.tar.bz2
cd libdvdcss-1.2.9
tar xjOf ~/diet-pc-src/xine-lib- \
	xine-lib- | patch -p1 -b
# If you have automake 1.10 or later you will need to replace the stupid
# lexical comparison in the bootstrap script with one that actually works:
# vi bootstrap	# Replace "if expr "$amvers ..." line with
		# if [ "`echo $amvers | cut -f2 -d.`" -lt 5 ]; then
./configure --disable-static
strip -R .note -R .comment src/.libs/
mkdir -p ~/diet-pc/mmedia_xine/files/usr/lib
cp src/.libs/ ~/diet-pc/mmedia_xine/files/usr/lib/
cd ..
rm -rf libdvdcss-1.2.9

lilo 22.8.0

LILO is specific to the x86 and x86_64 ports of DIET-PC.

FIXME: checkit may be unable to correctly identify gcc version.

N.B. requires bin86.

tar xzf ~/diet-pc-src/lilo-22.8.src.tar.gz
cd lilo-22.8
vi Makefile	# remove -g from CFLAGS assignment, change OPT=$CFLAGS
make all
strip -R .note -R .comment lilo
mkdir -p ~/diet-pc/tools ~/diet-pc/tools-doc
cp lilo ~/diet-pc/tools/
~/diet-pc/tools/man2txt manPages/lilo.8 >~/diet-pc/tools-doc/lilo.txt
~/diet-pc/tools/man2txt manPages/lilo.conf.5 >\
cd ..
rm -rf lilo-22.8

lpr 2006.11.04

FIXME: DIET-PC libwrap patch!

tar xzf ~/diet-pc-src/lpr_2006.11.04.tar.gz
cd lpr-2006.11.04
vi common_source/lp.h	# Add "#define O_NOFOLLOW	0400000"
make .CURDIR=.
strip -R .note -R .comment lpq/lpq lpr/lpr lprm/lprm lpc/lpc lpd/lpd \
mkdir -p ~/diet-pc/printserver/files/usr/bin \
	~/diet-pc/printserver/files/usr/sbin \
cp lpq/lpq lpr/lpr lprm/lprm ~/diet-pc/printserver/files/usr/bin/
cp lpc/lpc lpd/lpd ~/diet-pc/printserver/files/usr/sbin/
cp filters/lpf ~/diet-pc/printserver/files/usr/libexec/lpfilters/
~/diet-pc/tools/man2txt lpc/lpc.8 >~/diet-pc/printserver/lpc.txt
~/diet-pc/tools/man2txt lpd/lpd.8 >~/diet-pc/printserver/lpd.txt
~/diet-pc/tools/man2txt lprm/lprm.1 >~/diet-pc/printserver/lprm.txt
~/diet-pc/tools/man2txt lpr/lpr.1  >~/diet-pc/printserver/lpr.txt
~/diet-pc/tools/man2txt debian/printcap.5 \
cd ..
rm -rf lpr-2006.11.04

Linux kernel

These build instructions are for the generic_kernel_586+ package, which is intended as a quick-start demonstration, not production use. You should treat these instructions merely as a starting point for building your own custom kernel, which you should install to ~/diet-pc/kernel, or some other directory containing the word "kernel" that is distinct from ~/diet-pc/generic_kernel_586+.

tar xjf ~/diet-pc-src/linux-2.6.23.tar.bz2
mv linux-2.6.23 linux-
cd linux-
bunzip2 -c ~/diet-pc-src/patch- | patch -p1 -E
gunzip -c ~/diet-pc-src/unionfs-2.1.11_for_2.6.23.9.diff.gz | patch -p1 -E
bunzip2 -c ~/diet-pc-src/linux-2.6.23-squashfs2.2-r2.patch.bz2 | patch -p1 -E
bunzip2 -c ~/diet-pc-src/bootsplash-3.1.6-2.6.23.diff.bz2 | patch -p1 -E
# (PPC, ARM and MIPSEL: don't apply this patch, bootsplash doesn't work on
# non-x86 hardware because it doesn't support VESA)
bunzip2 -c \
	~/diet-pc-src/linux-2.6.23-ieee80211_txctl_long_retry_limit.patch.bz2 \
	| patch -p1 -E
cp ~/diet-pc-src/config.generic_kernel_586+ .config
					# or any other kernel config
					# file that you wish to use as
					# an initial template
make menuconfig				# Modify as necessary, then save and
					# exit.  If your config template comes
					# from an older kernel, pay close
					# attention to items marked "(NEW)".
make bzImage ROOT_DEV=''
# (ARM: zImage instead of bzImage)
# (PPC: vmlinux instead of bzImage)
mkdir -p ~/diet-pc/generic_kernel_586+
cp .config ~/diet-pc/generic_kernel_586+/config.generic_586+/
cp ~/diet-pc/generic_kernel_586+/
cp arch/i386/boot/bzImage ~/diet-pc/generic_kernel_586+/
# (x86_64: copy arch/x86_64/boot/zImage instead of arch/i386/boot/bzImage)
# (ARM: copy arch/arm/boot/zImage instead of arch/i386/boot/bzImage)
# (PPC: copy vmlinux instead of arch/i386/boot/bzImage)
make modules
make modules_install INSTALL_MOD_PATH=~/diet-pc/generic_kernel_586+/files
ln -s `pwd`/include ~/diet-pc/generic_kernel_586+/include
cd ..
# Leave the kernel tree intact - it will be needed to build out-of-tree modules.
tar xzf ~/diet-pc-src/rt2x00-cvs-2007082600.tar.gz
cd rt2x00-cvs-2007082600
bunzip2 -c ~/diet-pc-src/rt2x00-cvs-2007082600-dietpc-patch.bz2 | patch -p1 -b
make KERNDIR=/usr/src/linux-
mkdir ~/diet-pc/generic_kernel_586+/files/lib/modules/
cp *.ko ~/diet-pc/generic_kernel_586+/files/lib/modules/
pushd ~/diet-pc/generic_kernel_586+
depmod -AeF -b files
cd ..
rm -rf rt2x00-cvs-2007082600

lm_sensors 2.10.6

Prerequisite: you must compile and install the rrdtool and libsysfs (sysfsutils) libraries first.

These instructions only are only for compiling user-space tools. Compiling kernel modules is your problem :-).

DIET-PC uses lm_sensors 3.x, which is for 2.6 kernels only. 3.x compiles similarly, but has no libsysfs dependency, and has become

tar xzf ~/diet-pc-src/lm_sensors-2.10.6.tar.gz
cd lm_sensors-2.10.6
make user PROG_EXTRA=sensord CFLAGS="$CFLAGS"
gcc -shared -Wl,-soname, -o lib/ lib/*.lo \
	-Wl,-Bstatic -lsysfs -Wl,-Bdynamic -lm
strip -R .note -R .comment prog/sensors/sensors prog/sensord/sensord \
mkdir -p ~/diet-pc/sensors/files/etc
mkdir -p ~/diet-pc/sensors/files/usr/{bin,lib,sbin}
cp etc/ ~/diet-pc/sensors/files/etc/sensors.conf
cp prog/sensors/sensors ~/diet-pc/sensors/files/usr/bin/
cp prog/sensord/sensord ~/diet-pc/sensors/files/usr/sbin/
cp lib/ ~/diet-pc/sensors/files/usr/lib/
~/diet-pc/tools/man2txt prog/sensors/sensors.1 >\
~/diet-pc/tools/man2txt prog/sensord/sensord.8 >\
cd ..
rm -rf lm_sensors-2.10.6

lp_server 1.1.6

lp_server was originally an LprNG contrib, but apparently can now only be found on the LTSP project's downloads page.

You may wish to consider using p910nd instead.

tar xzf ~/diet-pc-src/lp_server-1.1.6.tar.gz
cd lp_server-1.1.6
gunzip -c ~/diet-pc-src/lp_server-1.1.6-dietpc.patch.gz | patch -p1 -b
./configure --prefix=/usr
make LDFLAGS='-lwrap'
strip -R .note -R .comment src/lp_server
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp src/lp_server ~/diet-pc/shell/files/usr/sbin/
~/diet-pc/tools/man2txt man/lp_server.8 >~/diet-pc/shell/lp_server.txt
cd ..
rm -rf lp_server-1.1.6

mac-fdisk 0.1-14 (a.k.a. pdisk 0.4a2)

mac-disk is specific to the PowerPC port of DIET-PC. It is maintained by the Debian distribution (

tar xzf ~/diet-pc-src/mac-fdisk_0.1.orig.tar.gz
cd mac-fdisk-0.1.orig
gunzip -c ~/diet-pc-src/mac-fdisk_0.1-14.diff.gz | patch -p1 -b
make pdisk
strip -R .note -R .comment pdisk
mkdir -p ~/diet-pc/assembler_installer/files/sbin
cp pdisk ~/diet-pc/assembler_installer/files/sbin/mac-fdisk
~/diet-pc/tools/man2txt \
cd ..
rm -rf mac-fdisk-0.1.orig

madplay 0.15.2b
tar xzf ~/diet-pc-src/madplay-0.15.2b.tar.gz
cd madplay-0.15.2b
./configure --prefix=/usr --sysconfdir=/etc --disable-nls --without-alsa \
gcc -o madplay *.o -lm -lz -Wl,-Bstatic -lmad -lid3tag -Wl,-Bdynamic
strip -R .note -R .comment madplay

make 3.81

tar xjf ~/diet-pc-src/make-3.81.tar.bz2
cd make-3.81
./configure --prefix=/usr --disable-nls
# DIET-PC 3: omit Makefile hack, is now standard
vi Makefile	# change "LIBS = -Wl,-Bstatic -lrt -Wl,-Bdynamic"
		# on x86_64, this trick won't work, so don't bother - you will
		# have to add to assembler_installer/files/lib
		# or shell/files/lib
strip -R .note -R .comment make
mkdir -p ~/diet-pc/assembler_installer/files/usr/bin
cp make ~/diet-pc/assembler_installer/files/usr/bin/
cd ..
rm -rf make-3.81

mdadm 2.6.9

tar xjf ~/diet-pc-src/mdadm-2.6.9.tar.bz2
cd mdadm-2.6.9
strip -R .note -R .comment mdadm

module-init-tools 3.9

Not on Freshmeat at present, for some reason. You can find it on and its mirrors, at more-or-less the same location as modutils.

tar xjf ~/diet-pc-src/module-init-tools-3.9.tar.bz2
cd module-init-tools-3.9
bunzip2 -c ~/diet-pc-src/module-init-tools-3.9-dietpc-patch.bz2 | patch -p1 -b
./configure --prefix='' --enable-zlib
cd build
strip -R .note -R .comment depmod insmod lsmod modinfo modprobe rmmod
mkdir -p ~/diet-pc/shell/files/sbin
cp depmod insmod lsmod modinfo modprobe rmmod ~/diet-pc/shell/files/sbin/
cd ../..
rm -rf module-init-tools-3.9

modutils 2.4.27

tar xjf ~/diet-pc-src/modutils-2.4.27.tar.bz2
cd modutils-2.4.27
# For GCC 4.x, you'll need to work around some sloppy coding using this patch:
#bunzip2 -c ~/diet-pc-src/modutils-2.4.27-gcc4-patch.bz2 | patch -p1 -b
./configure --enable-combined --disable-combined-ksyms \
	--disable-combined-kallsyms --disable-compat-2-0 \
	--disable-common-i386 --enable-zlib --with-dynamic-zlib
strip -R .note -R .comment depmod/depmod insmod/insmod insmod/modinfo
mkdir -p ~/diet-pc/shell/files/sbin
cp depmod/depmod ~/diet-pc/shell/files/sbin/depmod.old
cp insmod/insmod ~/diet-pc/shell/files/sbin/insmod.old
cp insmod/modinfo ~/diet-pc/shell/files/sbin/modinfo.old
ln -s insmod.old ~/diet-pc/shell/files/sbin/lsmod.old
ln -s insmod.old ~/diet-pc/shell/files/sbin/modprobe.old
ln -s insmod.old ~/diet-pc/shell/files/sbin/rmmod.old
cd ..
rm -rf modutils-2.4.27


N.B. needs libgdbm and libid3tag.

tar xzf ~/diet-pc-src/mt-daapd-
cd mt-daapd-
vi +3870 configure		# Delete the line that adds "-g" to CPPFLAGS
./configure --prefix=/usr --sysconfdir=/etc
cd src
gcc -o mt-daapd *.o -lpthread -lz -Wl,-Bstatic -lgdbm -lid3tag -Wl,-Bdynamic
strip -R .note -R .comment mt-daapd

mtd-utils 20080530

tar xzf ~/diet-pc-src/mtd-utils-git300508.tar.gz
cd mtd-utils
vi Makefile			# Substitute $CFLAGS for -O2 in OPTFLAGS;
				# remove "-g" from targets (three occurences)
strip -R .note -R .comment docfdisk flashcp flash_eraseall flash_lock \
	flash_unlock ftl_format mtd_debug nandtest nandwrite nftl_format \

mtools 4.0.11

tar xjf ~/diet-pc-src/mtools-4.0.11.tar.bz2
cd mtools-4.0.11
bunzip2 -c ~/diet-pc-src/mtools-3.9.9-dietpc-patch.bz2 | patch -p1 -b
./configure --prefix=/usr --sysconfdir=/etc --enable-floppyd
make floppyd
gcc -o floppyd floppyd.o -L/usr/X11R6/lib -lX11 -lwrap
strip -R .note -R .comment floppyd
mkdir -p ~/diet-pc/storageserver/files/usr/X11R6/bin
cp floppyd ~/diet-pc/storageserver/files/usr/X11R6/bin/
~/diet-pc/tools/man2txt floppyd.1 >~/diet-pc/storageserver/floppyd.txt
cd ..
rm -rf mtools-4.0.11

NAS 1.9.2

This suite of programs leverages X11 libraries and build automation. You need at least flex, xutils-dev, libxt-dev, libxaw7-dev, and all of their dependencies in order to compile it.

tar xzf ~/diet-pc-src/nas-1.9.2.src.tar.gz
cd nas-1.9.2
make World CDEBUGFLAGS="$CFLAGS -fno-strict-aliasing"
strip -R .note -R .comment server/nasd
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp server/nasd ~/diet-pc/shell/files/usr/sbin/
~/diet-pc/tools/man2txt server/ >~/diet-pc/shell/nasd.txt
~/diet-pc/tools/man2txt server/ >\
cd ..
rm -rf nas-1.9.2

nbd 1.4

We use this obsolete version of nbd because it creates a much smaller nbd-server binary. Newer versions add features that we don't need, and link against very large libraries, mostly for programmer convenience.

The distribution can be downloaded from the legacy NBD page.

FIXME: DIET-PC libwrap patch!

tar xzf ~/diet-pc-src/nbd.14.tar.gz
cd nbd
./configure --prefix=/usr --sysconfdir=/etc
vi nbd-server.c		# Comment out definition and undefinition of _IO macro
			# (lines 28, 32), change llseek to lseek64 (line 162)
# (ARM/PPC/x86_64: vi nbd-client.c, comment out "#include <asm/page.h>")
strip -R .note -R .comment nbd-server
mkdir -p ~/diet-pc/storageserver/files/usr/sbin
cp nbd-server ~/diet-pc/storageserver/files/usr/sbin/
cd ..
rm -rf nbd

nbd 2.9.13

We use nbd-client from this version, because it contains significant bug fixes and feature additions compared with version 1.4, at negligible size cost.

This (up-to-date) version of nbd can be found at

N.B. requires libglib2.0-dev.

tar xjf ~/diet-pc-src/nbd-2.9.13.tar.bz2
cd nbd-2.9.13
./configure --prefix=/usr --sysconfdir=/etc --enable-syslog
make nbd_server_LDADD='-Wl,-Bstatic -lglib-2.0 -Wl,-Bdynamic'
strip -R .note -R .comment nbd-client
mkdir -p ~/diet-pc/shell/files/sbin
cp nbd-client ~/diet-pc/shell/files/sbin/
~/diet-pc/tools/man2txt nbd-client.8 >~/diet-pc/shell/nbd-client.txt
cd ..
rm -rf nbd-2.9.13

netboot 0.10.2

netboot is specific to the x86 and x86_64 ports of DIET-PC.

tar xzf ~/diet-pc-src/netboot-0.10.2.tar.gz
cd netboot-0.10.2
./configure --prefix=/usr --sysconfdir=/etc --without-berkeley-db \
strip -R .note -R .comment mknbi-linux/mknbi
mkdir -p ~/diet-pc/tools ~/diet-pc/tools-doc
cp mknbi-linux/mknbi ~/diet-pc/tools/mknbi-linux
~/diet-pc/tools/man2txt mknbi-linux/ >\
cd ..
rm -rf netboot-0.10.2

nfs-utils 1.2.0

tar xjf ~/diet-pc-src/nfs-utils-1.2.0.tar.bz2
cd nfs-utils-1.2.0
./configure --prefix=/usr --sysconfdir=/etc --disable-nfsv4 --disable-gss \
	--disable-uuid --with-statduser=nobody --disable-shared \
rm -f utils/exportfs/exportfs
make -C utils/exportfs exportfs LIBWRAP=
strip -R .note -R .comment utils/exportfs/exportfs utils/nfsd/nfsd \
	utils/mountd/mountd utils/mount/mount.nfs

ntpclient 2007_365

Ntpclient's home page is

tar xzf ~/diet-pc-src/ntpclient_2007_365.tar.gz
cd ntpclient-2007
vi Makefile	# delete the line "CFLAGS += -O2"
strip -R .note -R .comment ntpclient
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp ntpclient ~/diet-pc/shell/files/usr/sbin/
cd ..
rm -rf ntpclient-2007

numlock 2.1.1

This utility is from the Mandrake Linux distribution. Source code can be found via

rpm2cpio ~/diet-pc-src/numlock-2.1.1-2mdv2009.0.src.rpm | cpio -i \
tar xjf numlock-2.1.1.tar.bz2
cd numlock-2.1.1
gcc -c $CFLAGS -Wall -I/usr/X11R6/include enable_X11_numlock.c
gcc -o enable_X11_numlock enable_X11_numlock.o -L/usr/X11R6/lib -lX11 -lXext \
	-Wl,-Bstatic -lXtst -Wl,-Bdynamic
strip -R .note -R .comment enable_X11_numlock
mkdir -p ~/diet-pc/xcore/files/usr/X11R6/bin
cp enable_X11_numlock ~/diet-pc/xcore/files/usr/X11R6/bin/
cd ..
rm -rf numlock-2.1.1 numlock-2.1.1.tar.bz2

openchrome SVN

OpenChrome is a video driver for Via embedded chipsets that is more capable and supports newer hardware than the Unichrome driver bundled with Xorg. I use this because I happen to have one of these newer chipsets (CN700). Use of this driver is entirely optional (if you don't use it, your xserver_xorg_via package will be built using the bundled Xorg driver instead).

This driver will need access to your Xorg (xc) tree, so build Xorg first (and don't clean up afterwards).

FIXME: This is the procedure for Xorg 6.9 only, need update for Xorg 7.x using 0.2.902 official (Xorg 7.4).

svn co openchrome
cd openchrome
bunzip2 -c ~/diet-pc-src/via_vt1625_PAL.diff.bz2 | patch -p1 -b
	# This is David Vidrie's patch, as advertised on the openchrome-users
	# mailing list in December 2005, available at
	# Why it hasn't been committed to SVN yet is a mystery!
cd libxvmc
xmkmf ~/xc	# Or wherever your Xorg build tree is located.
strip -R .note -R .comment
mkdir -p ~/diet-pc/xserver_xorg_via/files/usr/X11R6/lib
cp \
cd ../unichrome
xmkmf ~/xc	# Or wherever your Xorg build tree is located.
strip -R .note -R .comment
mkdir -p ~/diet-pc/xserver_xorg_via/files/usr/X11R6/lib/modules/drivers
cp ~/diet-pc/xserver_xorg_via/files/usr/X11R6/lib/modules/drivers/
~/diet-pc/tools/man2txt via._man >~/diet-pc/xserver_xorg_via/via.txt
cd ../..
rm -rf openchrome

opendchub 0.7.15

N.B. --enable-switch_user doesn't work if libcap-dev is not installed.

tar xzf ~/diet-pc-src/opendchub-0.7.15.tar.gz
cd opendchub-0.7.15
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
	--enable-switch_user --disable-perl
rm src/opendchub
make -C src opendchub LIBS="-lcrypt -L/usr/local/lib -Wl,-Bstatic -lcap \
	-lcrypto -Wl,-Bdynamic"
strip -R .note -R .comment src/opendchub

open-iscsi 2.0-871

tar xzf ~/diet-pc-src/open-iscsi-2.0-871.tar.gz
cd open-iscsi-2.0-871
vi utils/Makefile utils/sysdeps/Makefile # Remove "-O2" and "-g" from CFLAGS
strip -R .note -R .comment usr/{iscsiadm,iscsid}

openmotif 2.2.4

OpenMotif is a (regrettable) necessity for the wfcmgr component of ICA Client version 9.0 and later. There is no ICA Client 9 available for PowerPC or ARM Linux, so at present there is no point in compiling OpenMotif for these architectures.

OpenMotif's official homepage is very outdated. For all intents and purposes, the real home page is actually OpenMotif is shunned by many Linux distros because of its license restrictions, but at present it is the only free implementation that provides the full Motif 2.0 compliance that Linux ICA Client 9 needs.

OpenMotif 2.2.4 contains important security fixes, but there isn't a generic official source tarball, so we'll have to extract it from one of the distro-specific SRPMs instead.

Ensure that you have xbitmaps and all of the xorg-dev group installed before trying to compile this.

rpm2cpio ~/diet-pc-src/openmotif-2.2.4-0.1.src.rpm | cpio -i \
tar xzf openmotif-2.2.4.tar.gz
cd openmotif-2.2.4
amvers=`automake --version | awk '{print $NF; exit}' | cut -f1-2 -d.`
# OpenMotif 2.3.1:
#for amfile in compile config.guess config.sub depcomp install-sh missing \
#	mkinstalldirs; do
for amfile in missing mkinstalldirs depcomp install-sh; do
    ln -sf /usr/share/automake-$amvers/$amfile
# OpenMotif 2.3.1:
#rm -f
#ln -s /usr/share/libtool/
#./configure --prefix=/usr --sysconfdir=/etc/X11 --disable-static \
#	--disable-utf8 --disable-xft --disable-png --disable-jpeg
./configure --prefix=/usr/X11R6 --disable-static
# DIET-PC 3: use --prefix=/usr
# FIXME: remove bogus Xext dependency
vi lib/Xm/Makefile	# Remove "-g" from CFLAGS, "-lXext" from libXm_la_LIBADD
make -C lib/Xm
strip -R .note -R .comment lib/Xm/.libs/
# OpenMotif 2.3.1:
mkdir -p ~/diet-pc/ica/extras
cp lib/Xm/.libs/ ~/diet-pc/ica/extras/
cd ..
rm -rf openmotif-2.2.4 openmotif-2.2.4.tar.gz

openssh 5.1p1

To reduce binary size, compile and install OpenSSL 0.9.7 (space optimised) first.

tar xzf ~/diet-pc-src/openssh-5.1p1.tar.gz
cd openssh-5.1p1
./configure --prefix=/usr --sysconfdir=/etc --with-tcp-wrappers \
	--disable-wtmp --disable-lastlog --with-ssl-dir=/usr/local \
	--with-md5-passwords --with-ipaddr-display --with-ipv4-default \
# Or "--with-ssl-dir=/usr" to use your host's OpenSSL libraries, if you prefer.
# (x86_64: use --build=x86_64-dietpc-linux-gnu)
# (PPC: use --build=powerpc-dietpc-linux-gnu)
# (ARM: use --build=arm-dietpc-linux-gnu)
# (ARMEL: use --build=arm-dietpc-linux-gnueabi)
# (MIPSEL: use --build=mipsel-dietpc-linux-gnu)
# (DIET-PC 3 x86: use --build=i486-dietpc-linux-gnu)
# Note to self: for opensc support, also need to add "-lopensc -lopenct
# -lscconf -lltdl" to the list of statically linked libs, and -lpcsclite to
# dynamically linked libs, for ssh and ssh-keygen (adds ~450k to file size)
rm -f ssh scp ssh-keygen
make ssh ssh-keygen \
	LIBS='-lresolv -ldl -lz -L/usr/local/lib -Wl,-Bstatic -lcrypto -Wl,-Bdynamic'
make scp LIBS='-lresolv -L/usr/local/lib -Wl,-Bstatic -lcrypto -Wl,-Bdynamic'
strip -R .note -R .comment ssh scp ssh-keygen
mkdir -p ~/diet-pc/ssh/files/usr/bin ~/diet-pc/ssh/files/etc
mkdir -p ~/diet-pc/ssh/extras
cp moduli ~/diet-pc/ssh/files/etc/
cp ssh scp ~/diet-pc/ssh/files/usr/bin/
chmod 4755 ~/diet-pc/ssh/files/usr/bin/ssh
ln -s ssh ~/diet-pc/ssh/files/usr/bin/slogin
cp ssh-keygen ~/diet-pc/ssh/extras/
~/diet-pc/tools/man2txt scp.1 >~/diet-pc/ssh/scp.txt
~/diet-pc/tools/man2txt ssh.1 >~/diet-pc/ssh/ssh.txt
~/diet-pc/tools/man2txt ssh_config.5 >~/diet-pc/ssh/ssh_config.txt
~/diet-pc/tools/man2txt ssh-keygen.1 >~/diet-pc/ssh/extras/ssh-keygen.txt
cd ..
rm -rf openssh-5.1p1

openssl 0.9.7m

Your host platform no doubt provides OpenSSL libraries that you can link against. However, there are some advantages in building a custom version. Firstly, OpenSSL 0.9.7 is significantly smaller than OpenSSL 0.9.8. Secondly, this version may be more up-to-date with regard to security fixes than your host's. And thirdly, unlike your host's libraries, these will actually run on an 80386 (because we remove "-m486").

This library isn't installed in DIET-PC directly, but it is linked against by OpenSSH, Rdesktop, etc. Programs that require OpenSSL typically only use a small subset of the library's functions, so unless you have several programs that use encryption, it is more space efficient to link each such binary against a static library.

FIXME: add Configure tweak to force space optimisation.

tar xzf ~/diet-pc-src/openssl-0.9.7m.tar.gz
cd openssl-0.9.7m
vi Configure	# Remove -m486 from "linux-elf" section (x86 DIET-PC 2 only)
./config --prefix=/usr/local --openssldir=/usr/local/openssl shared 386
# (x86_64/PPC/ARM/MIPSEL/DIET-PC 3: omit "386")
sudo make install
cd ..
rm -rf openssl-0.9.7m

php 5.2.11

tar xjf ~/diet-pc-src/php-5.2.11.tar.bz2
cd php-5.2.11
./configure  --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var \
	--without-apache --without-apxs2 --disable-cli --enable-cgi \
	--enable-fastcgi --enable-force-cgi-redirect \
	--with-config-file-path=/etc/php/php.ini --disable-ipv6 --disable-all \
	--with-pcre-regex --enable-ctype --without-iconv --enable-json \
	--enable-libxml --enable-posix --enable-sockets --enable-session \
	--enable-spl --with-sqlite --enable-sqlite-utf8 --enable-tokenizer \
	--enable-xml --with-exec-dir=/usr/local/php/bin
make EXTRA_LIBS='-lresolv -lm -ldl -lnsl -lcrypt -lz /usr/lib/libxml2.a'
strip -R .note -R .comment sapi/cgi/php-cgi

pciutils 3.1.4

The authoritative site for the pcimodules patch ( seems to be permanently unreachable, and copies can be difficult to locate. I have updated the original patch (for pciutils 2.1.11) for pciutils 3.0.0; this patch is available from the DIET-PC downloads area.

tar xjf ~/diet-pc-src/pciutils-3.1.4.tar.bz2
cd pciutils-3.1.4
bunzip2 -c ~/diet-pc-src/pciutils-3.0.0-pcimodules-1.patch.bz2 | patch -p1 -b
make PREFIX=/usr OPT="$CFLAGS" IDSDIR=/usr/share/misc
strip -R .note -R .comment pcimodules lspci
mkdir -p ~/diet-pc/shell/files/sbin
mkdir -p ~/diet-pc/shell/extras
cp pcimodules ~/diet-pc/shell/files/sbin/
cp lspci pci.ids.gz ~/diet-pc/shell/extras/
~/diet-pc/tools/man2txt lspci.8 >~/diet-pc/shell/extras/lspci.txt
cd ..
rm -rf pciutils-3.1.4

pmac-utils 2.1

pmac-utils is specific to the PowerPC port of DIET-PC. It is part of the Yellow Dog Linux distribution, and is available from .

rpm2cpio ~/diet-pc-src/pmac-utils-2.1-5.ydl.3.src.rpm | cpio -i \
tar xzf pmac-utils-2.1.tar.gz
cd pmac-utils-2.1
vi Makefile	# Removed "-g -O2" from CFLAGS, add $CFLAGS
# N.B. you'll need linuxdoc-tools and its various tetex dependencies installed
# in order for sgml2txt to work.
strip -R .note -R .comment nvsetenv
mkdir -p ~/diet-pc/assembler_installer/files/sbin
cp nvsetenv ~/diet-pc/assembler_installer/files/sbin/
~/diet-pc/tools/man2txt nvsetenv.8 \
cd ..
rm -rf pmac-utils-2.1

portmap 6.0

tar xzf ~/diet-pc-src/portmap-6.0.tgz
cd portmap_6.0
vi Makefile	# Substitute FACILITY=LOG_AUTHPRIV
vi pmap_check.[ch]	# Remove '__attribute ((visibility ("hidden")))' from
			# declarations of verboselog, deny_severity and
			# allow_severity (such that they are just simple
			# integers)
strip -R .note -R .comment portmap
mkdir -p ~/diet-pc/remotefs/files/sbin
cp portmap ~/diet-pc/remotefs/files/sbin/
cd ..
rm -rf portmap_6.0

qvwm 1.1.12-9-IKu

tar xzf ~/diet-pc-src/qvwm-1.1.12-9-IKu.tar.gz
cd qvwm-1.1.12-9-IKu
# DIET-PC 3: configure with --prefix=/usr --without-alsa --without-esd
# --without-imlib --with-qvwmdir=/etc/qvwm --with-snddir=/usr/share/qvwm/sounds
# --with-imgdir=/usr/share/qvwm/images
CXX=g++-2.95 ./configure --prefix=/opt/qvwm --without-alsa --without-esd \
vi config.h			# Comment out definition of USE_XSMP
vi src/		# Add "#include "
vi src/Makefile			# Add "-lXpm" to LIBS
vi src/		# Declare "KeySym released" at line 224, and
				# change line 332 such that it is an
				# assignment rather than an initialiser
cd src
gcc-2.95 -o qvwm *.o -L/usr/X11R6/lib -lXext -lX11 -lXpm -Wl,-Bstatic -lXss \
	-lstdc++ -Wl,-Bdynamic
strip -R .note -R .comment qvwm qv_deanimate
mkdir -p ~/diet-pc/qvwm/files/opt/qvwm/bin ~/diet-pc/qvwm/extras
cp qvwm ~/diet-pc/qvwm/files/opt/qvwm/bin/
cp qv_deanimate ~/diet-pc/qvwm/extras/
cd ..
mkdir -p ~/diet-pc/qvwm/files/opt/qvwm/share/qvwm/{images,sounds}
cp images/*.xpm ~/diet-pc/qvwm/files/opt/qvwm/share/qvwm/images/
cp sounds/chimes.wav ~/diet-pc/qvwm/files/opt/qvwm/share/qvwm/sounds/
cp rc/system.qvwmrc rc/default.qvwm-theme \
cd ..
rm -rf qvwm-1.1.12-9-IKu

rdesktop 1.6.0

tar xzf ~/diet-pc-src/rdesktop-1.6.0.tar.gz
cd rdesktop-1.6.0
bunzip2 -c ~/diet-pc-src/rdesktop-1.5.0-dietpc-patch.bz2 | patch -p1 -b
./configure --prefix=/usr/X11R6 --with-openssl=/usr/local --with-sound=oss \
# Or "--with-openssl=/usr" if you want to use your platform's native libraries.
# DIET-PC 3: --prefix=/usr instead
strip -R .note -R .comment rdesktop
mkdir -p ~/diet-pc/rdp/files/usr/X11R6/bin ~/diet-pc/rdp/extras
mkdir -p ~/diet-pc/rdp/files/usr/X11R6/share/rdesktop/keymaps
cp rdesktop ~/diet-pc/rdp/files/usr/X11R6/bin/
cp keymaps/{common,modifiers,en-us} \
	# or substitute the appropriate keymap for your locale for "en-us"
cp -r keymaps ~/diet-pc/rdp/extras/
rm -rf ~/diet-pc/rdp/extras/keymaps/{common,modifiers,convert-map}
~/diet-pc/tools/man2txt doc/rdesktop.1 >~/diet-pc/rdp/rdesktop.txt
cd ..
rm -rf rdesktop-1.6.0

replimenu 0.9

tar xzf ~/diet-pc-src/replimenu-0.9.tar.gz
cd replimenu-0.9
vi configuration	# change "CFLAGS=-Wall -Wshadow $CFLAGS", "PREFIX=/usr"
strip -R .note -R .comment src/replimenu
mkdir -p ~/diet-pc/shell/files/usr/bin
cp src/replimenu ~/diet-pc/shell/files/usr/bin/
~/diet-pc/tools/man2txt man/replimenu.1 >~/diet-pc/shell/replimenu.txt
cd ..
rm -rf replimenu-0.9


This code is no longer supported, but still provides better functionality than supported alternatives (eg. RealVNC's x0vncserver). The source code can be found at

The xclass library is a prerequisite for rfb.

To avoid a huge binary, you should compile this with the oldest version of g++/gcc available on your platform.

tar xzf ~/diet-pc-src/rfb-
cd rfb-
bunzip2 -c ~/diet-pc-src/rfb- | patch -p1 -b
vi {lib,x0rfbserver}/Makefile	# substitute $CXXFLAGS for "-O3" in CXXFLAGS
cd lib
make CXX=g++-2.95
cd ../x0rfbserver
vi +501		# Change "size_t" to "socklen_t"
make CXX=g++-2.95		# this will probably fail, but don't worry
gcc-2.95 -o x0rfbserver *.o ../lib/librfb.a -lz -lm -L/usr/X11R6/lib \
	-L/usr/local/lib -lXext -lX11 -lXpm -Wl,-Bstatic -lxclass -lXtst \
	-lstdc++ -Wl,-Bdynamic -lwrap	# For gcc3 or later add -static-libgcc
strip -R .note -R .comment x0rfbserver
mkdir -p ~/diet-pc/rfbserver/files/usr/X11R6/bin
cp x0rfbserver ~/diet-pc/rfbserver/files/usr/X11R6/bin/
cd ../..
rm -rf rfb-

rrdtool 1.0.50

A prerequisite for lm_sensors. We specifically want the obsolete 1.0.x version because it's smaller. It's very unlikely that this is available for your platform.

tar xzf ~/diet-pc-src/rrdtool-1.0.50.tar.gz
cd rrdtool-1.0.50
./configure --prefix=/usr/local --sysconfdir=/etc
sudo mkdir -p /usr/local/lib/perl
sudo make install
cd ..
rm -rf rrdtool-1.0.50

rrshd 1.1.1

tar xzf ~/diet-pc-src/rrshd-1.1.1.tar.gz
cd rrshd
vi Makefile	# substitute $CFLAGS for "-O2" in CFLAGS
		# for DIET-PC 3, change /usr/X11R6/bin to /usr/local/bin in
strip -R .note -R .comment in.rrshd
mkdir -p ~/diet-pc/shell/files/usr/sbin
cp in.rrshd ~/diet-pc/shell/files/usr/sbin/
cd ..
rm -rf rrshd

rsync 3.0.6

tar xzf ~/diet-pc-src/rsync-3.0.6.tar.gz
cd rsync-3.0.6
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
	--disable-ipv6 --disable-iconv --with-included-popt
make LIBS='-Wl,-Bstatic -lattr -lacl -Wl,-Bdynamic'
strip -R .note -R .comment rsync

rxvt 2.7.10

tar xzf ~/diet-pc-src/rxvt-2.7.10.tar.gz
cd rxvt-2.7.10
./configure --prefix=/usr/X11R6 --enable-xterm-scroll --enable-xgetdefault \
	--enable-mousewheel --enable-smart-resize --enable-256-color \
	--enable-24bit --disable-backspace-key --disable-delete-key \
# DIET-PC 3: use --prefix=/usr instead.
vi +1325 src/command.c	# Change type of "upordown" to "signed char"
# DIET-PC 3 only:
#vi src/feature.h	# Change X11USRLIBDIR to /usr/lib
strip -R .note -R .comment src/rxvt
mkdir -p ~/diet-pc/xcore/extras
cp src/rxvt ~/diet-pc/xcore/extras/
cd ..
rm -rf rxvt-2.7.10

samba 1.9.18p10

tar xzf ~/diet-pc-src/samba-1.9.18p10.tar.gz
cd samba-1.9.18p10
bunzip2 -c ~/diet-pc-src/samba-1.9.18p8-dietpc-patch.bz2 | patch -p1 -b
cd source
vi Makefile	# Change "FLAGS1=$CFLAGS -DSYSLOG"
# DIET-PC 3: Change LIBDIR=/etc/samba and CODEPAGEDIR=/usr/lib/samba/codepages
# also
strip -R .note -R .comment smbd nmbd smbpasswd
mkdir -p ~/diet-pc/smbserver/files/usr/sbin
cp smbd nmbd ~/diet-pc/smbserver/files/usr/sbin/
# Better idea is to use codepages from Samba 2.x (see below).
#mkdir -p ~/diet-pc/smbserver/extras/codepages
#for page in 437 737 850 852 861 932 866 949 950 936; do
#	./make_smbcodepage c $page codepage_def.$page \
#		~/diet-pc/smbserver/extras/codepages/codepage.$page
#mkdir -p ~/diet-pc/smbserver/files/usr/lib/codepages
#cp ~/diet-pc/smbserver/extras/codepages/codepage.850 \
#	~/diet-pc/smbserver/files/usr/lib/codepages/
cp smbpasswd ~/diet-pc/smbserver/extras/
cd ..
~/diet-pc/tools/man2txt docs/smbd.8 >~/diet-pc/smbserver/smbd.txt
~/diet-pc/tools/man2txt docs/nmbd.8 >~/diet-pc/smbserver/nmbd.txt
~/diet-pc/tools/man2txt docs/smb.conf.5 >~/diet-pc/smbserver/smb.conf.txt
cd ..
rm -rf samba-1.9.18p10

samba 2.2.12

tar xzf ~/diet-pc-src/samba-2.2.12.tar.gz
cd samba-2.2.12/source
# (MIPSEL: cp /usr/share/automake-*/config.guess .)
bunzip2 -c ~/diet-pc-src/samba-2.2.12-dietpc-patch.bz2 | patch -p2 -b
./configure --prefix=/usr --with-configdir=/etc/samba \
	--with-privatedir=/etc/samba --with-lockdir=/var/lock \
	--with-piddir=/var/run --with-logfilebase=/var/log --with-syslog \
	--without-readline --disable-cups --with-included-popt \
	--with-acl-support --with-codepagedir=/usr/lib/samba/codepages \
	--with-smbmount --with-sendfile-support
vi include/config.h	# Comment out "#define HAVE_SYS_CAPABILITY_H 1", if
			# set
rm -f bin/smbmount
make bin/smbmount LIBS='-ldl -lnsl -lresolv'
# DIET-PC 3 provides Samba 2.x smbd as an alternative to Samba 1.x smbd
# (since 2.x supports CIFS and 1.x doesn't).
rm -f bin/smbd
make bin/smbd LIBS='-Wl,-Bstatic -lacl -lattr -Wl,-Bdynamic -ldl -lnsl -lcrypt'
# Hmmm, mount.cifs.c doesn't exist in 2.2.x - but now that Busybox supports
# CIFS mounts, do we care?
#gcc -o bin/mount.cifs $CFLAGS client/mount.cifs.c
#strip -R .note -R .comment bin/mount.cifs
strip -R .note -R .comment bin/smb{mnt,mount} bin/smbd
mkdir -p ~/diet-pc/remotefs/files/sbin ~/diet-pc/remotefs/files/usr/bin
#cp bin/mount.cifs ~/diet-pc/remotefs/files/sbin/
cp bin/smb{mnt,mount} ~/diet-pc/remotefs/files/usr/bin/
ln -s ../usr/bin/smbmount ~/diet-pc/remotefs/files/sbin/mount.smbfs
mkdir -p ~/diet-pc/smbserver/extras/codepages
for page in 437 737 775 850 852 857 861 862 866 932 936 949 950 1125 1251; do
	bin/make_smbcodepage c $page codepages/codepage_def.$page \
for map in 437 737 775 850 852 857 861 862 866 932 936 949 950 1125 1251 \
		ISO8859-1 ISO8859-2 ISO8859-5 ISO8859-7 ISO8859-8 ISO8859-9 \
		ISO8859-13 ISO8859-15 KOI8-R KOI8-U; do
	bin/make_unicodemap $map codepages/CP${map}.TXT \
mkdir -p ~/diet-pc/smbserver/files/usr/lib/codepages
cp ~/diet-pc/smbserver/extras/codepages/codepage.850 \
cd ..
~/diet-pc/tools/man2txt docs/manpages/smbmnt.8 \
~/diet-pc/tools/man2txt docs/manpages/smbmount.8 \
#~/diet-pc/tools/man2txt docs/manpages/mount.cifs.8 \
#	>~/diet-pc/remotefs/mount.cifs.txt
cd ..
rm -rf samba-2.2.12

squashfs 2.2-r2

Version 2.2 is very outdated, but DIET-PC 2 must continue to use this, because SquashFS 3.x is not backward compatible with 2.x, and the skeleton package (which includes mksquashfs) must remain interoperable with the earliest DIET-PC 2.0 kernel, which used SquashFS 2.0.

tar xzf ~/diet-pc-src/squashfs2.2-r2.tar.gz
cd squashfs2.2-r2/squashfs-tools
vi Makefile	# Substitute $CFLAGS for "-g" in CFLAGS
strip -R .note -R .comment mksquashfs
mkdir -p ~/diet-pc/tools
cp mksquashfs ~/diet-pc/tools/mksquashfs2
ln -s mksquashfs2 ~/diet-pc/tools/mksquashfs
cd ../..
rm -rf squashfs2.2-r2

squashfs 3.4

This is the newer version of SquashFS, not compatible with SquashFS 2.2, and not used by default. If you want to use SquashFS 3.x, change the ~/diet-pc/tools/mksquashfs symlink to point to mksquashfs3 instead of mksquashfs2.

tar xzf ~/diet-pc-src/squashfs3.4.tar.gz
cd squashfs3.4/squashfs-tools
vi Makefile	# Substitute $CFLAGS for "-O2" in CFLAGS
strip -R .note -R .comment mksquashfs
mkdir -p ~/diet-pc/tools
cp mksquashfs ~/diet-pc/tools/mksquashfs3
cd ../..
rm -rf squashfs3.4

ssmtp 2.62

tar xzf ~/diet-pc-src/ssmtp_2.62.orig.tar.gz
cd ssmtp
./configure  --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
	--disable-ssl --disable-inet6 --enable-md5auth
strip -R .note -R .comment ssmtp

strace 4.5.18

tar xjf ~/diet-pc-src/strace-4.5.18.tar.bz2
cd strace-4.5.18
./configure --prefix=/usr --sysconfdir=/etc
strip -R .note -R .comment strace
mkdir -p ~/diet-pc/shell/extras
cp strace ~/diet-pc/shell/extras/
cd ..
rm -rf strace-4.5.18

sysfsutils 2.1.0

sysfsutils is part of the linux-diag project, available from It is a prerequisite for compiling sensord in the lm_sensors 2.x distribution.

On Debian (other than amd64), try "apt-get install libsysfs-dev" instead. On Debian amd64, you will need to compile and install your own libsysfs with the "-fPIC" option as below, because you can't safely link a dynamic library against a non-PIC static library on an x86_64 platform.

tar xzf ~/diet-pc-src/sysfsutils-2.1.0.tar.gz
cd sysfsutils-2.1.0
CFLAGS="$CFLAGS -fPIC" ./configure --prefix=/usr/local --disable-shared
sudo make install
cd ..
rm -rf sysfsutils-2.1.0

syslinux 3.83

syslinux is specific to the x86 and x86_64 ports of DIET-PC.

You will need to install netpbm in order to avoid build errors (pngtopnm is needed).

tar xjf ~/diet-pc-src/syslinux-3.83.tar.bz2
cd syslinux-3.83
make clean
strip -R .note -R .comment linux/syslinux extlinux/extlinux
mkdir -p ~/diet-pc/tools ~/diet-pc/tools-doc
mkdir -p ~/diet-pc/templates/mbr
mkdir -p ~/diet-pc/templates/extlinux/boot/extlinux
mkdir -p ~/diet-pc/templates/isolinux/boot/isolinux
mkdir -p ~/diet-pc/templates/pxelinux/pxelinux
mkdir -p ~/diet-pc/templates/syslinux/boot/syslinux
cp utils/sha1pass linux/syslinux extlinux/extlinux ~/diet-pc/tools/
cp doc/{extlinux,isolinux,pxelinux,syslinux}.txt ~/diet-pc/tools-doc/
cp core/isolinux.bin ~/diet-pc/templates/isolinux/boot/isolinux/
cp core/pxelinux.0 ~/diet-pc/templates/pxelinux/pxelinux/
cp com32/modules/chain.c32 com32/menu/{menu,vesamenu}.c32 \
cp com32/modules/chain.c32 com32/menu/{menu,vesamenu}.c32 \
cp com32/modules/chain.c32 com32/menu/{menu,vesamenu}.c32 \
cp com32/modules/chain.c32 com32/menu/{menu,vesamenu}.c32 \
cd ..
rm -rf syslinux-3.83

sysvinit 2.86

tar xzf ~/diet-pc-src/sysvinit-2.86.tar.gz
cd sysvinit-2.86
bunzip2 -c ~/diet-pc-src/sysvinit-2.86-dietpc-patch.bz2 | patch -p1 -b
cd src
# DIET-PC 3 only: vi init.h and set PATH_DFL to
# "PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"
strip -R .note -R .comment init halt
mkdir -p ~/diet-pc/shell/files/sbin
cp init halt ~/diet-pc/shell/files/sbin/
chmod u+s ~/diet-pc/shell/files/sbin/init
ln -s sbin/init ~/diet-pc/shell/files/init
ln -s halt ~/diet-pc/shell/files/sbin/reboot
cd ../..
rm -rf sysvinit-2.86

tcp_wrappers 7.6-ipv6.4

tar xzf ~/diet-pc-src/tcp_wrappers_7.6-ipv6.4.tar.gz
cd tcp_wrappers_7.6-ipv6.4
chmod u+w Makefile scaffold.c
# FIXME: perhaps should disable -DPARANOID?
vi Makefile	# set REAL_DAEMON_DIR=/usr/sbin, STYLE=-DPROCESS_OPTIONS,
		# FACILITY=LOG_AUTHPRIV; in linux section add VSYSLOG=, change
		# comment out VSYSLOG
vi +28 scaffold.c	# Comment out inaccurate extern declaration of malloc
make linux
gcc -shared -o -Wl, hosts_access.o options.o \
	shell_cmd.o rfc931.o eval.o hosts_ctl.o refuse.o percent_x.o \
	clean_exit.o fromhost.o fix_options.o socket.o tli.o workarounds.o \
	update.o misc.o diag.o percent_m.o myvsyslog.o
strip -R .note -R .comment
mkdir -p ~/diet-pc/shell/files/lib
cp ~/diet-pc/shell/files/lib/
ln -s ~/diet-pc/shell/files/lib/
~/diet-pc/tools/man2txt hosts_access.5 >~/diet-pc/shell/hosts_access.txt
cd ..
rm -rf tcp_wrappers_7.6-ipv6.4

textps 1.01

gcc $CFLAGS -o textps ~/diet-pc-src/textps.c
strip -R .note -R .comment textps
mkdir -p ~/diet-pc/printserver/files/usr/libexec/lpfilters
mv textps ~/diet-pc/printserver/files/usr/libexec/lpfilters/

TightVNC 1.3.10

N.B. requires libjpeg62-dev.

tar xjf ~/diet-pc-src/tightvnc-1.3.10_unixsrc.tar.bz2
cd vnc_unixsrc
bunzip2 -c ~/diet-pc-src/tightvnc-1.3.9-dietpc-patch.bz2 | patch -p1 -b
xmkmf -a
vi {libvncauth,vncpasswd,vncviewer}/Makefile	# change CDEBUGFLAGS to
						# "$CFLAGS -fno-strict-aliasing"
make -C libvncauth
make -C vncpasswd
make -C vncviewer XAWLIB=/usr/lib/ XPMLIB= SMLIB= ICELIB=
	# or /usr/X11R6/lib/, if your development box has it there
	# instead
strip -R .note -R .comment vncpasswd/vncpasswd vncviewer/vncviewer
#cd Xvnc
#cd ..
mkdir -p ~/diet-pc/rfb/extras ~/diet-pc/xserver_xorg_vnc/extras \
mkdir -p ~/diet-pc/rfb/files/usr/X11R6/bin
cp vncpasswd/vncpasswd ~/diet-pc/rfb/extras/
cp vncpasswd/vncpasswd ~/diet-pc/xserver_xorg_vnc/extras/
cp vncpasswd/vncpasswd ~/diet-pc/xserver_xvnc/extras/
cp vncviewer/vncviewer ~/diet-pc/rfb/files/usr/X11R6/bin/
~/diet-pc/tools/man2txt vncpasswd/ >\
~/diet-pc/tools/man2txt vncviewer/ >~/diet-pc/rfb/vncviewer.txt
cd ..
rm -rf vnc_unixsrc

transmission 1.75

N.B. Requires libcurl (with SSL support).

tar xjf ~/diet-pc-src/transmission-1.75.tar.bz2
cd transmission-1.75
vi configure		# Comment out first 'if test "x$GCC" ... fi' block
CFLAGS="$CFLAGS -fPIC" CXXFLAGS="$CFLAGS" ./configure --prefix=/usr \
	--sysconfdir=/etc --disable-gtk --enable-cli --disable-libnotify \
	--enable-daemon --enable-shared
#vi gtk/Makefile		# Remove "-DHAVE_GIO=1" from DEFS (if present)
cd libtransmission
gcc -shared -Wl,-soname -Wl, -o \
        `ar t libtransmission.a` `find ../third-party -name \*.a` \
        /usr/local/lib/libcurl.a /usr/local/lib/libssl.a \
        /usr/local/lib/libcrypto.a -lrt -ldl -lz
cd ../daemon
gcc -o transmission-daemon daemon.o watch.o \
	../libtransmission/ -lm
gcc -o transmission-remote remote.o ../libtransmission/ -lm
cd ../cli
gcc -o transmissioncli cli.o ../libtransmission/ -lm
cd ..
strip -R .note -R .comment daemon/transmission-{daemon,remote} \
	cli/transmissioncli libtransmission/

tzdata 2008h

If you have DIET-PCs in multiple timezones, it may be more convenient to pass a TZ kernel parameter via the boot loader (see tzset(3) manpage) than to create separate boot images with different /etc/localtime files.

mkdir tzdata2008h
cd tzdata2008h
tar xzf ~/diet-pc-src/tzdata2008h.tar.gz
/usr/sbin/zic -d . australasia	# or other region as required
mkdir -p ~/diet-pc/shell/files/etc
cp Australia/Sydney ~/diet-pc/shell/files/etc/localtime	# or other zone as
							# required
cd ..
rm -rf tzdata2008h

ucl 1.03

UCL is required by UPX, so we'll compile and install a static version of the library on your build host.

You probably won't need to do this on Debian, try "apt-get install libucl-dev".

tar xzf ~/diet-pc-src/ucl-1.03.tar.gz
cd ucl-1.03
CFLAGS=-O3 ./configure --prefix=/usr/local
sudo make install
cd ..
rm -rf ucl-1.03

udev 141

Ignore the udev distribution's claims of a minimum kernel version of 2.6.15, demands to disable /sbin/hotplug, and insistance that test-udev is "only for testing". In practice, udev will still work satisfactorily with older 2.6 kernels as long as test-udev is installed as /sbin/udev and /bin/hotplug still calls it.

It boggles the mind that the 2.6 kernel was released without stable userspace tools, and worse, that the udev developers seem to have no intention of ever providing stable releases, and change their minds like they change their socks. The fact that the udev version number no longer starts with zero does not imply that it is in any way "stable".

tar xjf ~/diet-pc-src/udev-141.tar.bz2
cd udev-141
bunzip2 -c ~/diet-pc-src/udev-128-dietpc-patch.bz2 | patch -p1 -b
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --disable-shared
strip -R .note -R .comment udev/{test-udev,udevadm,udevd} \
mkdir -p ~/diet-pc/shell/files/sbin
mkdir -p ~/diet-pc/shell/files/etc/udev/rules.d
cp udev/test-udev ~/diet-pc/shell/files/sbin/udev
cp udev/{udevadm,udevd} ~/diet-pc/shell/files/sbin/
cd ..
rm -rf udev-141

unzip 6.0

tar xzf ~/diet-pc-src/unzip60.tar.gz
cd unzip60
vi unix/Makefile	# Substitute $CFLAGS for "-O3" in linux section (x86)
			# or linux_noasm section (x86_64/PPC/ARM/MIPSEL)
			# and add -DNO_LCHMOD to CFLAGS
make -f unix/Makefile linux
# (PPC/ARM/x86_64/MIPSEL: make -f unix/Makefile linux_noasm)
strip -R .note -R .comment unzip
mkdir -p ~/diet-pc/shell/files/usr/bin
cp unzip ~/diet-pc/shell/files/usr/bin/
cd ..
rm -rf unzip60

upx 3.04

The ucl library is a prerequisite for this package.

tar xjf ~/diet-pc-src/upx-3.04-src.tar.bz2
cd upx-3.04-src/src
export UCLDIR=/usr/local	# Not necessary if using Debian's libucl-dev
vi Makefile			# Remove "-O2" from CXXFLAGS
gcc -static-libgcc -o upx *.o -L/usr/local -Wl,-Bstatic -lucl -lstdc++ \
	-Wl,-Bdynamic -lz
strip -R .note -R .comment upx
mkdir -p ~/diet-pc/tools
cp upx ~/diet-pc/tools/
cd ../doc
mkdir -p ~/diet-pc/tools-doc
~/diet-pc/tools/man2txt upx.1 >~/diet-pc/tools-doc/upx.txt
cd ../..
rm -rf upx-3.04-src

usbutils 0.11

Can be found at

tar xzf ~/diet-pc-src/usbutils-0.11.tar.gz
cd usbutils-0.11
# Provided config.sub is too old to handle some architectures (eg. x86_64),
# so substitute an up-to-date one:
amvers=`automake --version | awk '{print $NF; exit}' | cut -f1-2 -d.`
rm config.sub
ln -s /usr/share/automake-$amvers/config.sub
./configure --prefix=''
make usbmodules
strip -R .note -R .comment usbmodules
mkdir -p ~/diet-pc/shell/files/sbin
cp usbmodules ~/diet-pc/shell/files/sbin/
cd ..
rm -rf usbutils-0.11

util-linux 2.12r

tar xjf ~/diet-pc-src/util-linux-2.12r.tar.bz2
cd util-linux-2.12r
vi MCONFIG	# change CPUTAIL=486 to CPUTAIL=686 and substitute -Os for -O2
		# in the 'ifeq "$(ARCH)" "intel"' section
# (x86_64: don't modify CPUTAIL, change CPUOPT=-m64)
# (PPC and MIPSEL: change default OPT= case (just before WARNFLAGS) to "$CFLAGS
# -fomit-frame-pointer" instead)
# (ARM: change the OPT flags in the ifeq "$(ARCH)" "arm" case to "$CFLAGS -pipe
# -fsigned-char -fomit-frame-pointer")
vi configure	# comment out "CFLAGS=${CFLAGS-"-O2"}"
vi make_include		# change to "HAVE_BLKID=no" if it is not already
vi mount/realpath.c	# change to "#undef resolve_symlinks"
			# Skip this for DIET-PC 3
# DIET-PC 3 only:
#vi disk-utils/mkfs.c	# Append /usr/sbin:/usr/local/sbin to SEARCH_PATH
make -C lib
make -C disk-utils mkfs
make -C disk-utils mkfs.cramfs
make -C misc-utils mcookie
make -C mount mount
strip -R .note -R .comment disk-utils/mkfs disk-utils/mkfs.cramfs \
	misc-utils/mcookie mount/mount
mkdir -p ~/diet-pc/persistfs/files/sbin ~/diet-pc/xcore/files/usr/bin
mkdir -p ~/diet-pc/remotefs/files/bin ~/diet-pc/storageserver/files/bin
mkdir -p ~/diet-pc/tools
cp disk-utils/mkfs ~/diet-pc/persistfs/files/sbin/
cp disk-utils/mkfs.cramfs ~/diet-pc/tools/mkcramfs
cp misc-utils/mcookie ~/diet-pc/xcore/files/usr/bin/
cp mount/mount ~/diet-pc/remotefs/files/bin/
cp mount/mount ~/diet-pc/storageserver/files/bin/
cd ..
rm -rf util-linux-2.12r

wireless_tools 29

tar xzf ~/diet-pc-src/wireless_tools.29.tar.gz
cd wireless_tools.29
vi Makefile	# Set PREFIX=, BUILD_STATIC=y, modify CFLAGS as required
make iwmulticall
strip -R .note -R .comment iwmulticall
mkdir -p ~/diet-pc/wireless/files/sbin
cp iwmulticall ~/diet-pc/wireless/files/sbin/
ln -s iwmulticall ~/diet-pc/wireless/files/sbin/iwconfig
ln -s iwmulticall ~/diet-pc/wireless/files/sbin/iwlist
ln -s iwmulticall ~/diet-pc/wireless/files/sbin/iwspy
ln -s iwmulticall ~/diet-pc/wireless/files/sbin/iwpriv
ln -s iwmulticall ~/diet-pc/wireless/files/sbin/iwgetid
~/diet-pc/tools/man2txt iwconfig.8 >~/diet-pc/wireless/iwconfig.txt
cd ..
rm -rf wireless_tools.29

wpa_supplicant 0.6.9

tar xzf ~/diet-pc-src/wpa_supplicant-0.6.9.tar.gz
cd wpa_supplicant-0.6.9/wpa_supplicant
cp defconfig .config
		# CONFIG_TLS=internal
strip -R .note -R .comment wpa_supplicant wpa_passphrase
mkdir -p ~/diet-pc/wireless/files/sbin ~/diet-pc/wireless/files/etc \
cp wpa_supplicant ~/diet-pc/wireless/files/sbin/
cp wpa_supplicant.conf ~/diet-pc/wireless/
cp wpa_passphrase ~/diet-pc/wireless/extras/
~/diet-pc/tools/man2txt doc/docbook/wpa_supplicant.8 \
~/diet-pc/tools/man2txt doc/docbook/wpa_supplicant.conf.5 \
cd ../..
rm -rf wpa_supplicant-0.6.9

wu-ftpd CVS

WU-FTPD no longer appears to be maintained (it had a history of security problems, and was abandoned in favour of VSFTPD et al). Nevertheless it remains the FTP server of choice for DIET-PC because of its FTP conversions feature (on-the-fly compression and archiving). Note, however, that WU-FTPD 2.6.2 is not adequate for DIET-PC purposes - you will get segfaults. Hence you should use a CVS snapshot available from

tar xzf ~/diet-pc-src/wuftpd-cvs-current.tar.gz
cd wu-ftpd
./configure --prefix=/usr --disable-private --enable-anononly --disable-pam \
	--disable-log-rp --disable-virtual --disable-mail --enable-badclients \
	--enable-rfc931 --disable-ipv6
vi config.h		# add "#define LIBWRAP"
vi src/Makefile		# append -lwrap to LIBS
make -C support
make -C src ftpd
strip -R .note -R .comment src/ftpd
mkdir -p ~/diet-pc/storageserver/files/usr/sbin
cp src/ftpd ~/diet-pc/storageserver/files/usr/sbin/in.ftpd
~/diet-pc/tools/man2txt doc/ftpaccess.5 \
~/diet-pc/tools/man2txt doc/ftpconversions.5 \
~/diet-pc/tools/man2txt doc/ftpd.8 >~/diet-pc/storageserver/ftpd.txt
cp LICENSE ~/diet-pc/storageserver/LICENSE.wu-ftpd
cd ..
rm -rf wu-ftpd

X11R6.9.0 (X.Org)

mgadriver-x86-4.2.0-src.tar.gz is available from You cannot use version 4.3.0 or later.

If your root account aliases cp and rm such that they use the "-i" option by default, you should unalias these before attempting multi-line cut-and-pastes.

tar xzf ~/diet-pc-src/X11R6.9.0-src1.tar.gz
tar xzf ~/diet-pc-src/X11R6.9.0-src2.tar.gz
tar xzf ~/diet-pc-src/X11R6.9.0-src3.tar.gz
cd xc
bunzip2 -c ~/diet-pc-src/x11r6.9.0-cidfonts.diff.bz2 | patch -p0 -b
# FIXME: wrong patchlevel in x11r6.9.0-dbe-render.diff.bz2
bunzip2 -c ~/diet-pc-src/x11r6.9.0-dbe-render.diff.bz2 | patch -p0 -b
bunzip2 -c ~/diet-pc-src/x11r6.9.0-geteuid.diff.bz2 | patch -p0 -b
bunzip2 -c ~/diet-pc-src/x11r6.9.0-mitri.diff.bz2 | patch -p0 -b
bunzip2 -c ~/diet-pc-src/x11r6.9.0-setuid.diff.bz2 | patch -p1 -b -f
# Errors from the setuid diff are benign and may be ignored.
bunzip2 -c ~/diet-pc-src/X11R6.9.0-dietpc-diff.bz2 | patch -p1 -b
tar xzOf ~/diet-pc-src/mgadriver-4.2.0-src.tar.gz \
	mgadriver-4.2.0-src/6.8.2/mga/HALlib/mgaHALlib.a \
# PPC/ARM/MIPSEL instructions:
# - vesa driver is not available for this platform, we will use fbdev instead.
# - change HaveMatroxHal NO (or delete it) in config/cf/xorgsite.def.
# - add "#define OptimizedCDebugFlags	$CFLAGS -static-libgcc" to DIET-PC
#   section in config/cf/site.def.
make World

export LD_LIBRARY_PATH=exports/lib
strip -R .note -R .comment exports/lib/lib*.so.?
find exports/lib/modules -name \*.so -exec strip -R .note -R .comment {} \;

mkdir -p ~/diet-pc/xcore/files/usr/X11R6/bin
rm programs/xauth/xauth
make -C programs/xauth xauth XMUULIB='-Wl,-Bstatic -lXmuu -Wl,-Bdynamic'
strip -R .note -R .comment programs/xauth/xauth
cp programs/xauth/xauth ~/diet-pc/xcore/files/usr/X11R6/bin/

mkdir -p ~/diet-pc/xcore/files/usr/X11R6/lib/X11/fonts/{75dpi,misc}
cp exports/lib/lib{X11,Xext}.so.6 ~/diet-pc/xcore/files/usr/X11R6/lib/
cp programs/rgb/rgb.txt lib/X11/XKeysymDB \
programs/bdftopcf/bdftopcf fonts/bdf/75dpi/helvB12-L1.bdf | gzip -9 >\
programs/bdftopcf/bdftopcf fonts/bdf/misc/6x13-L1.bdf | gzip -9 >\
programs/bdftopcf/bdftopcf fonts/bdf/misc/cursor.bdf | gzip -9 >\
touch ~/diet-pc/xcore/files/usr/X11R6/lib/X11/fonts/75dpi/fonts.alias
cat >~/diet-pc/xcore/files/usr/X11R6/lib/X11/fonts/misc/fonts.alias <<EOF
fixed		-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
variable	-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1
6x13		-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
programs/mkfontscale/mkfontscale -b -s -l \

mkdir -p ~/diet-pc/xcore/extras/keymaps
cp programs/xkbcomp/keymap/xfree86 ~/diet-pc/xcore/extras/keymaps/
for keymap in `grep '^xkb_keymap' programs/xkbcomp/keymap/xfree86 | cut -f2 \
	-d \"`; do
    programs/xkbcomp/xkbcomp -Iprograms/xkbcomp -dflts -xkm -m $keymap \
	    programs/xkbcomp/keymap/xfree86 \
mkdir -p ~/diet-pc/xcore/files/usr/X11R6/lib/X11/xkb/compiled
cp ~/diet-pc/xcore/extras/keymaps/en_US.xkm \
	# Or other file to suit your locale

mkdir -p ~/diet-pc/xserver_xorg/files/usr/X11R6/lib/X11/xserver
cp programs/Xserver/Xext/SecurityPolicy \
mkdir -p ~/diet-pc/xserver_xorg/files/usr/X11R6/bin
strip -R .note -R .comment programs/Xserver/Xorg
cp programs/Xserver/Xorg ~/diet-pc/xserver_xorg/files/usr/X11R6/bin/
mkdir -p ~/diet-pc/xserver_xorg/files/usr/X11R6/lib/modules/{drivers,extensions,fonts,input,linux}
~/diet-pc/tools/man2txt programs/Xserver/Xserver._man \
~/diet-pc/tools/man2txt programs/Xserver/hw/xfree86/Xorg._man \
~/diet-pc/tools/man2txt programs/Xserver/hw/xfree86/xorg.conf._man \
~/diet-pc/tools/man2txt programs/Xserver/hw/xfree86/drivers/vesa/vesa._man \
# (PPC/ARM/MIPSEL: substitute fbdev/fbdev._man and fbdev.txt for vesa/vesa._man
# and vesa.txt)
for module in drivers/ extensions/ extensions/ \
	fonts/ input/ input/ \ \
	linux/; do
    cp exports/lib/modules/$module \
# (PPC/ARM/MIPSEL: and are not built, substitute
# and respectively; omit

for driver in atimisc cirrus fglrx i810 i740 mga nv r128 radeon s3 savage \
	trident via vmware; do
    mkdir -p ~/diet-pc/xserver_xorg_$driver/files/usr/X11R6/lib/modules/drivers
    if [ -f programs/Xserver/hw/xfree86/drivers/$driver/$driver._man ]; then
	~/diet-pc/tools/man2txt \
		programs/Xserver/hw/xfree86/drivers/$driver/$driver._man \
    cp exports/lib/modules/lib{ramdac,vgahw,xaa}.so \
    if [ -f exports/lib/modules/drivers/${driver} ]; then
	cp exports/lib/modules/drivers/${driver} \

mkdir -p ~/diet-pc/xserver_xorg_nvidia/files/usr/X11R6/lib/modules
cp exports/lib/modules/ \

mkdir -p ~/diet-pc/xserver_xorg_mga/files/usr/X11R6/lib/modules/drivers
cp exports/lib/modules/ \
# (PPC/ARM/MIPSEL: is not built, skip next command)
cp exports/lib/modules/drivers/ \

for driver in atimisc r128 radeon; do
    cp exports/lib/modules/drivers/ \
    if [ -f programs/Xserver/hw/xfree86/drivers/ati/$driver._man ]; then
	~/diet-pc/tools/man2txt \
		programs/Xserver/hw/xfree86/drivers/ati/$driver._man \

# (PPC/ARM/MIPSEL: cirrus drivers not built, skip next command)
cp exports/lib/modules/drivers/cirrus_{alpine,laguna}.so \

for driver in i810 r128 radeon vmware; do
    mkdir -p ~/diet-pc/xserver_xorg_$driver/files/usr/X11R6/lib/modules
    cp exports/lib/modules/ \

# (ARM: DRI not supported at all, so skip next two blocks entirely)
for driver in fglrx i810 mga r128 radeon via; do
    mkdir -p ~/diet-pc/xserver_xorg_$driver/files/usr/X11R6/lib/modules/{dri,extensions,linux}
    cp exports/lib/lib{GL,Xxf86vm}.so.1 \
    if [ -f exports/lib/modules/dri/${driver} ]; then
	cp exports/lib/modules/dri/${driver} \
    cp exports/lib/modules/extensions/lib{dri,GLcore,glx}.so \
    cp exports/lib/modules/linux/ \
mkdir -p ~/diet-pc/mmedia_xine/extras
cp exports/lib/lib{GL,Xxf86vm}.so.1 ~/diet-pc/mmedia_xine/extras/
rm ~/diet-pc/xserver_xorg_fglrx/files/usr/X11R6/lib/

# (PPC: i810 and via drivers are not built, so skip this block)
cp exports/lib/modules/dri/ \
cp exports/lib/modules/dri/ \
cp exports/lib/ \
rm ~/diet-pc/xserver_xorg_via/files/usr/X11R6/lib/lib{GL,Xxf86vm}.so.1
cp exports/lib/ exports/lib/ \

mkdir -p ~/diet-pc/mmedia_xine/files/usr/X11R6/lib
cp exports/lib/ exports/lib/ \
	exports/lib/ exports/lib/ \

for pkg in http_opera ica rfb ssh; do
    mkdir -p ~/diet-pc/$pkg/files/usr/X11R6/lib
    cp exports/lib/lib{ICE,SM,Xmu,Xt}.so.6  ~/diet-pc/$pkg/files/usr/X11R6/lib
rm ~/diet-pc/ssh/files/usr/X11R6/lib/

rm programs/xset/xset
make -C programs/xset xset XMUULIB='-Wl,-Bstatic -lXmuu -Wl,-Bdynamic' \
	XXF86MISCLIB='-Wl,-Bstatic -lXxf86misc -Wl,-Bdynamic' \
	XPLIB='-Wl,-Bstatic -lXp -Wl,-Bdynamic'
strip -R .note -R .comment programs/xset/xset
mkdir -p ~/diet-pc/mmedia_xine/files/usr/X11R6/bin
cp programs/xset/xset ~/diet-pc/mmedia_xine/files/usr/X11R6/bin/

rm programs/xmessage/xmessage
make -C programs/xmessage xmessage XAWLIB='../../exports/lib/' \
strip -R .note -R .comment programs/xmessage/xmessage
mkdir -p ~/diet-pc/ica/files/usr/X11R6/bin ~/diet-pc/rfb/files/usr/X11R6/bin \
cp programs/xmessage/xmessage ~/diet-pc/ica/files/usr/X11R6/bin/
cp programs/xmessage/xmessage ~/diet-pc/rfb/files/usr/X11R6/bin/
cp programs/xmessage/xmessage ~/diet-pc/http_opera/files/usr/X11R6/bin/

rm programs/xdpyinfo/xdpyinfo
make -C programs/xdpyinfo xdpyinfo LOCAL_LIBRARIES='-Wl,-Bstatic -ldmx -lXi \
	-lXtst -lXxf86dga -lXrender -lXinerama -lXxf86misc -lXxf86vm \
	-Wl,-Bdynamic -lXp -lX11 -lXext'
strip -R .note -R .comment programs/xdpyinfo/xdpyinfo
cp programs/xdpyinfo/xdpyinfo ~/diet-pc/ica/files/usr/X11R6/bin/

mkdir -p ~/diet-pc/ica/files/usr/X11R6/lib \
cp exports/lib/ exports/lib/ \
cp exports/lib/ ~/diet-pc/rfbserver/files/usr/X11R6/lib/

mkdir -p ~/diet-pc/xcore/files/usr/X11R6/lib/X11/locale/lib/common
cp -Lr exports/lib/locale/{C,iso8859-1} \
strip -R .note -R .comment exports/lib/locale/lib/common/*.so.?
cp exports/lib/locale/lib/common/{ximcp,xlcDef,xomGeneric}.so.2 \
chmod 755 ~/diet-pc/xcore/files/usr/X11R6/lib/X11/locale/lib/common/*.so.?
cp exports/lib/locale/*.{dir,alias} \

cd ..
tar cjf xorg690.tar.bz2 xc	# Retain a copy of the build tree, as you may
				# need to borrow additional libraries from it
rm -rf xc

X11R7.2/3 (X.Org)

Build instructions for modular Xorg (X11R7.x) aren't finished yet, and in any case are much too verbose to inline here. See xorg7_build.txt for interim build instructions.


tar xzf ~/diet-pc-src/x11-ssh-askpass-
cd x11-ssh-askpass-
vi	# uncomment "*grabServer"
./configure --prefix=/usr/X11R6
# DIET-PC 3: use --prefix/usr instead.
make includes
gcc -o x11-ssh-askpass *.o -lXt -lX11
strip -R .note -R .comment x11-ssh-askpass
mkdir -p ~/diet-pc/ssh/files/usr/X11R6/bin
cp x11-ssh-askpass ~/diet-pc/ssh/files/usr/X11R6/bin/
rm x11-ssh-askpass
make LOCAL_LIBRARIES="-lX11 -Wl,-Bstatic -lXt -lSM -lICE -Wl,-Bdynamic"
strip -R .note -R .comment x11-ssh-askpass
mkdir -p ~/diet-pc/ssh/extras
cp x11-ssh-askpass ~/diet-pc/ssh/extras/
cd ..
rm -rf x11-ssh-askpass-

Xaw95 1.1

FIXME: link more carefully to reduce dependencies.

tar xzf ~/diet-pc-src/Xaw95-1.1-src.tar.gz
cd Xaw95-1.1
gunzip -c ~/diet-pc-src/Xaw95-1.1-dietpc-patch.gz | patch -p1 -b
sudo mv /usr/include/X11/Xaw3d /usr/include/X11/Xaw3d.orig
# (only if this directory exists; may be located at
# /usr/X11R6/include/X11/Xaw3d on older systems, modify as appropriate)
sudo ln -s `pwd` /usr/include/X11/Xaw3d # (or /usr/X11R6/include/X11/Xaw3d)
make includes
make depend
make CDEBUGFLAGS="$CFLAGS -fno-strict-aliasing" CLIBDEBUGFLAGS= SOXAWREV=6.0 \
gcc -o -shared
strip -R .note -R .comment
mkdir -p ~/diet-pc/http_opera/files/usr/X11R6/lib
mkdir -p ~/diet-pc/ica/files/usr/X11R6/lib
mkdir -p ~/diet-pc/rfb/files/usr/X11R6/lib
cp ~/diet-pc/http_opera/files/usr/X11R6/lib/
cp ~/diet-pc/rfb/files/usr/X11R6/lib/
cp ~/diet-pc/ica/files/usr/X11R6/lib/
cp ~/diet-pc/ica/files/usr/X11R6/lib/
sudo rm /usr/include/X11/Xaw3d
sudo mv /usr/include/X11/Xaw3d.orig /usr/include/X11/Xaw3d
# (or /usr/X11R6/include/X11/Xaw3d)
cd ..
rm -rf Xaw95-1.1

xclass 0.9.2

Note that this configuration is no good for compiling xclass applications to run locally, since OX_DEFAULT_POOL and OX_DEFAULT_ROOT do not match the prefix used. A prefix of /usr/local is only used here to avoid installing software in /usr that is not under the control of your Linux distro's package manager.

xclass is required to build x0rfbserver (rfb). Although you may use your platform's xclass library (if available) instead of building one, this build of the xclass library is optimised for space, to ensure a smaller x0rfbserver binary.

tar xzf ~/diet-pc-src/xclass-0.9.2.tar.gz
cd xclass-0.9.2
vi lib/libxclass/
			# change "DEFINES=
			# -DOX_DEFAULT_POOL=\"/usr/X11R6/share/xclass/icons\"
			# -DOX_DEFAULT_ROOT=\"\""
# DIET-PC 3: use -DOX_DEFAULT_POOL=\"/usr/share/xclass/icons\"
# A couple of tweaks are needed for gcc 4.1:
vi +764 lib/libxclass/      # Change the type of "c" from "char"
                                        # to "signed char"
vi +599 lib/libxclass/	# Change "-128" to "(char)-128"
					# x86_64 only: change "(int)" to
					# "(long int)" on lines 1490 and 1494
vi test/			# Add "#include <time.h>"
# x86_64:
#vi +985 lib/libxclass/	# Change "(int)" to "(long int)"
# cflags_set=set gets around a configure stupidity
cflags_set=set CXX=g++-2.95 ./configure --prefix=/usr/local --disable-opengl
sudo make install
cd ..
rm -rf xclass-0.9.2

xf4vnc CVS

XF4VNC sources are only available via CVS.

FIXME: Need new entries for my own drop-in module-only solutions. This solution will only create useable modules for Xorg 6.9/7.0, or 7.2 using extra hacks. Still okay for Xvnc creation (although TightVNC code is simpler for that).

mkdir xf4vnc
cd xf4vnc
cvs login
cvs -z3 co .
cvs logout
cd xc
vi config/cf/host.def	# Uncomment GccWarningOptions and
				# DefaultCCOptions, change "-g -O2" to
				# $CFLAGS in DefaultCCOptions
				# Add "#define BuildGlxExt NO",
				# "#define BuildXKB YES" and
				# "#define BuildIPv6 NO"
				# "#define BuildFreeType NO"
				# "#define UseFreetype2 NO"
vi config/cf/site.def	# DIET-PC 3 only: Change "#define ProjectRoot /usr"
make World	# This will fail, but don't worry
cd ../libvncauth
imake -I../xc/config/cf
cd ../xc
# (PPC: vi programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h, change two
# references to "asm" to "__asm__" (problem might be specific to gcc 3.3.3))
# vi config/cf/		# Remove the "|| defined # (MipsArchitecture)"
#			 	# clause just before "#define DoLoadableServer
#				# NO"
# - If compilation fails with an error relating to a missing libi2c.a, do the
# following:
# pushd  programs/Xserver/hw/xfree86/i2c
# xmkmf ../../../../..
# make
# popd
# make
# - If compilation of programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.o fails
# when using gcc >=4.2:
# pushd  programs/Xserver/hw/xfree86/scanpci
# make MODCC=gcc-4.1
# popd
# make
# )
# (x86_64: need to recompile objects in libvncauth and
# xc/programs/Xserver/hw/xfree86/vnc using "CCOPTIONS+='-fPIC'" to overcome
# linker errors, even though Xvnc doesn't use; maybe we can avoid
# this by setting XF86Server to NO in host.def(?))
rm -f programs/Xserver/Xvnc
make -C programs/Xserver FREETYPE2LIB='-Wl,-Bstatic -lfreetype -Wl,-Bdynamic'
strip -R .note -R .comment programs/Xserver/Xvnc exports/lib/modules/
mkdir -p ~/diet-pc/xserver_xvnc/files/usr/X11R6/bin
mkdir -p ~/diet-pc/xserver_xvnc/files/usr/X11R6/lib/X11/xserver
cp programs/Xserver/Xvnc ~/diet-pc/xserver_xvnc/files/usr/X11R6/bin/
cp programs/Xserver/Xext/SecurityPolicy \
~/diet-pc/tools/man2txt programs/Xserver/Xserver._man \
mkdir -p ~/diet-pc/xserver_xorg_vnc/files/usr/X11R6/lib/modules/extensions
cp exports/lib/modules/ \
cd ../..
rm -rf xf4vnc

XFree86 3.3.6

N.B. Fixes 09 and 10 in the X336fixes.tar.gz bundle are unofficial and DIET-PC-specific.

XFree86 3.3.6 won't compile for ARM - it looks like the ARM architecture wasn't properly supported until XFree86 4.x. Nor will it compile for x86_64. It doesn't seem terribly useful on PPC either, for that matter!

mkdir xfree86-3.3.6
cd xfree86-3.3.6
tar xzf ~/diet-pc-src/X336src-1.tgz
cd xc
tar xzf ~/diet-pc-src/X336fixes.tar.gz
for fix in X336fixes/*; do
    if [ "$fix" = 'X336fixes/fix-04-s3trio3d2x' ]; then
	patch -p2 -E <$fix
	patch -p1 -E <$fix
# PPC instructions:
# - we're building XF86_FBDev, not XF86_SVGA
# - don't apply fix-09-modern_glibc patch
# - need to "#define OptimizedCDebugFlags   -static-libgcc $CFLAGS" in
#   AfterVendorCF section of config/cf/site.def
# - add "volatile" to definitions of GLINTMMIOBase and glintVideoMem in
#   programs/Xserver/hw/xfree68/pm2/pm2_accel.h and
#   programs/Xserver/hw/xfree68/pm2/pm2fbdev.c
# - PPC doesn't have the ioperm system call, so add a dummy macro to
#   programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h as follows:
#   #ifdef __powerpc__
#   #define ioperm(x,y,z)	0
#   #endif
# - programs/Xserver/hw/xfree86/fbdev/Makefile doesn't get built for reasons
#   unknown, so:
#   - pushd programs/Xserver/hw/xfree86/fbdev
#   - xmkmf ../../../../../
#   - make (fails)
#   - vi fbdev.c (comment out #include of <stdlib.h>)
#   - make
#   - popd
make World
strip -R .note -R .comment programs/Xserver/XF86_SVGA
# (PPC: XF86_FBDev, not XF86_SVGA)
mkdir -p ~/diet-pc/xserver_xf3/files/usr/X11R6/bin
cp programs/Xserver/XF86_SVGA ~/diet-pc/xserver_xf3/files/usr/X11R6/bin/
mkdir -p ~/diet-pc/xserver_xf3/files/usr/X11R6/lib/X11/xserver
cp programs/Xserver/Xext/SecurityPolicy \
~/diet-pc/tools/man2txt programs/Xserver/ >\
~/diet-pc/tools/man2txt programs/Xserver/hw/xfree86/ >\
# (PPC: no manpage for XF86_FBDev)
cd ../..
rm -rf xfree86-3.3.6

XFree86 4.8.0

Only the Xvesa or Xfbdev TinyX server is used from the XFree86 distribution - X.Org is used for most other X11 components (modular X server, libraries and utility programs).

mkdir xfree86-4.8.0
cd xfree86-4.8.0
tar xzf ~/diet-pc-src/XFree86-4.8.0-src-1.tgz
tar xzf ~/diet-pc-src/XFree86-4.8.0-src-2.tgz
tar xzf ~/diet-pc-src/XFree86-4.8.0-src-3.tgz
cd xc
bunzip2 -c ~/diet-pc-src/XFree86-4.6.0-dietpc-patch.bz2 | patch -p1 -b
vi config/cf/xf86site.def	# Change "-mcpu=i686" to "-mtune=i686" to
				# suppress gcc deprecation warnings
# DIET-PC 3: change ProjectRoot to /usr in config/cf/site.def
# PPC/ARM/MIPSEL instructions:
# - We will build Xfbdev instead of Xvesa.
# - Set ServerToInstall to Xfbdev in config/cf/xf86site.def
# - Add "#define OptimizedCDebugFlags    -static-libgcc $CFLAGS" in
#   AfterVendorCF section of config/cf/site.def.
make World
# This may fail with a bogus makedepend error in
# xc/lib/freetype2/freetype/config/ftconfig.h (related to "limits.h").
# Ignore this and continue.
strip -R .note -R .comment programs/Xserver/Xvesa
# (PPC/ARM/MIPSEL: Xfbdev instead of Xvesa)
mkdir -p ~/diet-pc/xserver_tinyx/files/usr/X11R6/bin
cp programs/Xserver/Xvesa ~/diet-pc/xserver_tinyx/files/usr/X11R6/bin/
# (PPC/ARM/MIPSEL: Xfbdev instead of Xvesa)
~/diet-pc/tools/man2txt programs/Xserver/Xserver._man >\
~/diet-pc/tools/man2txt programs/Xserver/hw/tinyx/TinyX._man >\
~/diet-pc/tools/man2txt programs/Xserver/hw/tinyx/vesa/Xvesa._man >\
# (PPC/ARM/MIPSEL: fbdev/Xfbdev._man > Xfbdev.txt)
cd ../..
rm -rf xfree86-4.8.0


xine-lib is very awkward to compile for an embedded environment, because it links to many back-end shared libraries using libtool. The back-end libraries are often too big to include whole in an embedded environment, and we would prefer to link some of these libraries statically into Xine's loadable modules. Unfortunately libtool makes this very difficult.

Because of the (un)subtleties of libtool and because xine-lib needs to be installed in order to compile xine-ui, we need to install xine-lib to /opt/xine on your development platform. It's unlikely that this will clash with an already installed package, but it would pay to check first.

Unfortunately the instructions below are likely to be somewhat Debian-specific. Your distro's developer libraries might be static, shared or (hopefully in most cases) both, and may or may not be cross-linked to certain other libraries, and any number of development packages that xine-lib regards as optional (but which are required by my particular built) may be absent. Hence the only way to ensure a known state is to use the official DIET-PC development environment virtual machine for your platform.

For full functionality, you will need to install a lot of development packages (DEB, RPM, etc) on your development platform before compiling xine-lib. Probably the best way to find out what you are missing is simply to run the configure command and see what errors are reported (important bits will be heavily asterisked). You don't need to install everything that configure complains about. My build didn't include: (a) pointless ASCII art libraries (AALib, CACA), (b) libraries irrelevant to the Linux x86 platform (Libstk, DirectX, IRIX AL), (c) libraries that are only provided in shared form (JACK), and (d) libraries that have too many further dependencies to be viable in an embedded context (WAND, directfb, polypaudio, gnome_vfs, libsmbclient, SDL, freetype and modplug).

These intructions assume that your static X libraries are in /usr/lib, which is usual for X11R7. If you have an older X11R6-based distro, you may need to change some X library pathnames to use the /usr/X11R6/lib prefix instead.

Except in the case of freetype (which can be safely turned off using --disable-freetype), the way I have avoided autodetection of unwanted back-end capabilities was simply to uninstall the relevant *-dev DEBs / *-devel RPMs.

Note that although these instructions will allow you to build Xine for PowerPC, in all likelihood it won't work, because the PowerPC runtime linker can't reliably combine static and shared components in a shared library (due to use of 24-bit relative addressing in objects that are compiled without -fpic, resulting in possible out-of-range jumps). Libtool warns us that doing this isn't always portable, and indeed in this case it isn't. The same is likely to be true for x86_64 (not attempted yet).

tar xjf ~/diet-pc-src/xine-lib-
cd xine-lib-
CFLAGS=-O3 PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig \
	./configure --prefix=/opt/xine --with-xv-path=/usr/lib \
	--with-w32-path=/opt/xine/lib/win32 --disable-freetype --disable-glu
# DIET-PC 3: ./configure --prefix=/usr/local --sysconfdir=/etc \
#	--localstatedir=/var --with-xv-path=/usr/lib \
#	--with-w32-path=/usr/local/lib/xine/win32 --disable-freetype \
#	--disable-glu
cd src/demuxers
rm -f
make VORBIS_LIBS='/usr/lib/libvorbis.a -lm' \
	THEORA_LIBS=/usr/lib/libtheora.a OGG_LIBS=/usr/lib/libogg.a \
rm -f
make MNG_LIBS='/usr/lib/libmng.a /usr/lib/liblcms.a -lm \
cd ../libxineadec
rm -f
make VORBIS_LIBS='/usr/lib/libvorbis.a -lm' \
rm -f
make SPEEX_LIBS='/usr/lib/libspeex.a \
        /usr/lib/libogg.a -lm'
cd ../libxinevdec
rm -f
make \
	GDK_PIXBUF_LIBS='/usr/lib/libgdk_pixbuf-2.0.a -lm \
	/usr/lib/libgobject-2.0.a /usr/lib/libgmodule-2.0.a \
	/usr/lib/libglib-2.0.a /usr/lib/libtiff.a -lz /usr/lib/libjpeg.a \
# DIET-PC 3: need to add /usr/lib/libpcre.a also
rm -f
# The odd positioning of /usr/lib/libogg.a is needed to overcome a link-time
# ordering problem.
make THEORA_LIBS='/usr/lib/libtheora.a -lm \
	/usr/lib/libogg.a' OGG_LIBS=''
cd ../audio_out
rm -f
make ESD_LIBS='/usr/lib/libesd.a \
	/usr/lib/libaudiofile.a -lasound'
#rm -f
#make ARTS_LIBS=/usr/lib/libartsc.a
#cd ../video_out
#rm -f
#make AALIB_LIBS=/usr/lib/libaa.a
#rm -f
#make CACA_LIBS='/usr/lib/libcaca.a \
#	/usr/lib/libcucul.a /usr/lib/libslang.a /usr/lib/libncurses.a'
cd ../../misc
gcc $CFLAGS -Wall -o cdda_server cdda_server.c -ldl
strip -R .note -R .comment cdda_server
mkdir -p ~/diet-pc/mmedia_xine/files/usr/sbin
cp cdda_server ~/diet-pc/mmedia_xine/files/usr/sbin/
cd ..
sudo make install
strip -R .note -R .comment /opt/xine/lib/
strip -R .note -R .comment /opt/xine/lib/xine/plugins/1.26/*.so
strip -R .note -R .comment /opt/xine/lib/xine/plugins/1.26/*/*.so
cd ..
rm -rf xine-lib-	# I suggest that you defer this until you're
				# sure that your plugins have no unforseen
				# library dependencies.

xine-ui 0.99.5

Use of CURL will blow out the size of the binary and introduce OpenSSL dependencies, so I suggest removing the libcurl3-dev / curl-devel package so that configure won't detect and use it.

Because xine-ui's installation is fairly complex (and because you might like to use Xine on your development box also!), we will install xine-ui in full to /opt/xine on your development platform, and then prepare the DIET-PC mmedia_xine package from that.

tar xzf ~/diet-pc-src/xine-ui-0.99.5.tar.gz
cd xine-ui-0.99.5
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/xine/lib/pkgconfig \
	./configure --prefix=/opt/xine --with-xine-prefix=/opt/xine \
	--disable-xft --without-curl
# DIET-PC 3: ./configure --prefix=/usr/local --with-xine-prefix=/usr/local \
#	     --disable-xft --without-curl
cd src/xitk
gcc -o xine-remote xine_remote-network.o ../common/libcommon.a \
	/usr/lib/libreadline.a /usr/lib/libtermcap.a -lpthread
gcc -o xine `ls *.o | grep -v xine_remote` \
	../common/libcommon.a xine-toolkit/libxitk.a oxine/liboxine.a \
	Imlib-light/libImlib-light.a ../common/libcommonx.a \
	/opt/xine/lib/ -Wl,-Bstatic -lpng -lfontconfig -lexpat \
	-llirc_client -L/usr/X11R6/lib -lXft -lXrender -lXxf86vm -lXtst \
	-Wl,-Bdynamic -L/usr/lib -lz -lm -lpthread -ldl -L/usr/X11R6/lib \
	-lX11 -lXext -lXv -lXinerama -Wl,--rpath -Wl,/opt/xine/lib
cd ../fb
gcc -o fbxine *.o ../common/libcommon.a -Wl,-Bstatic -lncurses -llirc_client \
	-Wl,-Bdynamic /opt/xine/lib/ -Wl,--rpath -Wl,/opt/xine/lib
cd ../..
sudo make install
sudo strip -R .note -R .comment /opt/xine/bin/{fbxine,xine,xine-remote}
mkdir -p ~/diet-pc/mmedia_xine
~/diet-pc/tools/man2txt /opt/xine/man/man1/xine.1 \
~/diet-pc/tools/man2txt /opt/xine/man/man1/xine-remote.1 \
# Certain modules' dependencies are way too complex for DIET-PC to handle, so
# we'll exclude them:
cat >/tmp/unembeddable.txt <<EOF
tar cCXf / /tmp/unembeddable.txt - opt/xine | bzip2 -9 \
cd ..
rm -rf xine-ui-0.99.5

yaboot 1.3.13

yaboot is specific to the PowerPC port of DIET-PC. It is available from

tar xzf ~/diet-pc-src/yaboot-1.3.13.tar.gz
cd yaboot-1.3.13
vi +79 lib/strstr.c	# insert an empty statement (a semicolon on a line by
			# itself) between "shloop:" and "}" to placate gcc 4.x
mkdir -p ~/diet-pc/templates/yaboot/diet-pc
mkdir -p ~/diet-pc/assembler_installer/files/sbin
strip -R .note -R .comment second/yaboot
cp second/yaboot ~/diet-pc/templates/yaboot/diet-pc/
vi ybin/ofpath		# Substitute "which" for all instances of "command -v"
cp ybin/ofpath ~/diet-pc/assembler_installer/files/sbin/
~/diet-pc/tools/man2txt man/yaboot.8 >~/diet-pc/tools-doc/yaboot.txt
~/diet-pc/tools/man2txt man/yaboot.conf.5 \

xwChoice 1.14

FIXME: Add diet-pc patch

tar xzf ~/diet-pc-src/xwChoice-1.14.tgz
cd xwChoice-1.14
bunzip2 -c ~/diet-pc-src/xwChoice-1.14-dietpc-patch.bz2 | patch -p1 -b
# The "CLAGS" typo is deliberate!
make DEBUG='' CLAGS="$CFLAGS -Wall" XAWLIB=/usr/lib/
strip -R .note -R .comment xwChoice
mkdir -p ~/diet-pc/http_opera/files/usr/X11R6/bin
cp xwChoice ~/diet-pc/http_opera/files/usr/X11R6/bin/
cd ..
rm -rf xwChoice-1.14

zip 3.0

unzip ~/diet-pc-src/
cd zip30
vi unix/Makefile	# Add -DNO_BZIP2_SUPPORT to CFLAGS_NOOPT
vi unix/configure	# Substitute $CFLAGS for "-O3" (two locations)
make -f unix/Makefile generic_gcc IZ_BZIP2=nowhere
strip -R .note -R .comment zip
mkdir -p ~/diet-pc/http_opera/files/usr/bin
mkdir -p ~/diet-pc/storageserver/files/usr/bin
cp zip ~/diet-pc/http_opera/files/usr/bin/
cp zip ~/diet-pc/storageserver/files/usr/bin/
cd ..
rm -rf zip30

zlib 1.2.3

tar xjf ~/diet-pc-src/zlib-1.2.3.tar.bz2
cd zlib-1.2.3
CFLAGS="$CFLAGS -fPIC" ./configure --shared --prefix=''
strip -R .note -R .comment
mkdir -p ~/diet-pc/shell/files/lib
cp ~/diet-pc/shell/files/lib/
cd ..
rm -rf zlib-1.2.3