1# configure.ac - Copyright (c) 2001, 2006, 2007 Olivier Poncet
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16
17AC_INIT([xcpc], [20070122], [ponceto@noos.fr])
18AM_INIT_AUTOMAKE
19AC_PROG_CC
20AC_PROG_LEX
21AC_PROG_YACC
22AC_PROG_LIBTOOL
23AC_PROG_INSTALL
24AC_PATH_X
25AC_PATH_XTRA
26AM_PATH_GLIB_2_0([2.6.0], [have_glib20="yes"], [have_glib20="no"], [gobject])
27if test "x${have_glib20}" = "xno"; then
28  AC_MSG_ERROR([Glib - version >= 2.6.0 is required])
29fi
30AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug], [turn on debugging [default=no]])], [], [enable_debug="no"])
31if test "x${enable_debug}" != "xyes"; then
32  AC_DEFINE([G_DISABLE_ASSERT],      [1], [Define to 1 to disable GLib/GObject assert.])
33  AC_DEFINE([G_DISABLE_CHECKS],      [1], [Define to 1 to disable GLib/GObject checks.])
34  AC_DEFINE([G_DISABLE_CAST_CHECKS], [1], [Define to 1 to disable GObject cast checks.])
35fi
36AC_CHECK_HEADER([libdsk.h], [have_libdsk="yes"], [AC_MSG_ERROR([libdsk is required !!])])
37AC_ARG_WITH([motif1], [AC_HELP_STRING([--with-motif1], [build the Motif1 version])])
38AC_CHECK_HEADER([Xm/Xm.h],
39[have_motif1="yes"], [have_motif1="no"], [
40#include <X11/Intrinsic.h>
41#include <X11/StringDefs.h>
42])
43AC_ARG_WITH([athena], [AC_HELP_STRING([--with-athena], [build the Athena version])])
44AC_CHECK_HEADER([X11/Xaw/XawInit.h],
45[have_athena="yes"], [have_athena="no"], [
46#include <X11/Intrinsic.h>
47#include <X11/StringDefs.h>
48])
49if   test "x${with_motif1}" = "xyes"; then
50  if test "x${have_motif1}" = "xyes"; then
51    AM_CONDITIONAL([MOTIF1], true )
52    AM_CONDITIONAL([ATHENA], false)
53    gui_toolkit="Motif1"
54  else
55    AC_MSG_ERROR([Motif1 toolkit not found])
56  fi
57elif test "x${with_athena}" = "xyes"; then
58  if test "x${have_athena}" = "xyes"; then
59    AM_CONDITIONAL([MOTIF1], false)
60    AM_CONDITIONAL([ATHENA], true )
61    gui_toolkit="Athena"
62  else
63    AC_MSG_ERROR([Athena toolkit not found])
64  fi
65else
66  if   test "x${have_motif1}" = "xyes"; then
67    AM_CONDITIONAL([MOTIF1], true )
68    AM_CONDITIONAL([ATHENA], false)
69    gui_toolkit="Motif1"
70  elif test "x${have_athena}" = "xyes"; then
71    AM_CONDITIONAL([MOTIF1], false)
72    AM_CONDITIONAL([ATHENA], true )
73    gui_toolkit="Athena"
74  else
75    AC_MSG_ERROR([no gui toolkit found ...])
76  fi
77fi
78AC_ARG_ENABLE([xshm], [AC_HELP_STRING([--enable-xshm], [add the support of XShm if available [default=yes]])], [], [enable_xshm="yes"])
79AC_CHECK_HEADER([sys/ipc.h], [], [enable_xshm="no"])
80if test "x${ac_cv_header_sys_ipc_h}" = "xyes"; then
81  AC_DEFINE([HAVE_SYS_IPC_H], [1], [Define to 1 if you have the <sys/ipc.h> header file.])
82fi
83AC_CHECK_HEADER([sys/shm.h], [], [enable_xshm="no"])
84if test "x${ac_cv_header_sys_shm_h}" = "xyes"; then
85  AC_DEFINE([HAVE_SYS_SHM_H], [1], [Define to 1 if you have the <sys/shm.h> header file.])
86fi
87AC_CHECK_HEADER([X11/extensions/XShm.h], [], [enable_xshm="no"], [
88#include <stdio.h>
89#include <stdlib.h>
90#include <string.h>
91#include <sys/ipc.h>
92#include <sys/shm.h>
93#include <X11/Xlib.h>
94#include <X11/Xutil.h>
95]
96)
97if test "x${enable_xshm}" = "xyes"; then
98  AC_DEFINE([HAVE_XSHM], [1], [Define to 1 if you have the X11-SHM extension.])
99fi
100
101AC_C_BIGENDIAN([AC_DEFINE([MSB_FIRST], [1], [MSB First: 68k, sparc, ...])],
102               [AC_DEFINE([LSB_FIRST], [1], [LSB First: x86, alpha, ...])],
103               [AC_MSG_ERROR([unsupported byte-order ...])])
104AC_CONFIG_HEADERS([config.h])
105AC_CONFIG_FILES([Makefile src/Makefile src/dev/Makefile src/drv/Makefile src/Xem/Makefile])
106AC_OUTPUT
107AC_MSG_NOTICE([Configured to build Xcpc:
108
109  GLib20 sdk .... ${have_glib20}
110  LibDSK sdk .... ${have_libdsk}
111  Motif1 sdk .... ${have_motif1}
112  Athena sdk .... ${have_athena}
113  gui toolkit ... ${gui_toolkit}
114  X11-SHM ....... ${enable_xshm}
115
116Have fun with Xcpc ;-)
117])
118