dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/chinput.h)

PRGDIR="/lib/Chinput"
DOCDIR="/lib/Chinput/doc"
IMDIR="/lib/Chinput/im"

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_AWK

dnl Checks for header files.
AC_PATH_XTRA
CHINPUT_CFLAGS="-I$x_includes"
CHINPUT_LIBS="-L$x_libraries"
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h Imlib.h)
AC_HEADER_SYS_WAIT

dnl Checks for libraries.
LDFLAGS="$LDFLAGS -L$x_libraries"
AC_CHECK_LIB(X11,XOpenDisplay,,AC_MSG_ERROR(Cannot find X11 libs))
CHINPUT_LIBS="$CHINPUT_LIBS -lX11"

AC_CHECK_LIB(Imlib, Imlib_init, 
    [CHINPUT_CFLAGS="$CHINPUT_CFLAGS -DIMLIB"; 
        CHINPUT_LIBS="$CHINPUT_LIBS -lXext -lImlib"],
                ,-lXext -lX11)
AC_CHECK_LIB(dl, dlopen,,AC_MSG_ERROR(Cannot find dl libs))

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_MODE_T
AC_STRUCT_ST_RDEV
AC_HEADER_TIME
AC_TYPE_UID_T

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(strdup strerror gethostname gettimeofday mkdir socket strstr strtol uname)

AC_SUBST(PRGDIR)
AC_SUBST(DOCDIR)
AC_SUBST(IMDIR)
AC_SUBST(CHINPUT_CFLAGS)
AC_SUBST(CHINPUT_LIBS)

AC_OUTPUT(Makefile                               \
          resource/Chinput.ad                    \
          resource/Makefile                      \
          src/Makefile                           \
          src/config.h                           \
          src/tips.h                             \
          unicon/Makefile                        \
          unicon/server/Makefile                 \
          unicon/client/Makefile                 \
          unicon/ImmModules/cce/Makefile         \
          unicon/ImmModules/cce/inputs/Makefile  \
          unicon/ImmModules/turbo/Makefile       \
          unicon/ImmModules/turbo/config.h)
