#!/bin/sh

prefix=/m10opt/dist
exec_prefix=${prefix}
exec_prefix_set=no

usage()
{
	cat <<EOF
Usage: mozilla-config [OPTIONS] [LIBRARIES]
Options:
	[--prefix[=DIR]]
	[--exec-prefix[=DIR]]
	[--version]
	[--libs]
	[--cflags]
EOF
	exit $1
}

if test $# -eq 0; then
	usage 1 1>&2
fi

while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  case $1 in
    --prefix=*)
      prefix=$optarg
      if test $exec_prefix_set = no ; then
        exec_prefix=$optarg
      fi
      ;;
    --prefix)
      echo_prefix=yes
      ;;
    --exec-prefix=*)
      exec_prefix=$optarg
      exec_prefix_set=yes
      ;;
    --exec-prefix)
      echo_exec_prefix=yes
      ;;
    --version)
      echo -1
      exit 0
      ;;
    --cflags)
      if test "${prefix}/include" != /usr/include ; then
        includes="-I${prefix}/include"
      fi
      echo_cflags=yes
      ;;
    --libs)
      echo_libs=yes
      ;;
    *)
      usage 1 1>&2
      ;;
  esac
  shift
done

if test "$echo_prefix" = "yes"; then
	echo $prefix
fi
if test "$echo_exec_prefix" = "yes"; then
	echo $exec_prefix
fi
if test "$echo_cflags" = "yes"; then
	cflags=" -DMOZ_DEFAULT_TOOLKIT=\"gtk\" -DSTDC_HEADERS=1 -DHAVE_INT64_T=1 -DHAVE_INT64=1 -DHAVE_UINT=1 -DHAVE_UINT_T=1 -DHAVE_MEMORY_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_IPC_H=1 -DHAVE_SHM_H=1 -DHAVE_SYS_SHM_H=1 -DHAVE_X11_EXTENSIONS_XSHM_H=1 -DHAVE_LIBM=1 -DHAVE_LIBDL=1 -DHAVE_LIBSOCKET=1 -DHAVE_LIBNSL=1 -DHAVE_LIBW=1 -DHAVE_RANDOM=1 -DHAVE_QSORT=1 -DHAVE_STRERROR=1 -DHAVE_FCHMOD=1 -DHAVE_LOCALTIME_R=1 -DHAVE_MEMMOVE=1 -DHAVE_GETTIMEOFDAY=1 -DGETTIMEOFDAY_TWO_ARGS=1 -DHAVE_VALLOC=1 -DHAVE_SYSERRLIST=1 -DHAVE_OSTREAM=1 -DNEEDS_bool=1 -DHAVE_CPP_SPECIALIZATION=1 -DHAVE_CPP_USING=1 -DHAVE_I18N_LC_MESSAGES=1 -DMOZ_MAIL_NEWS=1 -DNECKO=1 -DMOZ_MONOLITHIC_TOOLKIT=1 -DClientWallet=1 -DCookieManagement=1 -DSingleSignon=1 -DNDEBUG=1 -DTRIMMED=1 -DMOZ_USER_DIR=\".mozilla\" -DMOZ_DLL_SUFFIX=\".so\" -DXP_UNIX=1 -DUNIX_EMBED=1 -DX_PLUGINS=1 -DUNIX_LDAP=1 -DUNIX_ASYNC_DNS=1 -DJS_THREADSAFE=1 -DLAYERS=1 -DNGEDITOR=1 "
	echo $includes $cflags
fi
if test "$echo_libs" = "yes"; then
	echo -L${exec_prefix}/lib -lxpcom
fi
