forked from dosemu2/dosemu2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
330 lines (283 loc) · 9.88 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
dnl Process this file with autoconf to produce a configure script.
AC_INIT([DOSEMU2], m4_esyscmd([tr -d '\n' < VERSION]),
[https://github.com/stsp/dosemu2/issues], dosemu2)
AC_CONFIG_SRCDIR(src/emu.c)
AC_PREREQ(2.59)
# first check if we are called from default-configure and if not,
# execute that to parse compiletime settings
if test -z "$DOSEMU_DEFAULT_CONFIGURE" ; then
eval "set -- $ac_configure_args"
exec $srcdir/default-configure "$@"
fi
AC_CONFIG_HEADER(src/include/config.h)
AC_CANONICAL_BUILD
dnl Checks for programs.
: ${CFLAGS=""}
AC_PROG_CC
dnl ifdef([AC_PROG_CC_C99], [AC_PROG_CC_C99], [CPPFLAGS="$CPPFLAGS -std=gnu99"; export CPPFLAGS])
AC_PROG_CPP
AC_ARG_WITH(target-bits, [ --with-target-bits=bits compile for 32 or 64 bits (default=auto)],
CPPFLAGS="$CPPFLAGS -m$with_target_bits"
export CPPFLAGS
LDFLAGS="$LDFLAGS -m$with_target_bits"
export LDFLAGS
)
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LEX
if test -z "`echo $LEX | grep flex`" ; then
AC_CHECK_PROG(lex_ok, $LEX, "yes", "no")
fi
if test "$lex_ok" = "no"; then
AC_MSG_WARN( )
AC_MSG_WARN(Your system doesn't seem to have lex or flex available.)
AC_MSG_ERROR(Install lex or flex and retry.)
fi
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_YACC
dnl The bison problem
if test -z "`echo $YACC | grep bison`" ; then
AC_MSG_WARN( )
AC_MSG_WARN(Your system doesn't seem to have bison available.)
AC_MSG_ERROR(Install bison and retry.)
fi
dnl Checks for libraries.
dnl Checks for header files.
AC_SYS_LARGEFILE
if test "$build_cpu" = "x86_64"; then
AC_CHECK_MEMBER([struct sigcontext.ss],[AC_DEFINE(HAVE_SIGCONTEXT_SS)],,
[[#include <signal.h>]])
fi
dnl Checks for library functions.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
#include <unistd.h>]], [[
#if !(defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 && defined(CLOCK_MONOTONIC))
#error No monotonic clock
#endif
return 0;
]])],,[
AC_MSG_ERROR([Sorry, you need glibc with monotonic clock support (2.3.3 or newer).])])
AC_CHECK_LIB(rt, shm_open)
AC_CHECK_FUNCS(shm_open)
dnl Here is where we do our stuff
AC_ARG_WITH(docdir,
[ --with-docdir=dir give the directory used to install documentation]
[ (default: ${prefix}/share/doc/dosemu)],
docdir="$withval", docdir="${prefix}/share/doc/dosemu")
AC_ARG_WITH(x11fontdir,
[ --with-x11fontdir=dir give the directory used to install the VGA X11 font]
[ (default: ${datadir}/dosemu/Xfonts)],
x11fontdir="$withval", x11fontdir="${datadir}/dosemu/Xfonts")
AC_ARG_WITH(syshdimagedir,
[ --with-syshdimagedir=dir give the directory used for system wide boot directories and hdimages]
[ (default: /var/lib/dosemu)],
syshdimagedir="$withval", syshdimagedir="/var/lib/dosemu")
AC_ARG_WITH(fdtarball,
[ --with-fdtarball=file give the name of the FreeDOS tarball or 'none']
[ (default: dosemu-freedos-bin.tgz)],
fdtarball="$withval", fdtarball="dosemu-freedos-bin.tgz")
AC_SUBST(docdir)
AC_SUBST(x11fontdir)
AC_SUBST(syshdimagedir)
AC_SUBST(fdtarball)
if test "$build_os" = "linux-gnu"; then
CONFIG_HOST='linux'
fi
AC_SUBST(CONFIG_HOST)
dnl Check for static and then also use it for tests
DOSEMU_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-declarations\
-Wnested-externs -fms-extensions -fno-stack-protector"
DOSEMU_LDFLAGS="-Wl,-warn-common"
AC_CHECK_LIB(m, pow)
AC_ARG_ENABLE(dlplugins,
AS_HELP_STRING([--disable-dlplugins], [do NOT use dynamically loaded plugins]))
if test "$enable_dlplugins" != "no"; then
AC_MSG_NOTICE(Using dynamically loaded plugins...)
AC_DEFINE(USE_DL_PLUGINS)
USE_DL_PLUGINS="USE_DL_PLUGINS=1"
AC_SUBST(USE_DL_PLUGINS)
DOSBIN_LDFLAGS="-rdynamic"
AC_SUBST(DOSBIN_LDFLAGS)
AC_CHECK_LIB(dl, dlopen)
else
AC_MSG_NOTICE(Not using dynamically loaded plugins...)
fi
dnl check for stack protector and abort
AC_MSG_CHECKING([for stack protector disabled])
AS_IF([[(
${CC} ${CFLAGS} ${DOSEMU_CFLAGS} -S -x c -o - - << _EOF_
int foo(int);
int foo(int i)
{
char a[2];
a[i]=0;
return a[i+1];
}
_EOF_
) | grep "%fs:" >/dev/null]],
[
AC_MSG_RESULT([no])
AC_MSG_ERROR([Cannot compile dosemu with stack protector enabled])
], AC_MSG_RESULT([yes]))
dnl Check whether we have pthreads and whether to use it
AC_CHECK_LIB(pthread, pthread_create,,[
AC_MSG_ERROR([No libpthread found, please install glibc-devel package])
])
dnl Check for the XKB extension to get reliable keyboard handling
AC_CHECK_HEADER(X11/XKBlib.h, AC_DEFINE(HAVE_XKB,1))
CONFIG_TIME=`date +"%F %T %z"`
AC_DEFINE_UNQUOTED(CONFIG_HOST, "$CONFIG_HOST")
AC_DEFINE_UNQUOTED(CONFIG_TIME, "$CONFIG_TIME")
REQUIRED="commands tools/periph"
dnl enable EXPERIMENTAL stuff
AC_ARG_ENABLE(experimental,
AS_HELP_STRING([--enable-experimental], [enable configuration of EXPERIMENTAL stuff]))
if test "$enable_experimental" = "yes"; then
AC_MSG_NOTICE(Allowing EXPERIMENTAL stuff to be configured...);
AC_DEFINE([EXPERIMENTAL], 1, [ Define this to enable experimental stuff ])
else
AC_MSG_NOTICE(EXPERIMENTAL stuff disabled...);
fi
dnl try to hook in available plug-ins
if test -x $srcdir/mkpluginhooks; then
$srcdir/mkpluginhooks
if test -f plugin_libdirs; then
PLUGINSUBDIRS=`cat plugin_libdirs`
PLUGINS=`echo $PLUGINSUBDIRS | sed 's/plugin\///g'`
AC_MSG_NOTICE(Including plugins: $PLUGINS);
cd src
for i in $PLUGINSUBDIRS; do
if ! grep USE_DL_PLUGINS $i/Makefile >/dev/null ; then
ST_PLUGINSUBDIRS="$ST_PLUGINSUBDIRS $i"
fi
done
cd ..
if test -f plugin_incdirs; then
cd src
for i in `cat ../plugin_incdirs`; do
if test -f ../configure.ac; then
for j in $i/*.h; do
ln -sf ../../$j plugin/include/`basename $j`
done
else
abssrcdir=`cd .. && cd $srcdir && pwd`
for j in $abssrcdir/src/$i/*.h; do
ln -sf $j plugin/include/`basename $j`
done
fi
done
cd ..
fi
else
AC_MSG_NOTICE(Compiling without plug-ins...)
fi
else
AC_MSG_NOTICE(Compiling without plug-ins...)
fi
dnl Do compilation for GDB
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [compile with debug info]))
if test "$enable_debug" = "yes"; then
AC_MSG_NOTICE(Compiling with debug info...);
else
AC_MSG_NOTICE(Compiling without debug info...);
fi
AC_ARG_ENABLE(asan, [AS_HELP_STRING(--enable-asan, [enable address sanitizer])])
AC_SUBST(OPTIONALSUBDIRS)
AC_SUBST(REQUIRED)
AC_SUBST(PLUGINSUBDIRS)
AC_SUBST(ST_PLUGINSUBDIRS)
dnl Now CFLAGS and INCLUDES
INCDIR="-I\${top_builddir}/src/include -I\${top_builddir}/src/plugin/include"
AC_SUBST(INCDIR)
AC_ARG_WITH(target_cpu, [ --with-target-cpu=CPU use the specified target CPU (default=auto)])
if test "$with_target_cpu" = ""; then
AC_MSG_NOTICE(Compiling with default target CPU...)
target_cpu=""
else
AC_MSG_NOTICE(Compiling with specified target CPU...)
target_cpu=$with_target_cpu
fi
AC_MSG_CHECKING(for $CC actually being clang...)
if "$CC" -v 2>&1|grep 'clang' >/dev/null; then
if "$CC" -no-integrated-as -E - < /dev/null 2>&1|grep 'clang' >/dev/null; then
AC_MSG_RESULT([yes])
else
ASFLAGS="$ASFLAGS -no-integrated-as"
AC_MSG_RESULT([yes, using -no-integrated-as for assembly language files.])
fi
# unfortunately clang is too buggy even on -O1
DOSEMU_CFLAGS="$DOSEMU_CFLAGS -Wno-microsoft -O0"
use_clang="yes"
else
CCAS="$CC"
DOSEMU_CFLAGS="$DOSEMU_CFLAGS -fplan9-extensions -Wno-maybe-uninitialized"
AC_MSG_RESULT([no])
use_clang="no"
fi
if test "$enable_debug" = "yes" ; then
DOSEMU_CFLAGS="$DOSEMU_CFLAGS -ggdb3"
if test -z "$CFLAGS" -a "$use_clang" = "no" ; then
# simx86 is too slow on gcc without -O
DOSEMU_CFLAGS="$DOSEMU_CFLAGS -O"
fi
elif test -z "$CFLAGS" -a "$use_clang" = "no" ; then
DOSEMU_CFLAGS="$DOSEMU_CFLAGS -O2"
fi
if test "$enable_debug" = "yes"; then
if test "$enable_asan" = "yes"; then
DOSEMU_CFLAGS="$DOSEMU_CFLAGS -fsanitize=address"
LDFLAGS="$LDFLAGS -fsanitize=address"
fi
AC_DEFINE(_DEBUG)
fi
AC_DEFINE(_GNU_SOURCE)
DOSEMU_CFLAGS="${DOSEMU_CFLAGS} ${OPT} ${PIPE}"
DOSEMU_CPPFLAGS="${DOSEMU_CPPFLAGS} -MMD -DCFLAGS_STR=\"$DOSEMU_CFLAGS $CFLAGS\""
AC_SUBST(ASFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(DOSEMU_CFLAGS)
AC_SUBST(DOSEMU_CPPFLAGS)
AC_SUBST(DOSEMU_LDFLAGS)
AC_SUBST(LIBS)
dnl Create output files. If you add new ones, please do it in order.
AC_CONFIG_FILES([Makefile.conf])
AC_CONFIG_COMMANDS([Makefile],
[ if ! test -f configure.ac; then
abssrcdir=`cd $srcdir && pwd`
mkdir -p `(cd $abssrcdir; find . -name .git -prune -o -name .svn -prune -o -name CVS -prune -o -type d -print)`
for i in `(cd $abssrcdir; find . -name Makefile)`; do
echo ln -sf $abssrcdir/$i $i
ln -sf $abssrcdir/$i $i
done
fi
])
AH_TEMPLATE([CONFIG_HOST],
[ Define the host for which Dosemu is configured ])
AH_TEMPLATE([CONFIG_TIME],
[ Define the configure time ])
AH_TEMPLATE(HAVE_XKB,
[Define this if you have the XKB extension])
AH_TEMPLATE([USE_DL_PLUGINS],
[ DEFINE this, if you want dynamically loaded plugins ])
AH_TEMPLATE([_DEBUG],
[ Define this for DEBUG info ])
AH_TEMPLATE([_GNU_SOURCE],
[ Define this if the GNU_SOURCE macro is necessary ])
AH_TEMPLATE([HAVE_SIGCONTEXT_SS],
[ Define this if struct sigcontext has .ss field ])
AC_OUTPUT
dnl Print some warnings (if neccessary)
if test "$GCC" != "yes" ; then
AC_MSG_WARN( )
AC_MSG_WARN(Your system doesn't seem to have the GNU C compiler (gcc).)
AC_MSG_WARN(Trying to compile with $CC.)
AC_MSG_WARN(If you are sure you have gcc, set the environment variable)
AC_MSG_WARN(CC to the complete name of gcc. Examples:)
AC_MSG_WARN(csh/tcsh: setenv CC /usr/local/bin/gcc)
AC_MSG_WARN(sh/ksh/bash: CC=/usr/local/bin/gcc ; export CC)
AC_MSG_WARN(Of course you could also include the gcc bin directory in)
AC_MSG_WARN(your path.)
fi