xfce4 dev tools的一些说明

xfce4 dev tools的一些说明

xfce4 dev tools实际上基本是封装了一些autoconf的宏函数

比如XDT_I18N:

AC_DEFUN([XDT_I18N],
[
  dnl Substitute GETTEXT_PACKAGE variable
  GETTEXT_PACKAGE=m4_default([$2], [AC_PACKAGE_TARNAME()])
  AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Name of default gettext domain])
  AC_SUBST([GETTEXT_PACKAGE])

  dnl gettext and stuff
  ALL_LINGUAS="$1"
  AM_GLIB_GNU_GETTEXT()

  dnl This is required on some Linux systems
  AC_CHECK_FUNC([bind_textdomain_codeset])

  dnl Determine where to install locale files
  AC_MSG_CHECKING([for locales directory])
  AC_ARG_WITH([locales-dir], 
  [
    AC_HELP_STRING([--with-locales-dir=DIR], [Install locales into DIR])
  ], [localedir=$withval],
  [
    if test x"$CATOBJEXT" = x".mo"; then
      localedir=$libdir/locale
    else
      localedir=$datadir/locale
    fi
  ])
  AC_MSG_RESULT([$localedir])
  AC_SUBST([localedir])

  dnl Determine additional xgettext flags
  AC_MSG_CHECKING([for additional xgettext flags])
  if test x"$XGETTEXT_ARGS" = x""; then
    XGETTEXT_ARGS="--keyword=Q_ --from-code=UTF-8";
  else
    XGETTEXT_ARGS="$XGETTEXT_ARGS --keyword=Q_ --from-code=UTF-8";
  fi
  AC_SUBST([XGETTEXT_ARGS])
  AC_MSG_RESULT([$XGETTEXT_ARGS])
])

主要内容就在前面五行的实现:

  GETTEXT_PACKAGE=m4_default([$2], [AC_PACKAGE_TARNAME()])
  AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Name of default gettext domain])
  AC_SUBST([GETTEXT_PACKAGE])
  ALL_LINGUAS="$1"
  AM_GLIB_GNU_GETTEXT()

定义了GETTEXT_PACKAGE宏,然后将参数1传递给ALL_LINGUAS

而XDT_CHECK_PACKAGE的实现也很简单,基本上就是封装PKG_CONFIG

AC_DEFUN([XDT_CHECK_PACKAGE],
[
  XDT_PROG_PKG_CONFIG()

  AC_MSG_CHECKING([for $2 >= $3])
  if $PKG_CONFIG "--atleast-version=$3" "$2" >/dev/null 2>&1; then
    $1_VERSION=`$PKG_CONFIG --modversion "$2"`
    AC_MSG_RESULT([$$1_VERSION])

    AC_MSG_CHECKING([$1_CFLAGS])
    $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
    AC_MSG_RESULT([$$1_CFLAGS])

    AC_MSG_CHECKING([$1_LIBS])
    $1_LIBS=`$PKG_CONFIG --libs "$2"`
    AC_MSG_RESULT([$$1_LIBS])

    $1_REQUIRED_VERSION=$3

    AC_SUBST([$1_VERSION])
    AC_SUBST([$1_CFLAGS])
    AC_SUBST([$1_LIBS])
    AC_SUBST([$1_REQUIRED_VERSION])

    ifelse([$4], , , [$4])
  elif $PKG_CONFIG --exists "$2" >/dev/null 2>&1; then
    xdt_cv_version=`$PKG_CONFIG --modversion "$2"`
    AC_MSG_RESULT([found, but $xdt_cv_version])

    ifelse([$5], ,
    [
      echo "*** The required package $2 was found on your system,"
      echo "*** but the installed version ($xdt_cv_version) is too old."
      echo "*** Please upgrade $2 to atleast version $3, or adjust"
      echo "*** the PKG_CONFIG_PATH environment variable if you installed"
      echo "*** the new version of the package in a nonstandard prefix so"
      echo "*** pkg-config is able to find it."
      exit 1
    ], [$5])
  else
    AC_MSG_RESULT([not found])

    ifelse([$5], ,
    [
      echo "*** The required package $2 was not found on your system."
      echo "*** Please install $2 (atleast version $3) or adjust"
      echo "*** the PKG_CONFIG_PATH environment variable if you"
      echo "*** installed the package in a nonstandard prefix so that"
      echo "*** pkg-config is able to find it."
      exit 1
    ], [$5])
  fi
])

XDT_PROG_PKG_CONFIG检测系统中是否存在PKG_CONFIG,如果

存在,则通过pkg-config来配置CFLAGS/LIBS等4个变量

posted @ 2013-07-21 10:49  日月王  阅读(521)  评论(0编辑  收藏  举报