-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
435 lines (385 loc) · 13.9 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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#CFLAGS="-g"
AC_PREREQ([2.69])
# Version
m4_define(teo_major_version,[2])
m4_define(teo_minor_version,[0])
m4_define(teo_micro_version,[0b])
m4_define(teo_nano_version,[0])
#nano intentionaly left out, only used in windows dialog
m4_define([teo_version], [teo_major_version.teo_minor_version.teo_micro_version])
m4_define([teo_version_wrc], [teo_major_version, teo_minor_version, teo_micro_version, teo_nano_version])
AC_INIT([Teo-ng], [teo_version])
AM_INIT_AUTOMAKE([foreign subdir-objects])
#LT_INIT([disable-static],[dlopen])
LT_INIT
AC_CONFIG_SRCDIR([src/teo.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_CANONICAL_HOST
AC_DEFINE(TEO_VERSION_STR, "[teo_version]", [Package version constant, as defined in existing code base])
AC_DEFINE(TEO_YEAR_STRING, "2019", [Release year matching package version, as defined in existing code base])
AC_DEFINE(TEO_VERSION_WRC, [teo_version_wrc], [Package version constant, in a format suitable for Win32 resource files])
AC_DEFUN([AC_PROG_GCR], [AC_CHECK_PROG([GCR],[glib-compile-resources],[yes])])
#AC_SUBST(PACKAGE_HOMEPAGE,[https://sourceforge.net/projects/teoemulator/])
AC_SUBST(PACKAGE_HOMEPAGE,[http://www.teo-ng.com])
AC_SUBST(PACKAGE_CONTACT,[contact@teo-ng.com])
AC_SUBST(BUILD_TIMESTAMP,`date +%s`)
AC_DEFINE(PACKAGE_HOMEPAGE,["http://www.teo-ng.com"], [Website of the project])
# For functions like asprintf, get_current_dir_name
AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions.])
#compile options
AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Build an executable with debug sybmols and all optimization turned off (default=no)])],
[],
[enable_debug=no])
AC_ARG_ENABLE([profiling], [AS_HELP_STRING([--enable-profiling], [Build an executable that can be profiled with gprof (default=no)])],
[],
[enable_profiling=no])
AC_ARG_ENABLE([optimization], [AS_HELP_STRING([--enable-optimization], [Build an optimized executable. (default=yes)])],
[],
[enable_optimization=yes])
AC_ARG_ENABLE([machine_optimization], [AS_HELP_STRING([--enable-machine-optimization], [Build an optimized executable for the local machine using march and mtune=native. (default=no)])],
[],
[enable_machine_optimization=no])
AC_ARG_ENABLE([debian_build], [AS_HELP_STRING([--enable-debian-build], [Enable some Debian-specifc part of the codebase. (default=no)])],
[],
[debian_build=no])
AC_ARG_ENABLE([extra_tools], [AS_HELP_STRING([--enable-extra-tools], [Enable extra tools (default=no)])],
[],
[extra_tools=no])
#options
AC_ARG_ENABLE([gtk_panel], [AS_HELP_STRING([--enable-gtk-panel], [Enable GTK Panel when building against Allegro on Unix])],
[],
[enable_gtk_panel=no])
AC_ARG_ENABLE([gtk_debugger], [AS_HELP_STRING([--enable-gtk-debugger], [Enable GTK debugger when building against Allegro on Unix])],
[],
[enable_gtk_debugger=no])
#graphic backend
AC_ARG_WITH([gfx_backend], [AS_HELP_STRING([--with-gfx-backend=allegro,gtk-x11,sdl2], [Select graphic backend])],
[],
[with_gfx_backend=sdl2])
#Documentation
AC_ARG_WITH([doc],
[AS_HELP_STRING([--with-doc], [Install the documentation. [default=yes]])],
[AS_CASE([$with_doc],
[yes|no], [],
[AC_MSG_ERROR([Unrecognized value '${with_doc}' for --with-doc])]
)],
[with_doc=yes])
AM_CONDITIONAL([INSTALL_DOC], [test "x${with_doc}" = xyes])
# Checks for programs.
# Don't use the default -Wall -g -O2
#save_CFLAGS=$CFLAGS
AC_PROG_CC
CFLAGS="-Wall -O2"
AC_PROG_MAKE_SET
# Checks for header files.
AC_PATH_X
AC_CHECK_HEADERS([fcntl.h locale.h stddef.h stdlib.h string.h sys/ioctl.h sys/time.h termios.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
# Checks for library functions.
# Those 2 are based on runtime checks and therefore will always fail when cross compiling. R
# Replaced them with standard checks in AC_CHECK_FUNCS
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
AC_FUNC_MKTIME
AC_CHECK_FUNCS([malloc realloc atexit access getcwd memmove memset mkdir setlocale strchr strcspn strpbrk strrchr strstr strtol vasprintf get_current_dir_name scandir alphasort])
AM_GNU_GETTEXT([external])
#AM_GNU_GETTEXT_VERSION([0.19])
# check if the dirent structure of a d_type field and DT_UNKNOWN is defined
AC_MSG_CHECKING(if the dirent structure of a d_type field)
AC_LINK_IFELSE(
[
AC_LANG_SOURCE([[
#include <dirent.h>
int main() {
struct dirent entry;
return entry.d_type == DT_UNKNOWN;
}
]])
],[have_dirent_d_type=yes],[have_dirent_d_type=no])
AC_MSG_RESULT($have_dirent_d_type)
if test "$have_dirent_d_type" = yes; then
AC_DEFINE(HAVE_DIRENT_D_TYPE, 1,
[Define to 1 if the dirent structure has a d_type field])
fi
##########################
# Checking target platform
##########################
#WIN32/Mingw
AC_MSG_CHECKING([if compiling for Win32])
case "$host_os" in
*mingw*)
platform_win32=yes
;;
*)
platform_win32=no
;;
esac
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL([PLATFORM_WIN32], [test "x$platform_win32" = "xyes"])
AS_IF([test "x$platform_win32" = "xyes"],[
AC_DEFINE(PLATFORM_WIN32,[1],[Building for win32 and alike systems])
],[
AC_DEFINE(PLATFORM_WIN32,[0],[Building for win32 and alike systems])
])
####################
# Check for DOS/DJGPP
####################
AC_MSG_CHECKING([if compiling for MS-DOS])
case "$host_os" in
*djgpp*)
platform_msdos=yes
;;
*)
platform_msdos=no
;;
esac
AC_MSG_RESULT([$platform_msdos])
AM_CONDITIONAL(PLATFORM_MSDOS, test "x$platform_msdos" = "xyes")
AS_IF([test "x$platform_msdos" = "xyes"],[
AC_DEFINE(PLATFORM_MSDOS,[1],[Building for MS-DOS and alike systems])
],[
AC_DEFINE(PLATFORM_MSDOS,[0],[Building for MS-DOS and alike systems])
])
###########################################
# Otherwise just assume it's Linux/Unix
# If we ever need to deal with OS specifics
# just add another platform below
###########################################
AC_MSG_CHECKING([if compiling for Unix])
AS_IF([test "x$platform_win32" != "xyes" && test "x$platform_msdos" != "xyes"],[
platform_unix=yes
],[
platform_unix=no
])
AC_MSG_RESULT([$platform_unix])
AM_CONDITIONAL(PLATFORM_UNIX, test "x$platform_unix" = "xyes")
AS_IF([test "x$platform_unix" = "xyes"],[
AC_DEFINE(PLATFORM_UNIX,[1],[Building for unix-compatible systems])
AC_DEFINE(DIR_SEPARATOR,['/'],[Char that goes between directories in a path])
],[
AC_DEFINE(PLATFORM_UNIX,[0],[Building for unix-compatible systems])
AC_DEFINE(DIR_SEPARATOR,['\\'],[Char that goes between directories in a path])
])
####################
# Check for OS X
####################
#OSX/macOS
AC_MSG_CHECKING([if compiling for macOS(Darwin)])
case "$host_os" in
darwin*)
platform_osx=yes
;;
*)
platform_osx=no
;;
esac
AC_MSG_RESULT([$platform_osx])
AM_CONDITIONAL([PLATFORM_OSX], [test "x$platform_osx" = "xyes"])
AS_IF([test "x$platform_osx" = "xyes"],[
AC_DEFINE(PLATFORM_OSX,[1],[Building for OS X and alike systems])
],[
AC_DEFINE(PLATFORM_OSX,[0],[Building for OS X and alike systems])
])
#Win32 specific compiler flags
AS_IF([test "x$platform_win32" = "xyes" && test "x$enable_debug" != "xyes"],[
CC_CHECK_CFLAGS_APPEND([-mwindows])
])
# Checks for libraries.
AS_IF([test "x$platform_win32" = "xyes"],[
PKG_CHECK_MODULES([DEPS], [zlib])
PKG_CHECK_MODULES([PNG], [libpng])
AC_DEFINE([_WIN32_IE],[0x0300],[Minimum support level selection])
AC_CHECK_TOOL([WINDRES], [windres], [:])
],[test "x$platform_msdos" = "xyes"],[
PKG_CHECK_MODULES([PNG], [libpng])
AX_CHECK_COMPILE_FLAG([-fgnu89-inline],
[AX_APPEND_FLAG([-fgnu89-inline])],
[AC_MSG_WARN([-fgnu89-inline is not supported, linking with allegro might fail with gcc > 2.x])
])
],[
#Implicit Unix
PKG_CHECK_MODULES([DEPS], [glib-2.0])
PKG_CHECK_MODULES([PNG], [libpng])
])
AS_IF([test "x$enable_gtk_panel" != "xno"], [
AS_IF([test "x$platform_unix" != "xyes"],[
AC_MSG_ERROR(["GTK panel is not supported on $host_os"])
],[]);
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
AM_CONDITIONAL(ENABLE_GTK_PANEL, true)
AC_DEFINE(ENABLE_GTK_PANEL,[],[Use GTK for GUI])
AC_PROG_GCR
if test "x$GCR" != "xyes" ; then
AC_MSG_ERROR([glib-compile-resource needed for GTK/X11 backend and for GTK Panel])
fi
], [
AM_CONDITIONAL(ENABLE_GTK_PANEL, false)
])
AS_IF([test "x$enable_gtk_debugger" != "xno"], [
AS_IF([test "x$platform_unix" != "xyes"],[
AC_MSG_ERROR(["GTK debugger is not supported on $host_os"])
],[]);
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
AM_CONDITIONAL(ENABLE_GTK_DEBUGGER, true)
AC_DEFINE(ENABLE_GTK_DEBUGGER,[],[Use GTK for debugger GUI])
], [
AM_CONDITIONAL(ENABLE_GTK_DEBUGGER, false)
])
AS_CASE(["x$with_gfx_backend"],
["xallegro"],[
AM_CONDITIONAL(GFX_BACKEND_ALLEGRO, true)
AM_CONDITIONAL(GFX_BACKEND_GTK_X11, false)
AM_CONDITIONAL(GFX_BACKEND_SDL2, false)
AC_DEFINE(GFX_BACKEND_ALLEGRO,[],[Use Allegro for gfx rendering])
AC_SUBST(GFX_BACKEND,[allegro])
PKG_CHECK_MODULES([ALLEGRO], [allegro])
PKG_CHECK_MODULES([PNG], [libpng])
AS_IF([test "x$platform_unix" = "xyes"],[
AC_DEFINE(ALLEGRO_UNIX,[],[Building for Allegro on Unix])
],[]);
],
["xgtk-x11"],[
AS_IF([test "x$platform_unix" != "xyes"],[
AC_MSG_ERROR(["GTK/X11 graphic backend is not supported on $host_os"])
],[]);
AM_CONDITIONAL(GFX_BACKEND_GTK_X11, true)
AM_CONDITIONAL(GFX_BACKEND_ALLEGRO, false)
AM_CONDITIONAL(GFX_BACKEND_SDL2, false)
AC_DEFINE(GFX_BACKEND_GTK_X11,[],[Use GTK/X11 for gfx rendering])
AC_SUBST(GFX_BACKEND,[gtk_x11])
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
PKG_CHECK_MODULES([XEXT], [xext])
PKG_CHECK_MODULES([X11], [x11])
PKG_CHECK_MODULES([ALSA], [alsa])
AC_PROG_GCR
if test "x$GCR" != "xyes" ; then
AC_MSG_ERROR([glib-compile-resource needed for GTK/X11 backend and for GTK Panel])
fi
],
["xsdl2"],[
AM_CONDITIONAL(GFX_BACKEND_GTK_X11, false)
AM_CONDITIONAL(GFX_BACKEND_ALLEGRO, false)
AM_CONDITIONAL(GFX_BACKEND_SDL2, true)
AC_DEFINE(GFX_BACKEND_SDL2,[],[Use SDL2 for gfx rendering])
AC_SUBST(GFX_BACKEND,[sdl2])
PKG_CHECK_MODULES([SDL2], [sdl2])
AC_DEFINE(WITH_SDL2,[1],[Use SDL2 features that were not in SDL1.2])
],
[
AC_MSG_ERROR(["Valid values for --with-gfx-backend are 'allegro','gtk-x11' and 'sdl2'"])
]
)
if test "x$enable_extra_tools" = "xyes"; then
AM_CONDITIONAL(BUILD_EXTRA_TOOLS, true)
if test "x$platform_unix" = "xyes"; then
PKG_CHECK_MODULES([GTK], [gtk+-3.0],[
has_gtk=yes
],[
has_gtk=no
])
PKG_CHECK_MODULES([X11], [x11],[
has_x11=yes
],[
has_x11=no
])
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
AM_CONDITIONAL(BUILD_CC90, [test "x$has_gtk" = "xyes" && test "x$has_x11" = "xyes"])
else
if test "x$platform_win32" = "xyes"; then
AM_CONDITIONAL(BUILD_CC90,true)
else
AM_CONDITIONAL(BUILD_CC90, false)
fi
fi
else
AM_CONDITIONAL(BUILD_EXTRA_TOOLS, false)
AM_CONDITIONAL(BUILD_CC90, false)
fi
AS_IF([test "x$enable_gtk_panel" != "xno"], [
AS_IF([test "x$platform_unix" != "xyes"],[
AC_MSG_ERROR(["GTK panel is not supported on $host_os"])
],[]);
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
AM_CONDITIONAL(ENABLE_GTK_PANEL, true)
AC_DEFINE(ENABLE_GTK_PANEL,[],[Use GTK for GUI])
], [
AM_CONDITIONAL(ENABLE_GTK_PANEL, false)
])
# Debian-specific portions
AS_IF([test "x$enable_debian_build" = "xyes"],[
AM_CONDITIONAL(DEBIAN_BUILD, true)
],[
AM_CONDITIONAL(DEBIAN_BUILD, false)
])
################################
# Compile flags, debug/profile
################################
AC_MSG_CHECKING([Computing E_AM_CFLAGS])
E_AM_CFLAGS="-Wall"
OPTS_FLAGS="-O2 -funroll-loops -ffast-math"
if test "x$enable_debug" = "xyes"; then
enable_optimization=no
enable_machine_optimization=no
E_AM_CFLAGS+=" -O0 -g3 -DDEBUG"
fi
if test "x$enable_profiling" = "xyes"; then
E_AM_CFLAGS+=" -pg"
fi
if test "x$enable_optimization" = "xyes"; then
E_AM_CFLAGS+=" $OPTS_FLAGS"
fi
if test "x$enable_machine_optimization" = "xyes"; then
E_AM_CFLAGS+=" $OPTS_FLAGS -march=native -mtune=native"
fi
#TODO: Look into this
if test "x$enable_debian_build" = "xyes"; then
E_AM_CFLAGS+=" -DDEBIAN_BUILD"
fi
AC_MSG_RESULT([$E_AM_CFLAGS])
AC_SUBST(AM_CFLAGS, [$E_AM_CFLAGS])
AC_CONFIG_FILES([Makefile
po/Makefile.in
src/Makefile
data/Makefile
data/com.teo-ng.Teo.appdata.xml
data/com.teo-ng.Teo.desktop
data/Info.plist])
AM_COND_IF([GFX_BACKEND_ALLEGRO],
[AC_CONFIG_FILES([src/alleg/Makefile])])
AM_COND_IF([GFX_BACKEND_SDL2],
[AC_CONFIG_FILES([src/sdl2/Makefile])])
AM_COND_IF([PLATFORM_MSDOS],
[AC_CONFIG_FILES([src/dos/Makefile])])
AM_COND_IF([PLATFORM_UNIX],
[AC_CONFIG_FILES([src/linux/Makefile])])
AM_COND_IF([PLATFORM_WIN32],[
AC_CONFIG_FILES([src/win/Makefile])
AC_CONFIG_FILES([data/nsis/teo.nsis])
AC_CONFIG_FILES([src/win/wdialog.rc])
])
AM_COND_IF([INSTALL_DOC],[
AC_CONFIG_FILES([doc/Makefile])
])
AM_COND_IF([BUILD_EXTRA_TOOLS],
[AC_CONFIG_FILES([tools/Makefile
tools/cc90hfe/Makefile
tools/cc90hfe/src/Makefile
tools/k7tools/Makefile
tools/sap/Makefile
])])
AM_COND_IF([BUILD_EXTRA_TOOLS],[
AM_COND_IF([PLATFORM_WIN32],[
AC_CONFIG_FILES([tools/cc90hfe/src/win/Makefile])
])
])
AM_COND_IF([BUILD_EXTRA_TOOLS],[
AM_COND_IF([PLATFORM_UNIX],[
AC_CONFIG_FILES([tools/cc90hfe/src/linux/Makefile])
])
])
AC_OUTPUT