-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
288 lines (247 loc) · 11.1 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([ZBatt], [4.0.0], [amagura28@gmail.com],, [https://github.com/amagura/zelda-battery/issues])
#AC_CONFIG_SRCDIR([test.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
# Check for system extensions
AC_USE_SYSTEM_EXTENSIONS
# Check for targets
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
# M4 Code
m4_define([zb_natsolaris], [AS_CASE([$zb_build_type], [native::x*solaris*], [$1], [])])
m4_define([zb_natbsd], [AS_CASE([$zb_build_type], [native::x*bsd*], [$1], [])])
m4_define([zb_natsolaris_blk], [if echo "x$zb_build_type" | $ac_cv_path_GREP -q -- 'xnative::x.*solaris.*'; then])
m4_define([zb_natsolaris_klb], [fi])
m4_define([zb_natbsd_blk], [if echo "x$zb_build_type" | $ac_cv_path_GREP -q -- 'xnative::x.*bsd.*'; then])
m4_define([zb_natbsd_klb], [fi])
m4_define([zb_natnix_blk], [if echo "x$zb_build_type" | $ac_cv_path_EGREP -q -- 'xnative::x.*(bsd|linux|solaris).*'; then])
m4_define([zb_natnix_klb], [fi])
m4_define([zb_natunix_blk], [if echo "x$zb_build_type" | $ac_cv_path_EGREP -q -- 'xnative::x.*(bsd|solaris).*'; then])
m4_define([zb_natunix_klb], [fi])
m4_define([zb_natlinux_blk], [if echo "x$zb_build_type" | $ac_cv_path_GREP -q -- 'xnative::x.*linux.*'; then])
m4_define([zb_natlinux_klb], [fi])
m4_define([zb_natmswin_blk], [if echo "x$zb_build_type" | $ac_cv_path_EGREP -q -- 'xnative::x.*(cygwin|mingw32).*'; then])
m4_define([zb_natmswin_klb], [fi])
m4_define([zb_crnat_mswin_blk], [if echo "x$zb_build_type" | $ac_cv_path_EGREP -q -- 'xcross-native::x.*(cygwin|mingw32).*'; then])
m4_define([zb_crnat_mswin_klb], [fi])
#m4_define([zb_ncc_nix_blk], [m4_define([__argc__], [$#])
#m4_if([__argc__], [0], [if echo "x$zb_build_type" | $ac_cv_path_EGREP
m4_define([zb_grep], [echo "$1" | $ac_cv_path_EGREP -q -- m4_shift($@)])
# Check if we are cross compiling
#AS_IF([test "x$build" = "x$host" = "x$target"],
#[zb_build_type="native::x$host"],
#AS_IF([test "x$build" = "x$host"],
#[test "x$host" != "x$target"]
if test "x$build" = "x$host" \
&& test "x$host" = "x$target"; then
zb_build_type="native::x$host"
elif test "x$build" = "x$host" \
&& test "x$host" != "x$target"; then
zb_build_type="cross::x$target"
elif test "x$build" != "x$host" \
&& test "x$build" != "x$target" \
&& test "x$host" != "x$target"; then
zb_build_type="canadian::x$build::x$host::x$target"
elif test "x$build" != "$host" \
&& test "x$host" = "x$target" \
&& test "x$build" != "$target"; then
zb_build_type="cross-native::x$build::x$host::x$target"
fi
AS_CASE([$zb_build_type],
[native::*linux*|native::*bsd*|native::*solaris*],[
AC_PROG_CC
AC_PROG_CC_STDC
PKG_PROG_PKG_CONFIG()
[break]
],
[native::*cygwin*|native::*mingw*],[
AC_PROG_CXX
[break]
],)
dnl I only really need to support cross-building for windows
# Checks for programs.
AC_PROG_INSTALL
AC_PATH_PROGS_FEATURE_CHECK([GREP], [grep ggrep], [[echo 'a' | ac_cv_path_GREP -q -- 'a']])
AC_PATH_PROGS_FEATURE_CHECK([EGREP], [egrep gegrep], [[echo 'a' | ac_cv_path_EGREP -q -- 'a']])
AM_PATH_PYTHON([3.2])
# Checks for libraries.
dnl FIXME passing --with-x to configure.ac actually disables X Server support
AC_ARG_WITH([x],
AS_HELP_STRING([--without-x],
[disable x server support (default: enabled)])
AS_HELP_STRING([],
[supported options:
gtk3], [15], [30]),
[with_x=no],
[with_x=gtk3])
zb_natnix_blk
if test "x$with_x" != "xno"; then
AC_ARG_VAR([CYTHON], [Cython to C compiler (only used when '--with-x' is present)])
AC_CHECK_PROGS([CYTHON], [cython cython3], [no])
# AS_IF([test -z "$PYTHON_INCLUDE"], [
# AS_IF([test -z "$PYTHON_CONFIG"], [
# AS_IF([test "x$python_found" = "xno"],
#
AS_IF([test "x$CYTHON" = "xno"], [AC_MSG_ERROR([CYTHON is a make dependency for X server support.])])
AC_PATH_PROGS([PYTHON_CONFIG],
[python$PYTHON_VERSION-config python-config],
[no])
AS_IF([test "x$PYTHON_CONFIG" = "xno"], [AC_MSG_ERROR([python-config is a make dependency for X server support.])])
AC_MSG_CHECKING([python include flags])
AC_SUBST([PYTHON_CFLAGS], [`$PYTHON_CONFIG --includes`])
AC_MSG_RESULT([$PYTHON_CFLAGS])
AC_MSG_CHECKING([python ld flags])
AC_SUBST([PYTHON_LIBS], [`$PYTHON_CONFIG --libs --embed`])
AC_MSG_RESULT([$PYTHON_LIBS])
if test "x$with_x" = "xgtk3"; then
PKG_CHECK_MODULES([GTK3], [gtk+-3.0 >= 3.0], AC_DEFINE([WITH_GTK3], [1], [Defined when gtk3 is present.]))
# elif test "x$with_x" = "xgtk2"; then
# PKG_CHECK_MODULES([GTK2], [gtk+-2.0 >= 2.0], AC_DEFINE([WITH_GTK2], [1], [Defined when gtk2 is present.]))
fi
fi
zb_natnix_klb
#AS_IF([test "x$with_X" != "xno" && test "x$with_X" = "xgtk3"],
#[PKG_CHECK_MODULES([gtk3], [gtk+-3.0 >= 3.0], AC_DEFINE([HAVE_GTK3], [1], [Define if gtk3 is present.]))])
#AS_IF([test "x$with_X" != "xno" && test "x$with_X" = "xgtk2"],
#[PKG_CHECK_MODULES([gtk2], [gtk+-2.0 >= 2.0], AC_DEFINE([HAVE_GTK2], [1], [Define if gtk2 is present.]))])
# Check for needed items.
#AS_CASE([$zb_build_type],
#[native::x*solaris*],[AC_CHECK_HEADERS(
# Checks for header files.
AC_CHECK_HEADERS([limits.h stdlib.h string.h])
zb_natsolaris([AC_CHECK_HEADERS([sys/pm.h])])
zb_natunix_blk
# FIXME, only solaris and openbsd actually need ioctl
AC_CHECK_HEADERS([sys/ioctl.h])
zb_natunix_klb
zb_crnat_mswin_blk
[mswin=false]
AC_CHECK_HEADERS([{W,w}indows.h {W,w}inapifamily.h \
_mingw_unicode.h specstrings.h \
{s,S}hellapi.h],
[mswin=true],
,
[[#ifdef HAVE_WINDOWS_H
# include <Windows.h>
# include <windows.h>
#endif
#ifdef HAVE_WINAPIFAMILY_H
# include <winapifamily.h>
#endif
#ifdef HAVE__MINGW_UNICODE_H
# include <_mingw_unicode.h>
#endif
#ifdef HAVE_SPECSTRINGS_H
# include <specstrings.h>
#endif
#ifdef HAVE_SHELLAPI_H
# include <shellapi.h>
#endif
]])
zb_crnat_mswin_klb
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([bzero memmove mempcpy memset strchr strerror strtol])
zb_natnix_blk
AC_ARG_WITH([commoner],
AS_HELP_STRING([--with-commoner],
[enable libcommoner use (default: disabled)]),
[with_commoner=check],
[with_commoner=no])
AC_SEARCH_LIBS([nearbyint], [m],
,
[AC_MSG_ERROR([nearbyint is not defined by libm: use a C99 compliant compiler])])
# add support for libcommoner
LIBCOMMONER=
AS_IF([test "x$with_commoner" != xno],
[AC_SEARCH_LIBS([concatm],
[commoner],
AC_DEFINE([HAVE_LIBCOMMONER], [1], [Defined when libcommoner is present]),
[if test "x$with_commoner" != xcheck; then
AC_MSG_FAILURE([--with-commoner was given, but test for commoner failed])
fi
])])
#[AC_CHECK_LIB([commoner], [concatm],
#[AC_SUBST([LIBCOMMONER], ["-lcommoner"])
#AC_DEFINE([HAVE_LIBCOMMONER], [1])
#],
#[if test "x$with_commoner" != xcheck; then
#AC_MSG_FAILURE([--with-commoner was given, but test for commoner failed])
#fi
#], -commoner)])
#if test "x$with_commoner" == "xyes"; then
#AC_SEARCH_LIBS([concatm],
#[commoner],
#AC_DEFINE([HAVE_CONCATM], [1]),)
#fi
zb_natnix_klb
zb_natbsd_blk
AC_CHECK_FUNCS([sysctlbyname],
,
AC_SEARCH_LIBS([sysctlbyname],
[c],
[AC_DEFINE([HAVE_SYSCTLBYNAME], [1])],
[AC_MSG_WARN([*BSD systems without 'sysctlbyname' are not supported.])]))
zb_natbsd_klb
# Check for files.
zb_natlinux_blk
AC_CHECK_FILES([/sys/class/power_supply],
,
AC_CHECK_FILES([/proc/acpi/ac_adapter],
[AC_MSG_WARN([Support for kernels older than 2.6.24 is experimental])],
[AC_MSG_ERROR([Linux kernels without '/proc/acpi' or '/sys/class/power_supply' are not supported.])]))
## Check for Linux specific headers
AC_CHECK_HEADERS([glob.h])
## Check for Linux specific functions
AC_CHECK_FUNCS([globfree],
,
[AC_SEARCH_LIBS([globfree],
[c android-glob],
[AC_DEFINE([HAVE_GLOBFREE], [1])],
[AC_MSG_ERROR([Linux systems without 'globfree' are not supported.])])])
zb_natlinux_klb
AC_CONFIG_FILES([Makefile
img/Makefile
src/Makefile
src/mswin/Makefile])
#########
# Options
#########
AC_ARG_ENABLE([debug],
[ --enable-debug turn on debugging (default: disabled)],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_WARN([bad value '${enableval}' for --enable-debug]) ;;
esac],[debug=no])
test "x$debug" = "xno" && no_debug=false
test "x$debug" = "xfalse" && no_debug=true
#AC_CONFIG_SUBDIRS([old
#src/test])
# Automake directives
dnl `foreign' prevents autotools from installing a copy of the GPL
dnl `-Wall' gets rid of unnecessary warnings
AM_INIT_AUTOMAKE([foreign -Wall])
AM_CONDITIONAL([X], [test "x$with_x" != "xno"])
AM_CONDITIONAL([NATIVE], [test "x$native" = "xtrue"])
AM_CONDITIONAL([GENERIC], [test "x$generic" = "xtrue"])
AM_CONDITIONAL([STATIC], [test "x$static" = "xtrue"])
AM_CONDITIONAL([DEBUG], [test "x$debug" = "xtrue"])
AM_CONDITIONAL([NO_DEBUG], [test "x$debug" != "xtrue"])
AM_CONDITIONAL([MSWIN], [test "x$mswin" = "xtrue"])
AM_CONDITIONAL([TEST], [test "x$testdir" = "xtrue"])
m4_define([CLANG], [test "x`echo __clang__ | $CC -E -w -P -nostdinc -`" = "x"])
# XXX I'm guessing that tinyc doesn't expand __TINYC__ to a predictable value
# so instead of checking for a value, we're checking to see if the compiler doesn't expand
# __TINYC__ to anything; if it doesn't, then we know we're not using TINYC, so if it does, we know
# that we're using TINYC
m4_define([TINYC], [test ! "x`echo __TINYC__ | $CC -E -w -P -nostdinc -`" = "x__TINYC__"])
AM_CONDITIONAL([CPU_KNOWN], [test ! "x$CPUARCH" = "x" && test ! "x$CPUARCH" = "xunknown" && (]CLANG[ || ]TINYC[)])
AC_OUTPUT