forked from libxmp/libxmp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.ac
302 lines (268 loc) · 8.6 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
m4_define([libxmp_VERSION_MAJOR_m4], [4])
m4_define([libxmp_VERSION_MINOR_m4], [6])
m4_define([libxmp_VERSION_PATCH_m4], [0])
m4_define([libxmp_VERSION_m4], libxmp_VERSION_MAJOR_m4[.]libxmp_VERSION_MINOR_m4[.]libxmp_VERSION_PATCH_m4)
AC_PREREQ(2.60)
AC_INIT([libxmp],libxmp_VERSION_m4)
AC_ARG_ENABLE(depackers, [ --disable-depackers Don't build depackers])
AC_ARG_ENABLE(prowizard, [ --disable-prowizard Don't build ProWizard])
AC_ARG_ENABLE(static, [ --enable-static Build static library])
AC_ARG_ENABLE(shared, [ --disable-shared Don't build shared library])
AC_ARG_ENABLE(lite, [ --enable-lite Build lite version of the library])
AC_ARG_ENABLE(it, [ --disable-it Disable IT format in libxmp-lite])
AC_SUBST(LD_VERSCRIPT)
AC_SUBST(LIBM)
AC_SUBST(DARWIN_VERSION)
AC_CANONICAL_HOST
AC_PROG_CC
LT_PATH_LD
AC_CHECK_TOOL(AR, [ar], [:])
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_C_BIGENDIAN
dnl XMP_TRY_COMPILE(<message>,<cache-var>,<flags>,<program>,<ifyes>,<ifno>)
AC_DEFUN([XMP_TRY_COMPILE],[
AC_CACHE_CHECK([$1],[$2],[
oldcflags="${CFLAGS}"
CFLAGS="${CFLAGS} $3"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[$4]])],[$2=yes],[$2=no],[true])
CFLAGS="${oldcflags}"])
AS_IF([test "x$$2" = xyes], [$5], [$6])])
AC_DEFUN([AC_CHECK_DEFINED],[
AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1])dnl
AC_CACHE_CHECK([for $1 defined], ac_var,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#ifdef $1
int ok;
#else
choke me
#endif
]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
AS_IF([test AS_VAR_GET(ac_var) != "no"], [$2], [$3])dnl
AS_VAR_POPDEF([ac_var])dnl
])
case "${host_cpu}" in
powerpc64)
CFLAGS="${CFLAGS} -m64"
LDFLAGS="${LDFLAGS} -m64"
;;
esac
case "${host_os}" in
darwin*)
DARWIN_VERSION="`echo ${host_os#darwin}|cut -f1 -d'.'`"
if test "${enable_shared}" != no; then
CFLAGS="${CFLAGS} -fno-common"
fi
;;
cygwin* | *djgpp | emx* | mint* | amigaos* | aros* | morphos*)
enable_static=yes
enable_shared=no
;;
esac
AC_CHECK_DEFINED(__clang__)
case "${host_os}" in
dnl Skip this on platforms where it is just simply busted.
openbsd*) ;;
darwin*) LDFLAGS="$LDFLAGS -Wl,-undefined,error" ;;
dnl For whatever reason, the Clang sanitizers and --no-undefined for
dnl shared libraries are incompatible.
*) if test "$ac_cv_defined___clang__" = "no" || test "${LDFLAGS#*fsanitize}" = "$LDFLAGS"
then
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--no-undefined"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [], [LDFLAGS="$save_LDFLAGS"])
fi
;;
esac
if test "${enable_static}" = yes; then
STATIC="static"
if test "${enable_lite}" = yes; then
STATIC="$STATIC static-lite"
fi
AC_SUBST(STATIC)
fi
if test "${enable_shared}" != no; then
AC_CHECK_DEFINED(_WIN32,[
SHARED="dll"
CFLAGS_SHARED="-DBUILDING_DLL"
],[
CFLAGS_SHARED="-fPIC"
AC_CHECK_DEFINED(__APPLE__,[
SHARED="dylib"
],[
SHARED="shared"
])
])
if test "${enable_lite}" = yes; then
SHARED="$SHARED $SHARED-lite"
fi
AC_SUBST(SHARED)
AC_SUBST(CFLAGS_SHARED)
fi
XMP_TRY_COMPILE(whether compiler understands -Wall,
ac_cv_c_flag_w_all,
-Wall,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wall")
XMP_TRY_COMPILE(whether compiler understands -Wextra,
ac_cv_c_flag_w_extra,
-Wextra,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wextra")
XMP_TRY_COMPILE(whether compiler understands -Wunused-parameter,
ac_cv_c_flag_w_unused_parameter,
-Wunused-parameter,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wno-unused-parameter")
if test x$ac_cv_c_flag_w_extra != xyes && test x$ac_cv_c_flag_w_unused_parameter = xyes; then
XMP_TRY_COMPILE(whether compiler understands -W,
ac_cv_c_flag_w, -W,
[int main(void){return 0;}], CFLAGS="${CFLAGS} -W")
fi
XMP_TRY_COMPILE(whether compiler understands -Wsign-compare,
ac_cv_c_flag_w_sign_compare,
-Wsign-compare,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wno-sign-compare")
XMP_TRY_COMPILE(whether compiler understands -Wwrite-strings,
ac_cv_c_flag_w_write_strings,
-Wwrite-strings,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wwrite-strings")
XMP_TRY_COMPILE(whether compiler understands -Wundef,
ac_cv_c_flag_w_undef,
-Wundef,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wundef")
old_CFLAGS="${CFLAGS}"
XMP_TRY_COMPILE(whether compiler understands -Werror,
ac_cv_c_flag_w_error,
-Werror,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Werror")
XMP_TRY_COMPILE(whether compiler understands -xldscope=hidden,
ac_cv_c_flag_xldscope_hidden,
-xldscope=hidden,[
__global int foo(void) {}],
[CFLAGS="${old_CFLAGS} -xldscope=hidden -DXMP_LDSCOPE_GLOBAL"],
[XMP_TRY_COMPILE(whether compiler understands -fvisibility=hidden,
ac_cv_c_flag_f_visibility_hidden,
-fvisibility=hidden,[
__attribute__((visibility("default"))) int foo(void);
__attribute__((visibility("hidden"))) int bar(void);
int foo(void) { return 0; }
int bar(void) { return 1; }])]
)
case $host_os in
mingw*|cygwin*|emx*|*djgpp|amigaos*|aros*|morphos*)
if test $ac_cv_c_flag_f_visibility_hidden = yes; then
AC_MSG_NOTICE([ignoring -fvisibility flags for $host_os])
fi
ac_cv_c_flag_f_visibility_hidden=no
;;
esac
have_versioned_symbols=no
if test $ac_cv_c_flag_f_visibility_hidden = no; then
CFLAGS="${old_CFLAGS}"
else
CFLAGS="${old_CFLAGS} -fvisibility=hidden -DXMP_SYM_VISIBILITY"
if test $lt_cv_prog_gnu_ld = yes; then
case "${host_os}" in
emscripten*|beos*|atheos*|*mint)
;;
*) if test "${enable_shared}" != no; then
have_versioned_symbols=yes
CFLAGS_SHARED="${CFLAGS_SHARED} -DUSE_VERSIONED_SYMBOLS=1"
fi
LD_VERSCRIPT="-Wl,--version-script,libxmp.map"
;;
esac
fi
old_CFLAGS="${CFLAGS}"
if test $ac_cv_c_flag_w_error = yes; then
CFLAGS="${CFLAGS} -Werror"
fi
XMP_TRY_COMPILE(whether compiler understands attribute externally_visible,
ac_cv_c_attribute_visibility_external,[],[
__attribute__((visibility("default"),externally_visible)) int foo(void);
int foo(void) { return 0; }],
[CFLAGS="${old_CFLAGS} -DHAVE_EXTERNAL_VISIBILITY"],
[CFLAGS="${old_CFLAGS}"])
XMP_TRY_COMPILE(whether compiler understands attribute __symver__,
ac_cv_c_attribute_symver,[-Werror=attributes],[
void foo(void) __attribute__((__symver__("foo@bar")));],
[CFLAGS="${CFLAGS} -DHAVE_ATTRIBUTE_SYMVER"],
[CFLAGS="${CFLAGS}"])
fi
AC_MSG_CHECKING(whether to enable versioned symbols support)
AC_MSG_RESULT($have_versioned_symbols)
dnl for clang
XMP_TRY_COMPILE(whether compiler understands -Wunknown-warning-option,
ac_cv_c_flag_w_unknown_warning_option,
-Wunknown-warning-option,[
int main(void){return 0;}],
CFLAGS="${CFLAGS} -Wno-unknown-warning-option")
if test "${enable_lite}" = yes &&\
test "${enable_it}" = no; then
CFLAGS="${CFLAGS} -DLIBXMP_CORE_DISABLE_IT"
fi
if test "${enable_depackers}" != no; then
DEPACKER_OBJS='$(DEPACKER_OBJS)'
else
CFLAGS="${CFLAGS} -DLIBXMP_NO_DEPACKERS"
fi
AC_SUBST(DEPACKER_OBJS)
if test "${enable_prowizard}" != no; then
PROWIZARD_OBJS='$(PROWIZARD_OBJS)'
else
CFLAGS="${CFLAGS} -DLIBXMP_NO_PROWIZARD"
fi
AC_SUBST(PROWIZARD_OBJS)
LIBM=
case "${host_os}" in
dnl These systems don't have libm or don't need it (list based on libtool)
mingw*|darwin*|cygwin*|haiku*|beos*|cegcc*|pw32*)
;;
dnl djgpp has all c89 math funcs in libc.a
*djgpp)
;;
*) AC_CHECK_LIB(m, ceil, LIBM="-lm")
LIBS="${LIBS} ${LIBM}"
;;
esac
AC_CHECK_FUNCS(powf)
AC_MSG_CHECKING(for dirent)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <dirent.h>]], [[
DIR *dirp = opendir(".");
struct dirent *d = readdir(dirp);
(void)d; closedir(dirp);]])],
[have_dirent=yes
AC_DEFINE(HAVE_DIRENT,1,[ ])],
[have_dirent=no])
AC_MSG_RESULT($have_dirent)
AC_CHECK_FUNCS(popen mkstemp fnmatch umask)
dnl fork, execv & co don't work with djgpp
case "${host_os}" in
*djgpp|mingw*|riscos*)
;;
*) AC_CHECK_FUNCS(wait pipe fork execvp dup2)
;;
esac
case "${host_os}" in
amigaos*|aros*|morphos*)
AC_CHECK_HEADERS(proto/xfdmaster.h)
;;
esac
AC_SUBST([libxmp_VERSION_MAJOR],libxmp_VERSION_MAJOR_m4)
AC_SUBST([libxmp_VERSION_MINOR],libxmp_VERSION_MINOR_m4)
AC_SUBST([libxmp_VERSION_PATCH],libxmp_VERSION_PATCH_m4)
AC_SUBST([libxmp_VERSION],libxmp_VERSION_m4)
AC_SUBST([libxmplite_VERSION],libxmp_VERSION_m4)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([libxmp.pc])
AC_CONFIG_FILES([libxmp-config-version.cmake.autotools])
if test "${enable_lite}" = yes; then
AC_CONFIG_FILES([libxmp-lite.pc:src/lite/libxmp-lite.pc.in])
AC_CONFIG_FILES([libxmp-lite-config-version.cmake.autotools:src/lite/libxmp-lite-config-version.cmake.autotools.in])
fi
AC_OUTPUT