Hi folks,
mod_WebObjects? Since people are still discussing how to build the Apache adaptors on contemporary OSX, maybe I should add some more commentary.
If you need an Apache module that isn't supplied prebuilt for you, either as part of Apache or as part of what your vendor supplies, always be ready to build your own. Never go looking to download what someone else has already built. It's too likely that
the pre-built one won't work for you.
If you compile something in Java ... you get bytecode, and the class format is defined. Your bytecode can be expected to run in somebody else's JVM. Also, if your code subclassed a class, and the class you subclassed is somehow different, has more member
fields, it will all still work just fine.
In C, by comparison ... Apache is implemented in C. It is structures and pointers and offsets. How big are short, int and long? How does the compiler align these to word boundaries? The size of a structure can be very different if compiled with different
compilers or different compilation options, especially compilation options to do with optimization, even if the C source code declaring the structure is the same. The compiler knows the addresses of fields within a structure by computing offsets from the
structure's address; this can cause something in Objective-C 1 called 'fragile base class syndrome' where adding an instance variable to a class breks all subclasses of that class that have instance variables.... so, avoid all this. Build your own!
Apache provides a way round these problems. Apache modules are supposed to be built via a tool /usr/sbin/apxs ["APache eXtension System"] which is a /usr/bin/perl script to compile and link your source code using the same compiler options as was used to
build Apache.
From memory, we can start by downloading some ProjectWonder source code, and this includes source code for mod_WebObjects, and someone's already added a makefile for building for Apache 2.4 (it's more or less the same as building for Apache 2.2). I tried
this on OSX 10.11 ('El Capitan') mostly to see how it would fail.
Firstly, the build fails because the Makefiles specify building the FastCGI adaptor and by defautl we're missing some headers. We can fix that in make.config by setting
ADAPTORS = CGI Apache2.4
Secondly, Apache 2.4 was built for El Capitan by cross-compilation on Yosemite (10.10). There are some references to this which we need to deal with. Reading /usr/sbin/apxs (on OSX) we find it has a variable installbuilddir = /usr/share/httpd/build and
some configuration variables in a file config_vars.mk in that directory.
There are references to /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain , you might have that if you are on Yosemite and have the El Capitan SDK installed. There are references to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.Internal.sdk
. We fix these by making softlinks that refere to what we do have. For me, this was (as root):
cd /Applications/Xcode.app/Contents/Developer/Toolchains
pwd
ls -l
ln -s XcodeDefault.xctoolchain OSX10.11.xctoolchain
ls -l
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
pwd
ls -l
ln -s MacOSX10.11.sdk MacOSX10.11.Internal.sdk
ls -l
I also encountered an error about not being able to find httpd.h. There's this in make.config:
APACHEINCLUDE_DIR = /usr/include/apache2
which doesn't work on modern OSX because Apple appears to have decided not to do /usr/include any more. We need to use the platform SDKs. I added some stuff to make.config to work out which release of OSX the build was happening on, what the SDK path should
be, and using the SDK path when setting APACHEINCLUDE_DIR.
Next up: there was a linker flag "-macosx_version_min 10.5" which we don't want on OSX 10.8 and later. I changed this to be a variable which is empty unless on 10.4, 10.5, 10.6 or 10.7.
And that's enough to get the Adaptors project to compile and link. I've provided both a patch file of my changes, and a .tar.gz file of the files I changed, which some may find easier to read. Submitting a patch file to this list is not the approved way
of proposing changes to Project Wonder, but I'm not expecting my changes to make it in anyway.
[There is another gotcha which no longer applies to building on OSX. Nowadays, whatever Apple-supplied C or C++ compiler you ask for, you'll get a compiler based on LLVM, which outputs compact omtimised code and ignores optimisation flags. The makefiles
for the mod_WebObjects adaptors refer to gcc and -O2. If somebody built Apache using -Os (and Apple used to do that) then there is a risk of structure size mismatch problems.]
-- Patrick