# mozconfig.common only exists in mozilla-central
if test -e "$topsrcdir/mozilla/build/macosx/universal/mozconfig.common" || test -e "$topsrcdir/build/macosx/universal/mozconfig.common"; then

  # Now in comm-central land.
  if test -e "$topsrcdir/mozilla/build/macosx/universal/mozconfig"; then
    oldtopsrcdir=$topsrcdir
    export topsrcdir=$topsrcdir/mozilla
  else
    # Big Hack that unsets CC / CXX so that mozconfig.common doesn't get
    # mixed up with host/target CPUs when trying to work out how to do the
    # universal build. When we redo the build system (bug 648979) this will
    # go away.
    unset CC
    unset CXX
  fi

  . $topsrcdir/build/macosx/universal/mozconfig

  if test -n $oldtopsrcdir; then
    export topsrcdir=$oldtopsrcdir
  fi

  #Use ccache
  ac_add_options --with-ccache=/opt/local/bin/ccache
else
  # Treat this as a 1.9.2 mozconfig. Here we are accepting that 1.9.2 try
  # server builds will only work with 10.5 and above and only on i386
  # architecture. This simplifies what builders we need on try server.

  # 1.9.2 specific options.
  ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.5.sdk
  ac_add_options --enable-macos-target=10.5
  ac_add_options --target=i386-apple-darwin9.2.0
  ac_add_options --enable-static
  ac_add_options --disable-shared
  ac_add_options --disable-crashreporter
  CC="gcc-4.2 -arch i386"
  CXX="g++-4.2 -arch i386"
  HOST_CC="gcc-4.2"
  HOST_CXX="g++-4.2"
  RANLIB=ranlib
  AR=ar
  AS=$CC
  LD=ld
  STRIP="strip -x -S"
  CROSS_COMPILE=1
fi

ac_add_options --enable-application=mail
ac_add_options --enable-update-channel=nightly
ac_add_options --enable-update-packaging
ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --enable-tests
ac_add_options --enable-codesighs
ac_add_options --disable-install-strip

export CFLAGS="-gdwarf-2"
export CXXFLAGS="-gdwarf-2"

# For NSS symbols
export MOZ_DEBUG_SYMBOLS=1
ac_add_options --enable-debug-symbols="-gdwarf-2"

# Needed to enable breakpad in application.ini
export MOZILLA_OFFICIAL=1

if [ -f $topsrcdir/mozconfig-extra ] ; then
  . $topsrcdir/mozconfig-extra
fi
if [ -f $topsrcdir/mozconfig-extra-macosx64 ] ; then
  . $topsrcdir/mozconfig-extra-macosx64
fi

# Enable parallel compiling
CONCURRENCY=$(( `sysctl hw.logicalcpu | awk {'print $2'}`  + 2 ))
mk_add_options MOZ_MAKE_FLAGS="-j$CONCURRENCY"
