1 dnl Copyright © 2022-2023 Nick Bowler
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.
7 dnl remove pointless gnulib warning flag check
8 AC_DEFUN([gl_CC_GNULIB_WARNINGS])
10 AC_INIT([rrace], [0], [nbowler@draconx.ca])
11 AC_CONFIG_HEADERS([config.h])
13 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
14 AM_SILENT_RULES([yes])
22 AC_C_FLEXIBLE_ARRAY_MEMBER
25 m4_include([lib/gnulib.mk])
27 dnl We will provide our own makefile rules for gettext. Disable tracing of
28 dnl AM_GNU_GETTEXT to prevent autoreconf from running autopoint, and to
29 dnl prevent automake from growing gratuitous error conditions.
30 m4_traceoff([AM_GNU_GETTEXT])
31 AM_GNU_GETTEXT([external])
32 AH_BOTTOM([#include <conf_post.h>])
35 AC_ARG_WITH([curses], [AS_HELP_STRING([--with-curses],
36 [build UI for text mode via curses (default: auto)])],
37 [], [with_curses=auto])
38 AS_IF([test x"$with_curses" != x"no"],
39 [DX_LIB_CURSES([have_curses=yes], [have_curses=no])])
40 AS_IF([test x"$with_curses" = x"yes" && test x"$have_curses" != x"yes"],
41 [AC_MSG_FAILURE([--with-curses requested but curses was not found])])
42 AM_CONDITIONAL([HAVE_CURSES], [test x"$have_curses" = x"yes"])
44 AM_COND_IF([HAVE_CURSES],
45 [DX_CHECK_CURSES_FUNC([wresize], [0,0,0])
46 DX_CHECK_CURSES_MOUSE_SUPPORT])
49 m4_copy([AC_ARG_WITH], [save_AC_ARG_WITH])
50 m4_pushdef([AC_ARG_WITH], [m4_case([$1], [x],
51 [m4_popdef([$0])$0([x], AS_HELP_STRING([--with-x],
52 [build UI for the X Window System (default: auto)]), m4_shift2($@))],
53 [m4_pushdef([$0], m4_defn([save_$0]))$0($@)m4_popdef([$0])])])
55 AS_IF([test x"$no_x" != x"yes"],
56 [AC_CACHE_CHECK([for Motif], [dx_cv_have_motif],
57 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
58 dx_cv_motif_cflags="$X_CFLAGS"
59 dx_cv_motif_libs="$X_LIBS $X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS"
60 CFLAGS="$dx_cv_motif_cflags $CFLAGS"
61 LIBS="$dx_cv_motif_libs $LIBS"
62 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <Xm/XmAll.h>],
63 [XmCreateMainWindow(0, 0, 0, 0); XtAppSetExitFlag(0)])],
64 [dx_cv_have_motif=yes], [dx_cv_have_motif=no])
65 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])])
67 AS_IF([test x"$with_x" = x"yes" && test x"$dx_cv_have_motif" != x"yes"],
68 [AC_MSG_FAILURE([--with-x requested but Motif was not found])])
70 AC_SUBST([MOTIF_CFLAGS], [@&t@])
71 AC_SUBST([MOTIF_LIBS], [@&t@])
72 AM_CONDITIONAL([HAVE_MOTIF],
73 [test x"$with_x" != x"no" && test x"$dx_cv_have_motif" = x"yes"])
74 AM_COND_IF([HAVE_MOTIF],
75 [MOTIF_CFLAGS=$dx_cv_motif_cflags MOTIF_LIBS=$dx_cv_motif_libs],
76 [AC_DEFINE([X_DISPLAY_MISSING])])
77 AH_TEMPLATE([X11_RENDER_DEBUG],
78 [Define to 1 to enable visual aids for debugging X11 rendering.])
80 # Check for XmPIXMAP_AND_STRING.
82 # Just checking for the existence of this identifier is sufficient, to ensure
83 # that the C compiler accepts the name. If it turns out to not actually be
84 # supported by the library used at runtime, Motif itself will catch this
85 # and set to the default (i.e., XmSTRING).
86 AM_COND_IF([HAVE_MOTIF],
87 [AC_CACHE_CHECK([whether Motif supports XmPIXMAP_AND_STRING],
88 [dx_cv_motif_have_pixmap_and_string],
89 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
90 CFLAGS="$MOTIF_CFLAGS $CFLAGS" LIBS="$MOTIF_LIBS $LIBS"
91 AC_COMPUTE_INT([dx_tmp],
92 [XmPIXMAP != XmPIXMAP_AND_STRING && XmSTRING != XmPIXMAP_AND_STRING],
93 [#include <Xm/Label.h>], [dx_tmp=0])
94 AS_IF([test x"$dx_tmp" = x"1"],
95 [dx_cv_motif_have_pixmap_and_string=yes],
96 [dx_cv_motif_have_pixmap_and_string=no])
97 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])
98 AS_IF([test x"$dx_cv_motif_have_pixmap_and_string" = x"yes"],
99 [AC_DEFINE([HAVE_MOTIF_PIXMAP_AND_STRING], [1],
100 [Define to 1 if Motif supports XmPIXMAP_AND_STRING])])
103 dnl On ELF systems, linking a program against a string table in shared
104 dnl library is very expensive and actually makes things much worse than
105 dnl just duplicating the needed strings in the program.
107 dnl It may help a little bit when static linking or on other shared
108 dnl library implementations, which could maybe be auto-detected with
109 dnl a configure test, but the penalty for setting these anyway is
110 dnl very small (couple hundred bytes of rodata).
111 m4_foreach_w([lib], [Xt Xm],
112 [AC_DEFINE(m4_toupper(m4_defn([lib]))[STRINGDEFINES], [1],
113 [Define to 1 to avoid using the string tables from lib]m4_defn([lib])[.
114 On some platforms, or when statically linking lib]m4_defn([lib])[,
115 leaving this undefined may reduce the executable size somewhat.])])
117 AC_CONFIG_TESTDIR([.], [t:.])
119 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
121 AC_CHECK_PROGS([XPMTOPPM], [xpmtoppm])
122 AC_CHECK_PROGS([PNMTOPNG], [pnmtopng])
123 AC_CHECK_PROGS([CONVERT], [convert])
124 AC_CHECK_PROGS([GM], [gm])
125 AC_CACHE_CHECK([how to convert XPM to PNG], [dx_cv_xpm_to_png],
126 [cat >conftest.xpm <<'EOF'
134 check_conftest_png () {
135 od conftest.png | $AWK 'BEGIN { success=0; }
136 NR == 1 && $2 == "050211" && $3 == "043516" { success=1; }
137 NR == 1 && $2 == "104520" && $3 == "047107" { success=1; }
138 END { exit(!success); }'
141 for dx_cv_xpm_to_png in netpbm 'gm convert' convert unknown; do
142 AS_CASE([$dx_cv_xpm_to_png],
145 [AS_IF([$XPMTOPPM conftest.xpm >conftest.ppm 2>&AS_MESSAGE_LOG_FD],
147 AS_IF([$PNMTOPNG conftest.ppm >conftest.png 2>&AS_MESSAGE_LOG_FD],
149 AS_IF([check_conftest_png], [break])],
152 [AS_CASE([$dx_cv_xpm_to_png],
153 [gm*], [test_convert="$GM convert"],
154 [test_convert="$CONVERT"])
155 AS_IF([$test_convert conftest.xpm conftest.png >&AS_MESSAGE_LOG_FD 2>&1],
157 AS_IF([check_conftest_png], [break])])
159 rm -f conftest.xpm conftest.ppm conftest.png])
161 AM_CONDITIONAL([USE_NETPBM], [test x"$dx_cv_xpm_to_png" = x"netpbm"])
162 AM_CONDITIONAL([USE_CONVERT],
163 [AS_CASE([$dx_cv_xpm_to_png], [*convert], [], [false])])
165 AS_IF([test x"$dx_cv_xpm_to_png" = x"gm convert"],
166 [CONVERT="$GM convert"])
168 AC_CHECK_PROGS([OPTIPNG], [optipng])
171 AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"])
173 AC_CONFIG_FILES([Makefile])
177 AM_COND_IF([HAVE_CURSES], [have_ui=:])
178 AM_COND_IF([HAVE_MOTIF], [have_ui=:])
179 AS_IF([$have_ui], [],
180 [AC_MSG_WARN([No user interface is enabled.])
181 AC_MSG_WARN([It will not be possible to play the game.])])