Building your own TCL Extension

tjmcs edited this page Jun 14, 2012 · 1 revision

Building your own extensions for Tiny Core Linux (or for the Razor Microkernel) isn't that hard once you get things set up properly. The hardest thing to deal with is the fact that every thing you are doing is in memory, so if you take a misstep along the way that you can't easily recover from, you'll have to start again from scratch. It's probably easier to describe this process with a real example in mind, so on this page we will walk through the process that we followed to build a new TCL extension containing the Open Virtual Machine Tools package, which can be found here.

Getting Started

To start the process of building a an extension for the Microkernel, you'll first have to get your hands on a recent version of Tiny Core Linux (we'll use the "Core" distribution in this example, but the TinyCore distribution would work just as well (and has an X-Windows environment in it if you don't want to do everything from the command line). Simply download your preferred ISO from the Tiny Core Linux download page, which can be found here.

Once you have your preferred ISO downloaded, the next step in the process is to boot a new virtual machine using that ISO. You can use any VM framework you'd prefer, and we will assume here that you know the basics of how to create a virtual machine in that framework, boot the VM using an ISO from the host filesystem (your Tiny Core Linux ISO), and obtain console (or X-Windows) access to that VM once it's running. In this example, we happened to use a relatively recent version of VMware Workstation that was running on an Ubuntu 12.04 (64-bit Desktop) host, but you should be able to follow this same procedure using VMware Fusion or even KVM for your virtual machine environment.

Setting up your build environment

Now that we've got the TCL instance up and running, the first step in the process is to install the "build tools" and the apps that you'll need for the build process (Note: these are only needed for the build process, not to run the tools/modules)

tce-load -iw compiletc.tcz
tce-load -wi linux-headers-3.0.21-tinycore.tcz
tce-load -iw squashfs-tools-4.x.tcz
tce-load -iw glibc_apps.tcz
tce-load -iw commoncpp2.tcz

Next, we'll need to install some tools that the open-vm-tools package depends on (these extensions are needed to compile/run successfully). This list will change depending on the actual package you are building an extension for.

tce-load -iw glib2-dev.tcz
tce-load -iw fuse.tcz
tce-load -iw procps.tcz
tce-load -iw libdnet.tcz

We're almost ready to start building our executable, but first we need to get a copy of the package we're going to be building (in this example the "Open Virtual Machine Tools" package):

wget http://sourceforge.net/projects/open-vm-tools/files/open-vm-tools/stable-8.8.x/open-vm-tools-8.8.2-590212.tar.gz

And we need to set some FLAGS for the complilation process (the flags shown here are those that had to be set to successfully build the Open Virtual Machine Tools package, the flags you have to set for other packages may have different values than those shown here)

export CFLAGS="-march=i486 -mtune=i686 -Os -pipe -Wno-error=unused-but-set-variable"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -Wno-error=unused-but-set-variable"
export LDFLAGS="-Wl,-O1"

Next, unpack the gzipped tarfile we downloaded (above) and change directories into the "build directory" that is created when the gzipped tarfile is unpacked

tar zxvf open-vm-tools-8.8.2-590212.tar.gz
cd open-vm-tools-8.8.2-590212

And follow the 'normal process' for configuring the package (note the use of the RPCGEN setting in the configure command for the Open Virtual Machine Tools package, without this the build will fail because the "rpcgen" and "cpp" commands won't be found)

./configure --without-pam --prefix=/usr/local --without-x --without-icu \
   RPCGEN="$(readlink -f $(which rpcgen)) -Y "$(dirname $(which cpp))

And build the it

make

Now that we have the package successfully built, we can use the contents of this directory to build an extension (using mksquashfs)

touch /tmp/mark
make DESTDIR=/tmp/open_vm_tools install-strip
cd /tmp
mksquashfs open_vm_tools open_vm_tools.tcz

Note the use of the 'install-strip' option to the make command (above). This will strip out debugging information from the installed package. If the package you are building does not support this option (Open Virtual Machine Tools does) then you can just use 'install' in this command instead. While we're here, we'll a gzipped tarfile containing the contents of that same directory directory (in case something should go wrong)

cd open_vm_tools
tar zcvf ../open_vm_tools.tar.gz ./

And copy that gzipped tarfile (and the extension that we just built) over to an external machine (so that it won't be lost when we power off this virtual machine)

scp ../open_vm_tools.tar.gz ../open_vm_tools.tcz root@192.168.3.32:./
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.