1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(xrus.c)
3AM_CONFIG_HEADER(config.h)
4
5AM_INIT_AUTOMAKE(xruskb, 1.15.4)
6
7if test "$CFLAGS" = ""
8then
9   CFLAGS="-O"
10fi
11
12dnl Checks for programs.
13AC_PROG_AWK
14AC_PROG_CC
15AC_PROG_LN_S
16AC_PROG_INSTALL
17AC_PATH_PROGS(M4, m4, [$missing_dir/missing m4])
18
19if test "$CC" = gcc
20then
21   CFLAGS="$CFLAGS -Wall -Wno-implicit"
22fi
23
24dnl Checks for header files.
25AC_PATH_XTRA
26
27if test x$have_x != xyes; then
28   AC_MSG_ERROR(
29[You have to have X11 development package (include files and libraries) to compile xruskb.])
30fi
31
32AC_HEADER_STDC
33AC_HEADER_SYS_WAIT
34AC_CHECK_HEADERS(unistd.h)
35
36dnl Checks for typedefs, structures, and compiler characteristics.
37AC_TYPE_PID_T
38AC_CONST
39
40dnl Checks for library functions.
41AC_FUNC_ALLOCA
42AC_CHECK_FUNCS(strerror atexit strdup)
43
44dnl Xaw/Motif tests
45AC_ARG_WITH(Xaw,     [  --with-Xaw              compile with Athena widget set])
46AC_ARG_WITH(motif,   [  --with-motif            compile with Motif (or lesstif)])
47AC_ARG_WITH(toolkit, [  --with-toolkit=TK       use specified toolkit (motif, xaw, none)])
48
49case "$with_toolkit" in
50motif)with_motif=yes
51      AC_DEFINE([TK], [TK_MOTIF])
52      ;;
53xaw)  with_Xaw=yes
54      AC_DEFINE([TK], [TK_XAW])
55      ;;
56none) with_Xaw=no
57      with_motif=no
58      AC_DEFINE([TK], [TK_NONE])
59      ;;
60"")   ;; # no tk specified, use first available
61*)    AC_MSG_ERROR([invalid toolkit name, use motif, xaw, or none])
62      ;;
63esac
64
65AC_DEFUN([XRUS_CHECK_XAW],
66[
67   AC_CHECK_LIB($1,main,[
68	TOOLKIT_LIBS="-l$1"
69	AC_DEFINE([HAVE_LIBXAW])
70	],[],[-lXt -lXmu -Xext -lX11 $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS])
71])
72
73
74# if --with-Xaw was specified, check libXaw first
75if test x$with_Xaw = xyes
76then
77   XRUS_CHECK_XAW(Xaw3d)
78   if test -z "$TOOLKIT_LIBS"; then
79      XRUS_CHECK_XAW(Xaw)
80   fi
81fi
82
83# if we don't use Xaw directly, test for Motif
84if test x$ac_cv_lib_Xaw_main != xyes -a x$ac_cv_lib_Xaw3d_main != xyes \
85   || test x$with_Xaw != xyes
86then
87
88if test "$with_motif" != no; then
89dnl Check for Motif
90AC_PATH_MOTIF
91if test x$no_motif != xyes
92then
93   AC_DEFINE([HAVE_MOTIF])
94   if test "x$motif_includes" != x && test "x$motif_includes" != x/usr/include
95   then
96      TOOLKIT_INCLUDE="-I$motif_includes"
97      AC_SUBST(TOOLKIT_INCLUDE)
98   fi
99   TOOLKIT_LIBS="-lXm"
100   if test "x$motif_libraries" != x && test "x$motif_libraries" != x/usr/lib
101   then
102      case "$X_LIBS" in
103      *-R*) TOOLKIT_LIBS="-R$motif_libraries $TOOLKIT_LIBS";;
104      esac
105      TOOLKIT_LIBS="-L$motif_libraries $TOOLKIT_LIBS"
106   fi
107
108   # motif can require additional libs
109   AC_CHECK_LIB(gen,regex,[TOOLKIT_LIBS="$TOOLKIT_LIBS -lgen"])
110   AC_CHECK_LIB(intl,main,[TOOLKIT_LIBS="$TOOLKIT_LIBS -lintl"])
111
112fi # !motif
113fi # with_motif
114
115fi # libxaw
116
117# if Motif not found, fall back to Xaw
118if test x$no_motif = xyes
119then
120   if test -z "$TOOLKIT_LIBS"
121   then
122      XRUS_CHECK_XAW(Xaw3d)
123      if test -z "$TOOLKIT_LIBS"; then
124         XRUS_CHECK_XAW(Xaw)
125      fi
126   fi
127   if test x$ac_cv_lib_Xaw_main != xyes -a x$ac_cv_lib_Xaw3d_main != xyes \
128      || test x$with_Xaw = xno
129   then
130      AC_MSG_WARN(Neither Xaw3d, Xaw nor Motif found. Nothing will appear on the screen.)
131   fi
132fi
133
134AC_SUBST(TOOLKIT_LIBS)
135
136if uname -X 2>/dev/null | grep 3.2v5 >/dev/null
137then
138   # this dirty trick is used to force dynamic
139   # compilation with gcc on sco v5
140   LIBS="$LIBS /lib/libc.so"
141fi
142
143AC_OUTPUT(Makefile icons/Makefile keymaps/Makefile xmodmap/Makefile)
144