forked from audacious-media-player/audacious-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
252 lines (205 loc) · 6.22 KB
/
acinclude.m4
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
dnl Backward compatibility with older pkg-config <= 0.28
dnl Retrieves the value of the pkg-config variable
dnl for the given module.
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl ====================================================
m4_ifndef([PKG_CHECK_VAR], [
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])
])
dnl Add $1 to CFLAGS and CXXFLAGS if supported
dnl ==========================================
AC_DEFUN([AUD_CHECK_CFLAGS],[
AC_MSG_CHECKING([whether the C/C++ compiler supports $1])
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1 -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0;])],[
AC_MSG_RESULT(yes)
CFLAGS="$OLDCFLAGS $1"
CXXFLAGS="$CXXFLAGS $1"
],[
AC_MSG_RESULT(no)
CFLAGS="$OLDCFLAGS"
])
])
dnl Add $1 to CXXFLAGS if supported
dnl ===============================
AC_DEFUN([AUD_CHECK_CXXFLAGS],[
AC_MSG_CHECKING([whether the C++ compiler supports $1])
AC_LANG_PUSH([C++])
OLDCXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $1 -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0;])],[
AC_MSG_RESULT(yes)
CXXFLAGS="$OLDCXXFLAGS $1"
],[
AC_MSG_RESULT(no)
CXXFLAGS="$OLDCXXFLAGS"
])
AC_LANG_POP([C++])
])
dnl **
dnl ** Common checks
dnl **
AC_DEFUN([AUD_COMMON_PROGS], [
dnl Check platform
dnl ==============
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_MSG_CHECKING([operating system type])
HAVE_LINUX=no
HAVE_MSWINDOWS=no
HAVE_DARWIN=no
case "$target" in
*linux*)
AC_MSG_RESULT(Linux)
HAVE_LINUX=yes
;;
*mingw*)
AC_MSG_RESULT(Windows)
HAVE_MSWINDOWS=yes
;;
*darwin*)
AC_MSG_RESULT(Darwin)
HAVE_DARWIN=yes
;;
*)
AC_MSG_RESULT(other UNIX)
;;
esac
AC_SUBST(HAVE_MSWINDOWS)
AC_SUBST(HAVE_LINUX)
AC_SUBST(HAVE_DARWIN)
dnl Check for C and C++ compilers
dnl =============================
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([AC_C_BIGENDIAN])
AC_REQUIRE([AC_SYS_LARGEFILE])
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -std=gnu99 -ffast-math -Wall -pipe"
CXXFLAGS="$CXXFLAGS -ffast-math -Wall -pipe"
# use C++17 if possible (Qt 6 requires it)
AUD_CHECK_CXXFLAGS(-std=gnu++17)
if test "${CXXFLAGS%gnu++17}" = "$CXXFLAGS" ; then
CXXFLAGS="$CXXFLAGS -std=gnu++11"
fi
AUD_CHECK_CFLAGS(-Wtype-limits)
AUD_CHECK_CFLAGS(-Wno-stringop-truncation)
AUD_CHECK_CXXFLAGS(-Woverloaded-virtual)
fi
dnl On Mac, check for Objective-C and -C++ compilers
dnl ================================================
if test "x$HAVE_DARWIN" = "xyes"; then
AC_PROG_OBJC
AC_PROG_OBJCPP
AC_PROG_OBJCXX
AC_PROG_OBJCXXCPP
OBJCXXFLAGS="$OBJCXXFLAGS -std=c++11"
fi
dnl Enable "-Wl,-z,defs" only on Linux
dnl ==================================
if test $HAVE_LINUX = yes ; then
LDFLAGS="$LDFLAGS -Wl,-z,defs"
fi
dnl MinGW-specific flags
dnl ====================
if test $HAVE_MSWINDOWS = yes ; then
AC_DEFINE([__USE_MINGW_ANSI_STDIO], [1], "Use GNU-style printf")
CFLAGS="$CFLAGS -march=i686"
fi
dnl Byte order
dnl ==========
AC_C_BIGENDIAN([BIGENDIAN=1], [BIGENDIAN=0],
[AC_MSG_ERROR([Unknown machine byte order])],
[AC_MSG_ERROR([Universal builds are not supported, sorry])])
AC_SUBST([BIGENDIAN])
dnl Prevent symbol collisions
dnl =========================
if test "x$HAVE_MSWINDOWS" = "xyes" ; then
EXPORT="__declspec(dllexport)"
elif test "x$GCC" = "xyes" ; then
CFLAGS="$CFLAGS -fvisibility=hidden"
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
EXPORT="__attribute__((visibility(\"default\")))"
else
AC_MSG_ERROR([Unknown syntax for EXPORT keyword])
fi
AC_DEFINE_UNQUOTED([EXPORT], [$EXPORT], [Define to compiler syntax for public symbols])
dnl Checks for various programs
dnl ===========================
AC_PROG_LN_S
AC_PATH_PROG([RM], [rm])
AC_PATH_PROG([MV], [mv])
AC_PATH_PROG([CP], [cp])
AC_PATH_TOOL([AR], [ar])
AC_PATH_TOOL([RANLIB], [ranlib])
AC_PATH_TOOL([RC], [windres])
dnl Check for POSIX threads
dnl =======================
AC_SEARCH_LIBS([pthread_create], [pthread])
dnl Check for GTK+ and pals
dnl =======================
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32)
PKG_CHECK_MODULES(GMODULE, gmodule-2.0 >= 2.32)
AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_32], [target GLib 2.32])
dnl GTK+ support
dnl =============
AC_ARG_ENABLE(gtk3,
AS_HELP_STRING(--enable-gtk3, [Use GTK3 instead of GTK2 (default=disabled)]),
USE_GTK3=$enableval, USE_GTK3=no)
if test $USE_GTK3 = yes ; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.22)
AC_DEFINE(USE_GTK, 1, [Define if GTK+ support enabled])
AC_DEFINE(USE_GTK3, 1, [Define if GTK3+ support enabled])
fi
AC_SUBST(USE_GTK3)
AC_ARG_ENABLE(gtk,
AS_HELP_STRING(--disable-gtk, [Disable GTK+ support (default=enabled)]),
USE_GTK=$enableval, USE_GTK=yes)
if test $USE_GTK = yes -a $USE_GTK3 = no ; then
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.24)
AC_DEFINE([USE_GTK], [1], [Define if GTK+ support enabled])
fi
AC_SUBST(USE_GTK)
if test $USE_GTK = yes ; then
PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= 1.0)
fi
if test $HAVE_MSWINDOWS = yes ; then
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.32)
else
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.32 gio-unix-2.0 >= 2.32)
fi
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
dnl Qt support
dnl ==========
AC_ARG_ENABLE(qt,
AS_HELP_STRING(--disable-qt, [Disable Qt support (default=enabled)]),
USE_QT=$enableval, USE_QT=yes)
if test $USE_QT = yes ; then
PKG_CHECK_MODULES([QTCORE], [Qt5Core >= 5.2])
PKG_CHECK_VAR([QTBINPATH], [Qt5Core >= 5.2], [host_bins])
PKG_CHECK_MODULES([QT], [Qt5Core Qt5Gui Qt5Widgets >= 5.2])
AC_DEFINE([USE_QT], [1], [Define if Qt support enabled])
# needed if Qt was built with -reduce-relocations
QTCORE_CFLAGS="$QTCORE_CFLAGS -fPIC"
QT_CFLAGS="$QT_CFLAGS -fPIC"
fi
AC_SUBST(USE_QT)
AC_SUBST(QT_CFLAGS)
AC_SUBST(QT_LIBS)
AC_SUBST(QTBINPATH)
])