dnl -*- sh -*-
AC_INIT(src/ledit.c)
JD_INIT
JD_ANSI_CC

AC_CONFIG_AUX_DIR(autoconf)
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL

# determine X include and libs for XJed
AC_PATH_XTRA

#Check these header since they cause trouble
AC_CHECK_HEADERS( \
stdlib.h \
unistd.h \
memory.h \
malloc.h \
termios.h \
fcntl.h \
sys/fcntl.h \
)
# special treatment for sys/wait.h
AC_HEADER_SYS_WAIT
AC_HEADER_DIRENT

AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T

AC_CHECK_FUNCS(\
memset \
memcpy \
putenv \
setenv \
unsetenv \
getcwd \
setsid \
tcgetattr tcsetattr cfgetospeed \
)

JD_SET_OBJ_SRC_DIR
JD_TERMCAP
JD_FIND_SLANG
JD_GCC_WARNINGS

default_jed_root="/usr/local/jed"
JED_ROOT="${JED_ROOT:-$default_jed_root}"
AC_SUBST(JED_ROOT)dnl

JD_GET_MODULES(src/modules.unx)
JD_CREATE_MODULE_ORULES

AC_CONFIG_HEADER(src/sysconf.h:src/config.hin)
AC_OUTPUT(Makefile:autoconf/Makefile.in src/Makefile)

dnl JD_CREATE_ORULE(jprocess)
JD_CREATE_ORULE(chkslang)
JD_CREATE_ORULE(display)
JD_CREATE_ORULE(xterm)
JD_CREATE_ORULE(gpmmouse)
JD_CREATE_ORULE(rgrep)
JD_CREATE_ORULE(getmail)

JD_APPEND_RULES(src/Makefile)

echo ""
echo "You need to edit src/Makefile if the following are not correct:"
echo "  CC = $CC"
echo "  CFLAGS = $CFLAGS"
echo "  JED_ROOT = $JED_ROOT"
echo "Also edit src/Makefile to enable:"
echo "  GPM Mouse support (Linux)"
echo "You will need to edit src/jed-feat.h if you want:"
echo "  Folding support"
echo "  Asynchronous subprocess support (experimental)"
echo "  Enhanced syntax highlighting (experimental)"
echo ""
echo "Before typing 'make', type 'make clean' first."
