]> git.draconx.ca Git - rrace.git/blob - configure.ac
Fix reconfiguration when using --without-x.
[rrace.git] / configure.ac
1 dnl Copyright © 2022 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 dnl remove pointless gnulib warning flag check
8 AC_DEFUN([gl_CC_GNULIB_WARNINGS])
9
10 AC_INIT([rrace], [0], [nbowler@draconx.ca])
11 AC_CONFIG_HEADERS([config.h])
12
13 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
14 AM_SILENT_RULES([yes])
15 DX_AUTOMAKE_COMPAT
16
17 AC_PROG_CC_C99
18 gl_EARLY
19 LT_INIT
20 gl_INIT
21
22 AC_CACHE_SAVE
23 m4_include([lib/gnulib.mk])
24
25 dnl We will provide our own makefile rules for gettext.  Disable tracing of
26 dnl AM_GNU_GETTEXT to prevent autoreconf from running autopoint, and to
27 dnl prevent automake from growing gratuitous error conditions.
28 m4_traceoff([AM_GNU_GETTEXT])
29 AM_GNU_GETTEXT([external])
30 AH_BOTTOM([#include <conf_post.h>])
31
32 # Checks for curses
33 AC_ARG_WITH([curses], [AS_HELP_STRING([--with-curses],
34   [use curses for playing in text mode (default: auto)])],
35   [], [with_curses=auto])
36 AS_IF([test x"$with_curses" != x"no"],
37   [DX_LIB_CURSES([have_curses=yes], [have_curses=no])])
38 AS_IF([test x"$with_curses" = x"yes" && x"$have_curses" != x"yes"],
39   [AC_MSG_FAILURE([--with-curses requested but curses was not found])])
40 AM_CONDITIONAL([HAVE_CURSES], [test x"$have_curses" = x"yes"])
41
42 # Checks for X11
43 AC_PATH_XTRA
44 AS_IF([test x"$no_x" != x"yes"],
45 [AC_CACHE_CHECK([for Motif], [dx_cv_have_motif],
46 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
47 dx_cv_motif_cflags="$X_CFLAGS"
48 dx_cv_motif_libs="$X_LIBS $X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS"
49 CFLAGS="$dx_cv_motif_cflags $CFLAGS"
50 LIBS="$dx_cv_motif_libs $LIBS"
51 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <Xm/XmAll.h>],
52   [XmCreateMainWindow(0, 0, 0, 0); XtAppSetExitFlag(0)])],
53   [dx_cv_have_motif=yes], [dx_cv_have_motif=no])
54 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])])
55
56 AS_IF([test x"$with_x" = x"yes" && test "$dx_cv_have_motif" != x"yes"],
57   [AC_MSG_FAILURE([--with-x requested but Motif was not found])])
58
59 AC_SUBST([MOTIF_CFLAGS], [@&t@])
60 AC_SUBST([MOTIF_LIBS], [@&t@])
61 AM_CONDITIONAL([HAVE_MOTIF],
62   [test x"$with_x" != x"no" && test x"$dx_cv_have_motif" = x"yes"])
63 AM_COND_IF([HAVE_MOTIF],
64   [MOTIF_CFLAGS=$dx_cv_motif_cflags MOTIF_LIBS=$dx_cv_motif_libs],
65   [AC_DEFINE([X_DISPLAY_MISSING])])
66 AH_TEMPLATE([X11_RENDER_DEBUG],
67   [Define to 1 to enable visual aids for debugging X11 rendering.])
68
69 AC_CONFIG_TESTDIR([.], [t:.])
70 DX_PROG_AUTOTEST
71 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
72
73 AC_CHECK_PROGS([XPMTOPPM], [xpmtoppm])
74 AC_CHECK_PROGS([PNMTOPNG], [pnmtopng])
75 AC_CHECK_PROGS([CONVERT], [convert])
76 AC_CHECK_PROGS([GM], [gm])
77 AC_CACHE_CHECK([how to convert XPM to PNG], [dx_cv_xpm_to_png],
78 [cat >conftest.xpm <<'EOF'
79 /* XPM */
80 static char *x[] = {
81 "1 1 1 1",
82 "x c #123456",
83 "x"
84 };
85 EOF
86 check_conftest_png () {
87   od conftest.png | $AWK 'BEGIN { success=0; }
88 NR == 1 && $2 == "050211" && $3 == "043516" { success=1; }
89 NR == 1 && $2 == "104520" && $3 == "047107" { success=1; }
90 END { exit(!success); }'
91 }
92 rm -f conftest.png
93 for dx_cv_xpm_to_png in netpbm 'gm convert' convert unknown; do
94 AS_CASE([$dx_cv_xpm_to_png],
95
96 [netpbm],
97 [AS_IF([$XPMTOPPM conftest.xpm >conftest.ppm 2>&AS_MESSAGE_LOG_FD],
98   [], [continue])
99 AS_IF([$PNMTOPNG conftest.ppm >conftest.png 2>&AS_MESSAGE_LOG_FD],
100   [], [continue])
101 AS_IF([check_conftest_png], [break])],
102
103 [*convert],
104 [AS_CASE([$dx_cv_xpm_to_png],
105   [gm*], [test_convert="$GM convert"],
106   [test_convert="$CONVERT"])
107 AS_IF([$test_convert conftest.xpm conftest.png >&AS_MESSAGE_LOG_FD 2>&1],
108   [], [continue])
109 AS_IF([check_conftest_png], [break])])
110 done
111 rm -f conftest.xpm conftest.ppm conftest.png])
112
113 AM_CONDITIONAL([USE_NETPBM], [test x"$dx_cv_xpm_to_png" = x"netpbm"])
114 AM_CONDITIONAL([USE_CONVERT],
115   [AS_CASE([$dx_cv_xpm_to_png], [*convert], [], [false])])
116
117 AS_IF([test x"$dx_cv_xpm_to_png" = x"gm convert"],
118   [CONVERT="$GM convert"])
119
120 AC_CHECK_PROGS([OPTIPNG], [optipng])
121 : "${OPTIPNG:=:}"
122
123 AC_CONFIG_FILES([Makefile])
124 AC_OUTPUT
125
126 have_ui=false
127 AM_COND_IF([HAVE_CURSES], [have_ui=:])
128 AM_COND_IF([HAVE_MOTIF], [have_ui=:])
129 AS_IF([$have_ui], [],
130 [AC_MSG_WARN([No user interface is enabled.])
131 AC_MSG_WARN([It will not be possible to play the game.])])