]> git.draconx.ca Git - rrace.git/blob - configure.ac
Don't build locale/wcwidth junk if NLS is disabled.
[rrace.git] / configure.ac
1 dnl Copyright © 2022-2024 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 DX_PATCH_GNULIB
8
9 AC_INIT([rrace], [0], [nbowler@draconx.ca])
10 AC_CONFIG_HEADERS([config.h])
11
12 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
13 AM_SILENT_RULES([yes])
14 DX_AUTOMAKE_COMPAT
15
16 AC_PROG_CC_C99
17 gl_EARLY
18
19 AC_C_FLEXIBLE_ARRAY_MEMBER
20 AC_C_INLINE
21
22 LT_INIT
23 gl_INIT
24
25 AC_CACHE_SAVE
26 m4_include([lib/gnulib.mk])
27 AH_BOTTOM([#include <conf_post.h>])
28
29 # Checks for curses
30 AC_ARG_WITH([curses], [AS_HELP_STRING([--with-curses],
31   [build UI for text mode via curses (default: auto)])],
32   [], [with_curses=auto])
33 AS_IF([test x"$with_curses" != x"no"],
34   [DX_LIB_CURSES([have_curses=yes], [have_curses=no])])
35 AS_IF([test x"$with_curses" = x"yes" && test x"$have_curses" != x"yes"],
36   [AC_MSG_FAILURE([--with-curses requested but curses was not found])])
37 AM_CONDITIONAL([HAVE_CURSES], [test x"$have_curses" = x"yes"])
38
39 AM_COND_IF([HAVE_CURSES],
40 [DX_CHECK_CURSES_FUNC([wresize], [0,0,0])
41 DX_CHECK_CURSES_MOUSE_SUPPORT])
42
43 # Checks for X11
44 m4_copy([AC_ARG_WITH], [save_AC_ARG_WITH])
45 m4_pushdef([AC_ARG_WITH], [m4_case([$1], [x],
46   [m4_popdef([$0])$0([x], AS_HELP_STRING([--with-x],
47     [build UI for the X Window System (default: auto)]), m4_shift2($@))],
48   [m4_pushdef([$0], m4_defn([save_$0]))$0($@)m4_popdef([$0])])])
49 AC_PATH_XTRA
50 AS_IF([test x"$no_x" != x"yes"],
51 [AC_CACHE_CHECK([for Motif], [dx_cv_have_motif],
52 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
53 dx_cv_motif_cflags="$X_CFLAGS"
54 dx_cv_motif_libs="$X_LIBS $X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS"
55 CFLAGS="$dx_cv_motif_cflags $CFLAGS"
56 LIBS="$dx_cv_motif_libs $LIBS"
57 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <Xm/XmAll.h>],
58   [XmCreateMainWindow(0, 0, 0, 0); XtAppSetExitFlag(0)])],
59   [dx_cv_have_motif=yes], [dx_cv_have_motif=no])
60 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])])
61
62 AS_IF([test x"$with_x" = x"yes" && test x"$dx_cv_have_motif" != x"yes"],
63   [AC_MSG_FAILURE([--with-x requested but Motif was not found])])
64
65 AC_SUBST([MOTIF_CFLAGS], [@&t@])
66 AC_SUBST([MOTIF_LIBS], [@&t@])
67 AM_CONDITIONAL([HAVE_MOTIF],
68   [test x"$with_x" != x"no" && test x"$dx_cv_have_motif" = x"yes"])
69 AM_COND_IF([HAVE_MOTIF],
70   [MOTIF_CFLAGS=$dx_cv_motif_cflags MOTIF_LIBS=$dx_cv_motif_libs],
71   [AC_DEFINE([X_DISPLAY_MISSING])])
72 AH_TEMPLATE([X11_RENDER_DEBUG],
73   [Define to 1 to enable visual aids for debugging X11 rendering.])
74
75 # Check for XmPIXMAP_AND_STRING.
76 #
77 # Just checking for the existence of this identifier is sufficient, to ensure
78 # that the C compiler accepts the name.  If it turns out to not actually be
79 # supported by the library used at runtime, Motif itself will catch this
80 # and set to the default (i.e., XmSTRING).
81 AM_COND_IF([HAVE_MOTIF],
82 [AC_CACHE_CHECK([whether Motif supports XmPIXMAP_AND_STRING],
83 [dx_cv_motif_have_pixmap_and_string],
84 [save_CFLAGS=$CFLAGS save_LIBS=$LIBS
85 CFLAGS="$MOTIF_CFLAGS $CFLAGS" LIBS="$MOTIF_LIBS $LIBS"
86 AC_COMPUTE_INT([dx_tmp],
87   [XmPIXMAP != XmPIXMAP_AND_STRING && XmSTRING != XmPIXMAP_AND_STRING],
88   [#include <Xm/Label.h>], [dx_tmp=0])
89 AS_IF([test x"$dx_tmp" = x"1"],
90   [dx_cv_motif_have_pixmap_and_string=yes],
91   [dx_cv_motif_have_pixmap_and_string=no])
92 CFLAGS=$save_CFLAGS LIBS=$save_LIBS])
93 AS_IF([test x"$dx_cv_motif_have_pixmap_and_string" = x"yes"],
94   [AC_DEFINE([HAVE_MOTIF_PIXMAP_AND_STRING], [1],
95     [Define to 1 if Motif supports XmPIXMAP_AND_STRING])])
96 ])
97
98 dnl On ELF systems, linking a program against a string table in shared
99 dnl library is very expensive and actually makes things much worse than
100 dnl just duplicating the needed strings in the program.
101 dnl
102 dnl It may help a little bit when static linking or on other shared
103 dnl library implementations, which could maybe be auto-detected with
104 dnl a configure test, but the penalty for setting these anyway is
105 dnl very small (couple hundred bytes of rodata).
106 m4_foreach_w([lib], [Xt Xm],
107 [AC_DEFINE(m4_toupper(m4_defn([lib]))[STRINGDEFINES], [1],
108 [Define to 1 to avoid using the string tables from lib]m4_defn([lib])[.
109 On some platforms, or when statically linking lib]m4_defn([lib])[,
110 leaving this undefined may reduce the executable size somewhat.])])
111
112 AC_CONFIG_TESTDIR([.], [t:.])
113 DX_PROG_AUTOTEST_AM
114
115 AC_CHECK_PROGS([XPMTOPPM], [xpmtoppm])
116 AC_CHECK_PROGS([PNMTOPNG], [pnmtopng])
117 AC_CHECK_PROGS([CONVERT], [convert])
118 AC_CHECK_PROGS([GM], [gm])
119 AC_CACHE_CHECK([how to convert XPM to PNG], [dx_cv_xpm_to_png],
120 [cat >conftest.xpm <<'EOF'
121 /* XPM */
122 static char *x[] = {
123 "1 1 1 1",
124 "x c #123456",
125 "x"
126 };
127 EOF
128 check_conftest_png () {
129   od conftest.png | $AWK 'BEGIN { success=0; }
130 NR == 1 && $2 == "050211" && $3 == "043516" { success=1; }
131 NR == 1 && $2 == "104520" && $3 == "047107" { success=1; }
132 END { exit(!success); }'
133 }
134 rm -f conftest.png
135 for dx_cv_xpm_to_png in netpbm 'gm convert' convert unknown; do
136 AS_CASE([$dx_cv_xpm_to_png],
137
138 [netpbm],
139 [AS_IF([$XPMTOPPM conftest.xpm >conftest.ppm 2>&AS_MESSAGE_LOG_FD],
140   [], [continue])
141 AS_IF([$PNMTOPNG conftest.ppm >conftest.png 2>&AS_MESSAGE_LOG_FD],
142   [], [continue])
143 AS_IF([check_conftest_png], [break])],
144
145 [*convert],
146 [AS_CASE([$dx_cv_xpm_to_png],
147   [gm*], [test_convert="$GM convert"],
148   [test_convert="$CONVERT"])
149 AS_IF([$test_convert conftest.xpm conftest.png >&AS_MESSAGE_LOG_FD 2>&1],
150   [], [continue])
151 AS_IF([check_conftest_png], [break])])
152 done
153 rm -f conftest.xpm conftest.ppm conftest.png])
154
155 AM_CONDITIONAL([USE_NETPBM], [test x"$dx_cv_xpm_to_png" = x"netpbm"])
156 AM_CONDITIONAL([USE_CONVERT],
157   [AS_CASE([$dx_cv_xpm_to_png], [*convert], [], [false])])
158
159 AS_IF([test x"$dx_cv_xpm_to_png" = x"gm convert"],
160   [CONVERT="$GM convert"])
161
162 AC_CHECK_PROGS([OPTIPNG], [optipng])
163 : "${OPTIPNG:=:}"
164
165 AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"])
166
167 AC_CONFIG_FILES([Makefile])
168 AC_OUTPUT
169
170 have_ui=false
171 AM_COND_IF([HAVE_CURSES], [have_ui=:])
172 AM_COND_IF([HAVE_MOTIF], [have_ui=:])
173 AS_IF([$have_ui], [],
174 [AC_MSG_WARN([No user interface is enabled.])
175 AC_MSG_WARN([It will not be possible to play the game.])])