Xcode: External Target or External Build SystemSunday, June 22. 2008Recently I've become more and more addicted to the Xcode environment. Prior to using Xcode I was strictly a vi (specifically elvis a vi clone) power user. Good old vi served well as a multi platform editing tool, however I am finding that I perform most of initial development on a Mac Desktop (when I first started programming I worked from a Linux desktop) and then copy the source to other platforms (Linux, FreeBSD, Solaris, and Windows) for testing and deployment. This usually means that 90% of my time is spent working from a Mac desktop. Although vi is an invaluable tool, I prefer writing code in Xcode. This has led me to figure out how to write the code in Xcode and compile it using a GNU Autoconf/Automake/Libtool/Make environment. It turns out to be pretty simple. Xcode has the ability to configure an Xcode target to call an external script. The arguments passed to the script can be configured, but Xcode will pass the requested action (clean, install, etc) by default. To configure Xcode 3.0 to create a target which calls make, follow these steps:
This should create a target which defaults to calling /usr/bin/make. If you do not need to call configure, you are now done. If like me you use GNU Autoconf and GNU Automake to help port projects to different platforms, you need to create an additional target which will create the make file. Follow these steps to create a target which will create the Makefile by running configure:
The second target essentially tells make to use an alternative Makefile (Makefile-xcode) to generate the Makefile used by the rest of the project. Automake, and autoconf can also be run to generate configure, Makefile.in, config.h.in, etc, by using a longer Makefile-xcode. For example the following Makefile-xcode uses autoconf and automake: # # Makefile-xcode - automate Automake compiling from Xcode # # GNU build tools ACLOCAL ?= /opt/local/bin/aclocal AUTOCONF ?= /opt/local/bin/autoconf AUTOHEADER ?= /opt/local/bin/autoheader AUTOMAKE ?= /opt/local/bin/automake # local targets for building environment all: Makefile aclocal.m4: Makefile-xcode acinclude.m4 configure.ac $(ACLOCAL) touch aclocal.m4 config.h.in: Makefile-xcode aclocal.m4 $(AUTOHEADER) touch config.h.in configure: Makefile-xcode aclocal.m4 configure.ac $(AUTOCONF) touch configure Makefile.in: Makefile-xcode Makefile.am configure $(AUTOMAKE) touch Makefile.in Makefile: Makefile-xcode configure Makefile.in config.h.in ./configure --enable-dependency-tracking clean: test -f Makefile && make distclean install: # end of Makefile file Well that's it for now. I hope this is helpful to the autoconf, automake, Xcode users out there.
(Page 1 of 1, totaling 1 entries)
Competition entry by David Cummins powered by Serendipity v1.0 |
ArchivesAuthors loginBlog Administration |