Universal difficulty of Makefile in Mac OS X: PowerPC, Intel or both?

These days, "universal" build in OS X means building universal binaries for i386 (32-bit addressing architecture) and x86_64 (64-bit addressing architecture).

But Macintosh was once a PowerPC architecture. When Apple decided to transition from PowerPC to Intel, there was quite a disarray in the development environment in OS X; at that time, PowerPC 32-bit, PowerPC 64-bit, i386 32-bit and x86_64 64-bit are OS X's possible build target architectures.

Now I'm trying to update Makefiles of a library which is intended to be used under various OSs. Current Makefiles for OS X try to create universal binaries of PowerPC 32-bit, i386 32-bit and x86_64 64-bit; yet as I mentioned in the first line in this post, OS X these days (I mean 10.8) no longer provides a dev toolchain for compiling PowerPC binaries, so that I have to update Makefiles to be able to decide whether PowerPC binaries can be compiled or not depending on the current OS X version and its dev toolchains.

Here, I selfishly assume that Intel Mac folk using this library does not need the PowerPC cross-compiling capability anymore; no need for PowerPC binaries for Intel Mac, just i386/x86_64 binaries for Intel Mac are enough. For PowerPC Mac folk, well, I will leave the i386/x86_64 cross-compiling capability there as before.


Now, I have to formulate a way to check availability of PowerPC dev toolchain…

file, uname and machine commands can display architecture information, so that what I have to do is to collect this information in the supported OS X versions of the library (quick googling had no hit about architecture information in each OS X version).

Fortunately, I have OS X install DVDs (through 10.3 to 10.6 with exception of 10.4; I think I rent it to someone and lost it… I have iBook and old iMac with OS X 10.4.11 installed, maybe I should backup the boot volume into a volume image using asr). With chroot command, I can change the root directory in a shell session; by using this feature I think I can access executables and dev toolchain in install DVDs to check architecture information for at least Intel-compatible OS X versions.

If it did not work, with Oracle's VirtualBox or QEMU, I can still try preparing OS X virtual machines using these install DVDs, then in this case I can definitely collect the information.

Update:

# Makefile code snippet
#
#OS=$(shell uname)
#…
ifeq ($(OS), Darwin)
# 10.1-10.5: PPC supported?
# 10.4-10.4: PPC and Intel?
# 10.6-:     Intel only
ifneq ($(shell sw_vers -productVersion | grep -e "^10\.[1-5].*"), )
    MAKEFILE = MAKEFILE.osx_before_10_6
else
    MAKEFILE = MAKEFILE.osx
endif
else ifeq ($(OS), Cygwin)
#…

I updated the Makefile for guessing the host OS. Guessing for the host OS version relies on command sw_vers -productVersion, which outputs the version identifier (I am somewhat suspicious about availability of sw_vers because its man page does not provide HISTORY section; I could at least confirm sw_vers is available in my iBook in which Mac OS X 10.4.11 is installed).

I feel grep command grep -e "^10\.[1-5].*") is too slack; MAKEFILE.osx_before_10_6 is a Makefile for building PowerPC/i386/x86_64 binaries, and yet some earlier Mac OS X versions does not have the i386/x86_64 cross-compilation capability, like in Mac OS X 10.1 .
I could not find a clear statement about supported version range of Mac OS X for this library, but I still feel the need for setting the minimum version requirement, say, to Mac OS X 10.4 .

Comments

Popular posts from this blog

Hardcoding Data Like Images and Sounds into HTML or CSS

DDS for GIMP (Mountain Lion, Native, no X11 GUI)

Make It Work: Global .gitattributes