AC_PREREQ(2.52)

AC_INIT(nautilus-actions, 1.2, http://www.grumz.net)
AM_CONFIG_HEADER(config.h)

AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)

AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")

AM_MAINTAINER_MODE
                                                                                
AM_DISABLE_STATIC
AC_PROG_CC
AM_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_MAKE_SET

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
        AC_MSG_ERROR([You need to install pkg-config])
fi

dnl --------------------------------------------------

GLIB_REQUIRED=2.4.0
GTK_REQUIRED=2.4.0
GLADE_REQUIRED=2.4.0
GNOME_REQUIRED=2.7.0
NAUTILUS_EXTENSION=2.8.0
GCONF_REQUIRED=2.8.0
LIBXML_REQUIRED=2.6.0
GOBJECT_REQUIRED=2.4.0

AC_SUBST(GLIB_REQUIRED)
AC_SUBST(GTK_REQUIRED)
AC_SUBST(GLADE_REQUIRED)

PKG_CHECK_MODULES(NAUTILUS_ACTIONS,\
	 glib-2.0 >= $GLIB_REQUIRED                \
	 gthread-2.0 >= $GLIB_REQUIRED             \
	 gmodule-2.0 >= $GLIB_REQUIRED		  \
	 gtk+-2.0    >= $GTK_REQUIRED             \
	 libglade-2.0 >= $GLADE_REQUIRED            \
	 libgnome-2.0 >= $GNOME_REQUIRED	\
	 libgnomeui-2.0 >= $GNOME_REQUIRED	\
	 gconf-2.0 >= $GCONF_REQUIRED \
	 libnautilus-extension >= $NAUTILUS_EXTENSION \
	 uuid)
AC_SUBST(NAUTILUS_ACTIONS_CFLAGS)
AC_SUBST(NAUTILUS_ACTIONS_LIBS)
AC_ARG_WITH(nautilus-extdir,
[ AC_HELP_STRING([--with-nautilus-extdir=EXTDIR],
					  [EXTDIR define the folder where nautilus stores its extentions plugins. [default=auto]])],
[ NAUTILUS_EXTENSIONS_DIR=$withval ],
[ NAUTILUS_EXTENSIONS_DIR=`$PKG_CONFIG --variable=extensiondir libnautilus-extension` ])

AC_SUBST(NAUTILUS_EXTENSIONS_DIR)

if test -z ${NAUTILUS_EXTENSIONS_DIR}; then
	AC_MSG_ERROR([*** Can't determine nautilus extension folder, please use --with-nautilus-extdir options to define it manually ]);
fi

OPTIONAL_SUBDIR="utils"
BUILD_COMMANDLINE_TOOL="yes"
AC_ARG_ENABLE(commandline-tool,
[  --enable-commandline-tool            define if command line tools must be build (disable it if you have GTK+ <= 2.4).
                           [default=auto]],
[ BUILD_COMMANDLINE_TOOL=$enableval ])
if test "x$BUILD_COMMANDLINE_TOOL" = "xno"; then
   OPTIONAL_SUBDIR=""
fi
$PKG_CONFIG glib-2.0 --max-version=2.4
if test "x$?" = "x0"; then
	OPTIONAL_SUBDIR=""
fi
AC_SUBST(OPTIONAL_SUBDIR)

default_config_path=`eval echo $datadir/nautilus-actions`
AC_DEFINE_UNQUOTED(DEFAULT_CONFIG_PATH, "$default_config_path", [Default system configuration path])
$PKG_CONFIG glib-2.0 --atleast-version=2.8
if test "x$?" = "x0"; then
	AC_DEFINE_UNQUOTED(HAVE_GLIB_2_8, 1, [Version of the glib-2.0 library is at least 2.8])
fi

PKG_CHECK_MODULES(NAUTILUS_ACTIONS_UTILS,\
	 glib-2.0 >= $GLIB_REQUIRED                \
	 gthread-2.0 >= $GLIB_REQUIRED             \
	 gmodule-2.0 >= $GLIB_REQUIRED		  \
	 gconf-2.0 >= $GCONF_REQUIRED \
	 gobject-2.0 >= $GOBJECT_REQUIRED \
	 libxml-2.0 >= $LIBXML_REQUIRED)
AC_SUBST(NAUTILUS_ACTIONS_UTILS_CFLAGS)
AC_SUBST(NAUTILUS_ACTIONS_UTILS_LIBS)

dnl --------------------------------------------------

GNOME_COMPILE_WARNINGS

GNOME_COMMON_INIT

dnl **** GConf support ***
AC_PATH_PROG(GCONFTOOL, gconftool-2)
AM_GCONF_SOURCE_2

# List of supported languages has been moved into po/LINGUAS to make
# translators' life easier :)
# More info here : http://live.gnome.org/GnomeGoals/PoLinguas
AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
ALL_LINGUAS="`grep -v '^#' "$srcdir/po/LINGUAS"`"

GETTEXT_PACKAGE=nautilus-actions
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [GetText Package])
                                                                               
AM_GLIB_GNU_GETTEXT
AC_PROG_INTLTOOL

if test "x${exec_prefix}" = "xNONE"; then
	if test "x${prefix}" = "xNONE"; then
		if test "x${bindir}" = "xNONE"; then
			BINDIR=`eval echo $ac_default_prefix/bin`
		else
			BINDIR=`eval echo $bindir`
		fi
	else
		BINDIR=`eval echo $prefix/bin`
	fi
else
	BINDIR=`eval echo $bindir`
fi
AC_SUBST(BINDIR)
	
if test "x${prefix}" = "xNONE"; then
  DATADIR="${ac_default_prefix}/${DATADIRNAME}" 
  LOCALEDIR="${DATADIR}/locale"
  AC_DEFINE_UNQUOTED(LOCALEDIR, "${LOCALEDIR}", [Locale dir])
else
  DATADIR="${prefix}/${DATADIRNAME}"
  LOCALEDIR="${DATADIR}/locale"
  AC_DEFINE_UNQUOTED(LOCALEDIR, "${LOCALEDIR}", [Locale dir])
fi
AC_SUBST(DATADIR)
AC_SUBST(LOCALEDIR)

AC_DEFINE_UNQUOTED(NAUTILUS_ACTIONS_CONFIG_VERSION, "1.1", [Version of the configuration format])
AC_DEFINE_UNQUOTED(NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR, "/apps/nautilus-actions", [GConf base dir where all config will be stored])

AC_OUTPUT([
Makefile
libnautilus-actions/Makefile
plugin/Makefile
nact/Makefile
utils/Makefile
icons/Makefile
icons/16x16/Makefile
icons/22x22/Makefile
icons/48x48/Makefile
icons/scalable/Makefile
po/Makefile.in
])

