The Linux Wacom Project Logo

Linux Wacom Project HOWTO

13.4 - Building wacom_drv.o from Scratch


I should tell you out-right that this is a time consuming process.

Why would you want to do this? Two reasons. One, you are a developer and need to make changes to the source code directly. Two, your distribution uses c libraries or configuration options that are not compatible with the wacom_drv.o file that I provide. People running libc5 for instance, would need to build their own driver.

Timothy Klein has submitted a brief howto for compiling on Debian Stable which is still running XFree86 4.1 as of this writing. It covers steps one through four of this document, and a savvy developer should be able to figure out step five on his own. If someone solves step five and generates a patch to, I'll see what I can do about getting it into the configuration script. That document is on the Installing wacom driver On Debian page.

You will need the X source code to rebuild the wacom_drv.o driver. The build configuration for X generates a number of header files that are necessary but not installed by default on most distributions. Consequently, you will need to not only get the source, but build it, practically in its entirety. Then, after all that, the configure script can be instructed to hook into the X build tree and rebuild wacom_drv.o at any time without having to rebuild X again.

Since I am running Redhat 8.0 and cannot really pull down the original XFree86 4.2.0 source code, compile it, and expect it to work on my system, I need to instead use the source RPM provided by Redhat. If you choose to go this route, I provide pretty detailed instructions for making this work. If your distribution works differently, or you are using Gentoo where most everything is source code by default, you'll need to handle this as best as possible according to your particular situation.

Step One: Get The Source

On Redhat 8.0, I discovered the version number for my currently installed XFree86 packages by running rpm -q XFree86. This reported version 4.2.0-72, therefore the source package is XFree86-4.2.0-72.src.rpm. I downloaded the package from Redhat directly and installed it to the system as follows:

[root@sen src]# rpm -ivh XFree86-4.2.0-72.src.rpm
   1:XFree86                ########################################### [100%]

This installs a number of files to the /usr/src/redhat directory, particularly in the SOURCES and SPECS subdirectories. Other distributions undoubtedly install elsewhere. Look for the XFree86.spec file which should be located in the SPECS directory. This file contains all the information necessary to patch the orginal XFree86-4.2.0 source code to the level that Redhat is distributing in their regular binary package. The source code and patch files are located in SOURCES.

Step Two: Build the Source

This step describes how to build the source from the RPM itself. If you are building from some other mechanism, I honestly cannot offer much assistance since I generally don't build my X system from scratch. If you'd like to write up a short section on building the server for your particular distribution, I would be happy to include it here.

Next, you don't actually have to build the entire thing. The point at which the xf86Wacom.c driver can be built however, is not until somewhere in the middle of the build process. The driver depends on a number of header files that are created dynamically so until they are generated, wacom_drv.o cannot be compiled. My solution was to open a separate terminal in the wacom driver directory and periodically attempt to build it. When it successfully built, I stopped the X build process. Here's how to build the source for an RPM that's been exploded out into the SPECS and SOURCES directories.

[root@sen root]# cd /usr/src/redhat
[root@sen redhat]# rpmbuild -bc SPECS/XFree86.spec

Not every distribution has rpmbuild; try using just rpm instead. At some point, Redhat split the build functionality into separate programs. If after looking through the rpm man page, you still cannot get this to work, send me some email, and I'll look into it.

The important item is the "-bc" option of rpmbuild which unpacks, patches, and builds the source without actually installing. While it is also possible to simply unpack and patch using the "-bp" option, there does not seem to be a way to just build. The "-bc" option simply deletes all the files provided by "-bp" and recreates them again. The downside of this is that if you wanted to simply unpack, patch, and then copy the new xf86Wacom.c file over the old one, you'll find that the build step deletes it and starts over again. I have gotten this to work by creating a new patch file, but this requires a bit more effort, so I don't recommend it right off.

Step Three: Build the Original Driver

The xf86Wacom.c file is buried pretty deep in the X build tree. If it is in a different location than the one I have provided below, try using find . -name xf86Wacom.c from the BUILD directory.

[root@sen redhat]# cd BUILD/XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/input/wacom
[root@sen wacom]# ls
Imakefile    xf86Wacom.c.Wacom-USB-driver-a25-update
Makefile   xf86Wacom.c
The "a25-update" file is the original xf86Wacom.c file before Redhat's patch. If you open xf86Wacom.c, you'll find that it is version 25, at least as of this writing and this distribution. The presence of the Makefile means that the configuration has at least been run for this directory. If you have built a sufficient portion of the X source files, then all the header files that you need have been generated, and you can build xf86Wacom.c. Try it, and if it does not build, wait a bit. The absence of xf86Version.h for instance, is a good indication that the build process is not ready.
[root@sen wacom]# make
rm -f xf86Wacom.o
gcc -O2 -march=i386 ... -c xf86Wacom.c
ld -r xf86Wacom.o -o wacom_drv.o

Step Four: Automating the Build Process

By configuring the package with the --with-xf86 option set to the XFree86 build tree, you can build the driver outside of the X build tree.

[jej@ayukawa wacom]$ ./configure \
            XFree86 - yes
        wacom_drv.o - yes
[jej@ayukawa wacom]$ make

The makefile rule which builds the driver is contained within src/ and is modified according to the configuration to generate a rule similar to this in src/Makefile:

xf86Wacom.o: xf86Wacom.c
        gcc -O2 -march=i386 -mcpu=$(ARCHITECTURE) -pipe -ansi \
                -pedantic -Wall -Wpointer-arith -fno-merge-constants \
                -I. -I$(XF86_DIR)/programs/Xserver/hw/xfree86/common \
                -I$(XF86_DIR)/programs/Xserver/hw/xfree86/loader \
                -I$(XF86_DIR)/programs/Xserver/hw/xfree86/os-support \
                -I$(XF86_DIR)/programs/Xserver/include \
                -I$(XF86_DIR)/programs/Xserver/mi \
                -I$(XF86_DIR)/exports/include/X11 \
                -I$(XF86_DIR)/include/extensions \
                -I$(XF86_DIR) \
                -I$(XF86_DIR)/exports/include \
                -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE \
                -DSINGLEDEPTH -DXFreeXDGA -DXvExtension -DXFree86LOADER \
                -DXFree86Server -DXF86VIDMODE -DXvMCExtension \
                -DSMART_SCHEDULE -DBUILDDEBUG -DXResExtension \
                -DNARROWPROTO -DIN_MODULE -DXFree86Module -DLINUX_INPUT \
                -o xf86Wacom.o -c xf86Wacom.c
similar rules applie to wcmSerial.c, wcmUSB.c, wcmISDV4.c, wcmCommon.c, wcmCompat.c, wcmConfig.c, and, wcmFilter.c.

The options and directories specified come directly from the output of the make command in the previous step. All the root and parent directories have been replaced with the macro XF86_DIR which in this case is set by the configuration script to /usr/src/redhat/BUILD/XFree86-4.2.0/xc. If the options that you see in your build are identical to those above, then the default rule will work for you now. If not, you'll need to make some alterations. You can update the file and rerun automake, update the and rerun configure, or just update the Makefile directly.

So long as the X build tree exists, the include directories will point to the correct locations, and the driver will build. If space is an issue, you can probably remove all the non-essential directories, but be careful; the dependency tree in X is huge.

Copyright (C) 2002-2011 - LinuxWacom -Last updated July 23, 2012
This website and its contents are licensed under the GNU GENERAL PUBLIC LICENSE.