Tag Archives: compile

Using Zend Debugger with your custom built PHP – on an Intel Mac with Leopard

Maybe you’ve had your go at this problem already: Trying to make ZendDebugger work with a custom built PHP on a Mac. I’ve been hammering at this problem for some days now – just to find out that the problem is a trivial one. For some reason unknown to me Zend choose to build the ZendDebugger.so as a 32 bit module. If, however, you compile and run software on an Intel-Mac using Mac OS X 10.5 Leopard, the software will automagically run in 64 bit mode. And that’s why Apache+libphp5.so and also the CLI version of PHP won’t run the ZendDebugger.

So, the easy solution would be to just create 32 bit executables when building Apache/PHP. Did I just say “easy”? How is one to build a 32 bit application in the Mac you might ask yourself. Well, again, that’s easy. You’d just have to pass “-arch i386” to gcc when compiling the app. But how to do that, now?

As luck has it, most Open Source applications by now know about the Mac platform. Thus, they handle it within their configure scripts. A commonly used compiler option that gets set on the Mac is “-no-cpp-precomp”. So basically all you have to do is:

  • get the archive of the app you want to build
  • untar
  • do a ‘grep -R “-no-cpp-precomp” *’
  • take note of all the files the above command finds
  • use the script below
  • configure and compile as usual

The script I mentioned above is quite short:

#!/bin/bash
for FILE in $*; do
    sed -e “s/-no-cpp-precomp/-no-cpp-precomp -arch i386/g” $FILE > tmpfile
    mv tmpfile $FILE
done

I called mine “macify” and put it in /usr/local. The script will add the compile flag needed for generating 32 bit executables/libraries to the files you pass it one the command line. For PHP the command would be “macify configure configure.in”, for apache it would be “macify srclib/apr/configure srclib/apr/build/apr_hints.m4”.

By the way: you don’t have to do this for all apps and libraries you need in the process of building the final app. Since the gcc version used on Mac OS X will generate “universal” binaries and libraries, you just have to modify the final app like that while you can compile all supporting libraries without any modifications.

Would be nicer, though, if Zend could come up with a 64 bit version of the ZendDebugger.