XFree86 on Darwin and Mac OS X : Appendix
Previous: Outstanding Issues with the X server
Next: XFree86 on Darwin and Mac OS X

6. Appendix

6.1. Installing IOKit Header files on Mac OS X Beta

Here is what you need to do to be able to build XFree86 (or other clients of IOGraphics services) on Mac OS X Public Beta.

  1. You need to install some more build tools that aren't included in Mac OS X Beta, but are included in Darwin. These are needed for the next step. Go to your development directory and type:
    cvs checkout bootstrap_cmds
    cd bootstrap_cmds
    Now su to root and do a ``make install'' from the bootstrap_cmds directory.
  2. The IOKit framework included with Mac OS X Beta is a little on the wimpy side, even after installing the Developer Tools. You'll need to rebuild it, but to do so safely we'll take advantage of the cool directory structure of Mac OS X and put the new version in /Library/Frameworks/. This will override the version in /System/Library/Frameworks/. Or at least, that's where you should put it using the new Mac OS X Beta file structure, but in fact the compiler doesn't know this and still looks in /Local/Library/Frameworks. (I have already filed a developer's bug report on this.) To start we make a copy of the original. Login as root and do the following:
    cd /Library
    mkdir -p Frameworks
    cp -R /System/Library/Frameworks/IOKit.framework Frameworks/IOKit.framework
    cd /
    mkdir -p Local
    ln -s /Library /Local/Library
  3. Now you need to get a full version of the IOKit framework from the Darwin repository. This comes as part of the kernel. So, in your development directory again:
    cvs checkout xnu
    cd xnu
    source SETUP/setup.csh
    make exporthdrs
    make install
    The "make install" will start by assembling all the headers you need, but then will proceed to build a new kernel. You can Control-C out of the build once it starts compiling things if you want. Otherwise, just be patient.
  4. You also need to get the IOKitUser project, which contains the user interface to the IOKit, and merge it into the IOKit framework. From your development directory type:
    cvs checkout IOKitUser
    Then you need to change the Makefile so it builds on top of the new IOKit framework you are building. Change to the IOKitUser project directory and edit the Makefile. Change the following line:
    NEXTSTEP_BUILD_OUTPUT_DIR = <your xnudir>/BUILD/dst/System/Library/Frameworks
    Now, run ``make'' while in the IOKitUser directory. It will likely not finish building since the IOKitUser project relies on some stuff that Apple hasn't really made public yet, but it should finish populating the new IOKit framework with headers and start compiling. (Strangely enough, the headers installed in your new IOKit framework don't contain the real header files. They are just single line files with an #import of the file in your IOKitUser project. This works fine as long as you don't ever delete or move your IOKitUser project. I imagine that using ``make install'' would fix this up, but you can't do this as long as the project doesn't build correctly. So for now you can either move the header files by hand, or make sure you leave your IOKitUser project in place.)
  5. Now put the new IOKit headers into our local copy. Change to the xnu project directory and do the following as root:
    cd BUILD/dst/System/Library/Frameworks/
    cp -R IOKit.framework/Versions/A/Headers/* \
  6. The System framework needs touching up a bit too. You need to copy the libkern header files from the new System.framework. As root, go to the xnu project directory and type: (Of course you could make a local copy of the System framework in /Library/Frameworks/, but the additions to the System framework are small.)
    cd BUILD/dst/System/Library/Frameworks/System.framework/Versions/B/Headers
    cp -R libkern /System/Library/Frameworks/System.framework/Headers/libkern

6.2. Installing IOKit Header files on Mac OS X DP4

Here is an outline of what you need to do to be able to build XFree86 (or other clients of IOGraphics services) on Mac OS X Developers' Preview 4.

  1. Checkout, build, and install bootstrap_cmds from the CVS repository.
  2. Checkout xnu from the CVS repository. Go to sandbox/xnu and do the following:
    source SETUP/setup.csh
    make exporthdrs
  3. su to root and do the following:
    mkdir -p /Local/Library/Frameworks
    cp -R /System/Library/Frameworks/IOKit.framework /Local/Library/Frameworks
    This will create a new local version of the IOKit framework that will override the System version without changing the original.
  4. You now want to merge the IOKit headers from the xnu project into your local IOKit framework. I did this fairly tediously by hand, but I would suggest something like:
    cp -R sandbox/xnu/BUILD/dst/System/Library/Frameworks/IOKit.framework/Versions/A/Headers \
    The only problem with this is that there are a few stub header files included that are just a single line with an #import to the appropriate place in the xnu source on your disk. This is fine as long as you don't move your xnu project. If you do, you can copy the original file to replace the stub. There is probably an easier way to automatically build a clean version of the IOKit framework, but I didn't find it. (Let me know if you do.)
  5. There are just a few more files you need in the IOKit framework. Checkout the IO project from CVS. Get the necessary header files from there and put them in your new local IOKit framework. You'll get errors when you try to build XFree86 from which you can tell which files are needed. I also needed to make the following patch to IOLLEvent.h. Your mileage may vary.
    < #include <Kernel/libkern/OSTypes.h> 
    > #include <libkern/OSTypes.h>
  6. You'll also need a few extra CoreFoundation header files. Checkout CoreFoundation. You can make a new local version of the CoreFoundation framework as above, or just add to the existing one. The files you need are CFMachPort.h and CFMessagePort.h in the RunLoop.subproj and CFStorage.h in Collections.subproj.

XFree86 on Darwin and Mac OS X : Appendix
Previous: Outstanding Issues with the X server
Next: XFree86 on Darwin and Mac OS X