Q:

Qt 5.2.1 fails to build on mac OSX 10.8.5

I downloaded Qt 5.2.1 (the .tar.gz) on my Macbook running OS X 10.8.5 with xcode 5.0.2, unzipped, and ran this configure:
./configure -prefix $PWD/qtbase -debug-and-release -developer-build -no-c++11 -opensource -plugin-sql-sqlite -qtlibinfix _fmosoft -nomake tests -skip qtwebkit -skip qtwebkit-examples -no-compile-examples

I have a few patches to add to Qt5.2.1, so I can't just install the binaries.  But I thought I'd first try to build without any patches, just using the unzipped code with my configuration options.  Configure succeeds, then I run
make

That runs for about 5 minutes, then gives me this error:
../corelib/global/qt_pch.h:58:10: error: 'qglobal.h' file not found with
      <angled> include; use "quotes" instead
#include <qglobal.h>
         ^~~~~~~~~~~
         "qglobal.h"
../corelib/global/qt_pch.h:64:10: fatal error: 'qcoreapplication.h' file not
      found
#include <qcoreapplication.h>
         ^
2 errors generated.
make[4]: *** [.pch/debug/QtNetwork_fmosoft_debug/c++.pch] Error 1
make[3]: *** [debug-all] Error 2
make[2]: *** [sub-network-make_first] Error 2
make[1]: *** [sub-src-make_first] Error 2
make: *** [module-qtbase-make_first] Error 2

What am I doing wrong?  How do I build Qt5.2.1 on my Macbook?

A:

The prefix is the installation prefix, it makes no sense for it to point to the qtbase folder in the build directory. Build directory is where you must invoke configure.
The following worked for me (dumped from .bash_history from an actual build on OS X 10.9):
mkdir $HOME/Qt/build-5.2.1
cd $HOME/Qt/build-5.2.1
~/Qt5.2.1/5.2.1/Src/configure -prefix "$HOME/Qt/5.2.1" -debug-and-release \
  -no-pkg-config -opensource -confirm-license -optimized-qmake \
  -nomake examples
make -j2
make install

After make install, you get it installed to $HOME/Qt/5.2.1. That's what the prefix is.

