Skip to content

[automake] conditional config in configure.ac

dsindex edited this page Jul 30, 2014 · 1 revision

reference

특정 조건일 경우만 Makefile을 생성하고 싶은 경우가 있다면 :
(예를 들어서, --enable-python을 할 경우만 python wrapper 코드를 컴파일하고자 한다면)

./configure --enable-python=yes --with-pythoninc=/usr/local/include/python2.7

  1. configure.ac
AC_ARG_ENABLE(python,
   [  --enable-python=val make python wrapper library, val=yes or no],
   [case "${enableval}" in
      yes) python=true ;;
      no)  python=false ;;
      *) AC_MSG_ERROR(bad value ${enableval} for --enable-python) ;;
    esac],[python=false])
AM_CONDITIONAL(PYTHON_USE,test x"$python" = xtrue)

AM_COND_IF( [PYTHON_USE],[
AC_ARG_WITH(pythoninc,
    AC_HELP_STRING(
        [--with-pythoninc=DIRECTORY],
        [set python include directory path]),
    [pythoninc="$withval"],
    [path=/usr/local/include/python2.7
     if test -f ${path}/Python.h ; then
        python_header=${path}
     else
        AC_MSG_ERROR(Cannot locate python include header. You should either use --with-pythoninc option or place python header in ${path})
     fi
     pythoninc=${python_header}
    ]
)
AC_MSG_RESULT(found python header in $pythoninc.);
AC_SUBST(pythoninc) ] )

AC_CONFIG_FILES([
    Makefile
    src/Makefile
    include/Makefile
    doc/Makefile
])

AM_COND_IF( [PYTHON_USE], [
AC_CONFIG_FILES([
    wrapper/python/Makefile
])] )
  1. Makefile.am
if PYTHON_USE
SUBDIRS = include src wrapper/python doc
else
SUBDIRS = include src doc
endif
Clone this wiki locally