]> git.draconx.ca Git - rrace.git/blob - configure.ac
Combine x11_redraw_icon and x11_redraw_goal.
[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   [build UI for text mode via curses (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" && test 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 AM_COND_IF([HAVE_CURSES],
43 [DX_CHECK_CURSES_FUNC([wresize], [0,0,0])
44 DX_CHECK_CURSES_MOUSE_SUPPORT])
45
46 # Checks for X11
47 m4_copy([AC_ARG_WITH], [save_AC_ARG_WITH])
48 m4_pushdef([AC_ARG_WITH], [m4_case([$1], [x],
49   [m4_popdef([$0])$0([x], AS_HELP_STRING([--with-x],
50     [build UI for the X Window System (default: auto)]), m4_shift2($@))],
51   [m4_pushdef([$0], m4_defn([save_$0]))$0($@)m4_popdef([$0])])])
52 AC_PATH_XTRA
53 AS_IF([test x"$no_x" != x"yes"],
54 [AC_CACHE_CHECK([for Motif], [dx_cv_have_motif],
55 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
56 dx_cv_motif_cflags="$X_CFLAGS"
57 dx_cv_motif_libs="$X_LIBS $X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS"
58 CFLAGS="$dx_cv_motif_cflags $CFLAGS"
59 LIBS="$dx_cv_motif_libs $LIBS"
60 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <Xm/XmAll.h>],
61   [XmCreateMainWindow(0, 0, 0, 0); XtAppSetExitFlag(0)])],
62   [dx_cv_have_motif=yes], [dx_cv_have_motif=no])
63 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])])
64
65 AS_IF([test x"$with_x" = x"yes" && test x"$dx_cv_have_motif" != x"yes"],
66   [AC_MSG_FAILURE([--with-x requested but Motif was not found])])
67
68 AC_SUBST([MOTIF_CFLAGS], [@&t@])
69 AC_SUBST([MOTIF_LIBS], [@&t@])
70 AM_CONDITIONAL([HAVE_MOTIF],
71   [test x"$with_x" != x"no" && test x"$dx_cv_have_motif" = x"yes"])
72 AM_COND_IF([HAVE_MOTIF],
73   [MOTIF_CFLAGS=$dx_cv_motif_cflags MOTIF_LIBS=$dx_cv_motif_libs],
74   [AC_DEFINE([X_DISPLAY_MISSING])])
75 AH_TEMPLATE([X11_RENDER_DEBUG],
76   [Define to 1 to enable visual aids for debugging X11 rendering.])
77
78 # Check for XmPIXMAP_AND_STRING.
79 #
80 # Just checking for the existence of this identifier is sufficient, to ensure
81 # that the C compiler accepts the name.  If it turns out to not actually be
82 # supported by the library used at runtime, Motif itself will catch this
83 # and set to the default (i.e., XmSTRING).
84 AM_COND_IF([HAVE_MOTIF],
85 [AC_CACHE_CHECK([whether Motif supports XmPIXMAP_AND_STRING],
86 [dx_cv_motif_have_pixmap_and_string],
87 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
88 CFLAGS="$MOTIF_CFLAGS $CFLAGS" LIBS="$MOTIF_LIBS $LIBS"
89 AC_COMPUTE_INT([dx_tmp],
90   [XmPIXMAP != XmPIXMAP_AND_STRING && XmSTRING != XmPIXMAP_AND_STRING],
91   [#include <Xm/Label.h>], [dx_tmp=0])
92 AS_IF([test x"$dx_tmp" = x"1"],
93   [dx_cv_motif_have_pixmap_and_string=yes],
94   [dx_cv_motif_have_pixmap_and_string=no])
95 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])
96 AS_IF([test x"$dx_cv_motif_have_pixmap_and_string" = x"yes"],
97   [AC_DEFINE([HAVE_MOTIF_PIXMAP_AND_STRING], [1],
98     [Define to 1 if Motif supports XmPIXMAP_AND_STRING])])
99 ])
100
101 AC_CONFIG_TESTDIR([.], [t:.])
102 DX_PROG_AUTOTEST
103 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
104
105 AC_CHECK_PROGS([XPMTOPPM], [xpmtoppm])
106 AC_CHECK_PROGS([PNMTOPNG], [pnmtopng])
107 AC_CHECK_PROGS([CONVERT], [convert])
108 AC_CHECK_PROGS([GM], [gm])
109 AC_CACHE_CHECK([how to convert XPM to PNG], [dx_cv_xpm_to_png],
110 [cat >conftest.xpm <<'EOF'
111 /* XPM */
112 static char *x[] = {
113 "1 1 1 1",
114 "x c #123456",
115 "x"
116 };
117 EOF
118 check_conftest_png () {
119   od conftest.png | $AWK 'BEGIN { success=0; }
120 NR == 1 && $2 == "050211" && $3 == "043516" { success=1; }
121 NR == 1 && $2 == "104520" && $3 == "047107" { success=1; }
122 END { exit(!success); }'
123 }
124 rm -f conftest.png
125 for dx_cv_xpm_to_png in netpbm 'gm convert' convert unknown; do
126 AS_CASE([$dx_cv_xpm_to_png],
127
128 [netpbm],
129 [AS_IF([$XPMTOPPM conftest.xpm >conftest.ppm 2>&AS_MESSAGE_LOG_FD],
130   [], [continue])
131 AS_IF([$PNMTOPNG conftest.ppm >conftest.png 2>&AS_MESSAGE_LOG_FD],
132   [], [continue])
133 AS_IF([check_conftest_png], [break])],
134
135 [*convert],
136 [AS_CASE([$dx_cv_xpm_to_png],
137   [gm*], [test_convert="$GM convert"],
138   [test_convert="$CONVERT"])
139 AS_IF([$test_convert conftest.xpm conftest.png >&AS_MESSAGE_LOG_FD 2>&1],
140   [], [continue])
141 AS_IF([check_conftest_png], [break])])
142 done
143 rm -f conftest.xpm conftest.ppm conftest.png])
144
145 AM_CONDITIONAL([USE_NETPBM], [test x"$dx_cv_xpm_to_png" = x"netpbm"])
146 AM_CONDITIONAL([USE_CONVERT],
147   [AS_CASE([$dx_cv_xpm_to_png], [*convert], [], [false])])
148
149 AS_IF([test x"$dx_cv_xpm_to_png" = x"gm convert"],
150   [CONVERT="$GM convert"])
151
152 AC_CHECK_PROGS([OPTIPNG], [optipng])
153 : "${OPTIPNG:=:}"
154
155 AC_CONFIG_FILES([Makefile])
156 AC_OUTPUT
157
158 have_ui=false
159 AM_COND_IF([HAVE_CURSES], [have_ui=:])
160 AM_COND_IF([HAVE_MOTIF], [have_ui=:])
161 AS_IF([$have_ui], [],
162 [AC_MSG_WARN([No user interface is enabled.])
163 AC_MSG_WARN([It will not be possible to play the game.])])