/
configure.ac
471 lines (370 loc) · 15.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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# Narayan Designer, a modelling tool for the Narayan simulation engine.
# Copyright (C) 2017-2018 Cartesian Theatre™. All rights reserved.
# Minimum version of Autoconf used to successfully process configure.ac...
AC_PREREQ([2.67])
# Initialize Autoconf...
AC_INIT(
[narayan-designer],
[0.0.001],
[https://github.com/cartesiantheatre/narayan-designer/issues],
[narayan-designer],
[https://www.cartesiantheatre.com])
# Clear default C / C++ compiler flags. Otherwise -g -O2 is automatically set
# for the GNU C++ by AC_PROG_CC and AC_PROG_CXXCPP. Can still be overridden by
# user. This needs to be right here after AC_INIT or these variables will get
# clobbered...
: ${CFLAGS=""}
: ${CXXFLAGS=""}
# Location to find auxiliary automake scripts...
AC_CONFIG_AUX_DIR([Auxiliary])
# Location to find Autoconf plugins...
AC_CONFIG_MACRO_DIR([Macros])
# Sanity check to ensure generated ./configure script knows the directory on
# which it is being executed is actually the project directory by providing any
# unique source file...
AC_CONFIG_SRCDIR([Source/Main.cpp])
# Preserve all arguments for products that want them into config.h...
config_flags="$0 $*"
AC_DEFINE_UNQUOTED(
[CONFIGURATION_FLAGS],
["$config_flags"],
[All flags that were passed to configure at configuration time.])
# Store build date stamp...
package_build_date=$(date --rfc-2822)
AC_DEFINE_UNQUOTED(
[PACKAGE_BUILD_DATE],
["$package_build_date"],
[Date and time this package was built.])
AC_SUBST([PACKAGE_BUILD_DATE], [$package_build_date])
# Copyright notice...
copyright_notice="Copyright (C) 2017-2018 Cartesian Theatre™."
AC_COPYRIGHT([$copyright_notice])
AC_DEFINE_UNQUOTED(
[COPYRIGHT_NOTICE],
["$copyright_notice"],
[Upstream vendor's copyright notice.])
AC_SUBST([COPYRIGHT_NOTICE], [$copyright_notice])
# Initialize Automake...
# Setup flags. Add std-options later...
AM_INIT_AUTOMAKE([
color-tests \
dist-bzip2 \
foreign \
no-dist-gzip \
silent-rules \
subdir-objects \
tar-pax \
-Wall \
-Werror])
# Set by default to use silent build rules...
AM_SILENT_RULES([yes])
# Always enable maintainer mode, but allow user the option to disable it...
AM_MAINTAINER_MODE([enable])
# Initialize libtool...
# We need the archiver because we build a static convenience library. We
# need to expand this before LT_INIT...
AM_PROG_AR
# Minimum version required...
LT_PREREQ([2.4.6])
# Initialize with support for dynamic object loading at runtime...
LT_INIT
# Prepare canonical values for the platform we are compiling on and the platform
# to host the generated files on...
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# Configure config.h...
# Location to generate headers from templates containing Autoconf
# substitution variables...
AC_CONFIG_HEADERS([Source/config.h])
# Check for command-line options...
# Bash completion...
AC_ARG_ENABLE([bash-completion],
[AS_HELP_STRING([--enable-bash-completion],
[enable bash completion @<:@default: yes@:>@])], # Quadrigraph escaped
[enable_bash_completion=${enableval}],
[enable_bash_completion="yes"])
AM_CONDITIONAL(USE_BASH_COMPLETION, [test x"$enable_bash_completion" = "xyes"])
# Unit tests...
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--enable-tests],
[enable unit tests @<:@default: yes@:>@])], # Quadrigraph escaped
[enable_tests=${enableval}],
[enable_tests="yes"])
AM_CONDITIONAL(ENABLE_TESTS, [test x"$enable_tests" = "xyes"])
# Update caches for desktop entries, mime, and icons...
AC_ARG_ENABLE([caches],
[AS_HELP_STRING([--enable-caches],
[run update-{desktop-database,mime-database,icon-cache} to update caches when installing and uninstalling @<:@default: yes@:>@])], # Quadrigraph escaped
[enable_caches=${enableval}],
[enable_caches="yes"])
AM_CONDITIONAL(UPDATE_CACHES, [test x"$enable_caches" = "xyes"])
# Initialize i18n from GNU gettext...
# Version 0.19.7 forward supports GtkBuilder XML, .desktop files, GSettings
# schemas, AppData, and Custom XML formats with ITS rules...
# Note: No white space indentation because of
# <https://savannah.gnu.org/bugs/index.php?52424>
AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION([0.19.8])
# These options get passed to xgettext. These are the full GLib-approved
# list of options for use in a Gtk+ project...
AM_XGETTEXT_OPTION([--from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments])
# Make sure we are not being run as root...
#if test $UID == 0; then
# AC_MSG_ERROR([there is never a good reason to run this script as root..."])
#fi
# Make sure paths are sane...
# Alert user...
AC_MSG_CHECKING([whether paths are sane...])
# Build directory must not contain spaces...
if echo $PWD | grep -E ' ' >/dev/null ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([your build path must not contain spaces...])
fi
# Source directory must not contain spaces...
if echo $srcdir | grep -E ' ' >/dev/null ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([your source path must not contain spaces...])
fi
# Paths are sane...
AC_MSG_RESULT([yes])
# Checks for programs needed to build everything and perform unit tests...
# Bison C++ parser generator...
AX_PROG_BISONCPP([6.01.01])
AC_PATH_PROG([BISONCPP], [bisonc++])
# chmod...
AC_PATH_PROG([CHMOD], [chmod])
# C++14 compiler with strict conformance required...
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14([noext], [mandatory])
# C++ preprocessor...
AC_PROG_CXXCPP
# desktop-file-validate(1) tool to validate Desktop Entry files...
AC_PATH_PROG([DESKTOP_FILE_VALIDATE], [desktop-file-validate])
if test "x$DESKTOP_FILE_VALIDATE" = "x"; then
AC_MSG_ERROR([desktop-file-validate required, but unavailable...])
fi
# Flex C++ lexer generator...
AX_PROG_FLEXCPP([2.06.02])
AC_PATH_PROG([FLEXCPP], [flexc++])
# GSettings schema to binary compilation tool...
GLIB_GSETTINGS
# grep(1) required for test suite...
AC_PROG_GREP
# install(1) utility to copy files and set attributes...
AC_PROG_INSTALL
# mkdir -p functionality required in several places...
AC_PROG_MKDIR_P
# mktemp(1) tool required to perform test suite...
AC_PATH_PROG([MKTEMP], [mktemp])
if test "x$MKTEMP" = "x"; then
AC_MSG_ERROR([mktemp tool is required to perform test suite...])
fi
# rmdir(1) necessary in various places...
AC_PATH_PROG([RMDIR], [rmdir])
if test "x$RMDIR" = "x"; then
AC_MSG_ERROR([rmdir required, but unavailable...])
fi
# sed(1) tool...
AC_PROG_SED
# sort(1) command...
AC_PATH_PROG([SORT], [sort])
if test "x$SORT" = "x"; then
AC_MSG_ERROR([sort required, but unavailable...])
fi
# update-desktop-database(1) tool to update cache database of MIME types
# handled by Desktop Entries...
AC_PATH_PROG([UPDATE_DESKTOP_DATABASE], [update-desktop-database])
if test "x$UPDATE_DESKTOP_DATABASE" = "x"; then
AC_MSG_ERROR([update-desktop-database required, but unavailable...])
fi
# update-icon-caches(1) tool to update icon caches...
AC_PATH_PROG([UPDATE_ICON_CACHES], [update-icon-caches])
if test "x$UPDATE_ICON_CACHES" = "x"; then
AC_MSG_ERROR([update-icon-caches required, but unavailable...])
fi
# update-mime-database(1) tool to update shared MIME-Info database cache...
AC_PATH_PROG([UPDATE_MIME_DATABASE], [update-mime-database])
if test "x$UPDATE_MIME_DATABASE" = "x"; then
AC_MSG_ERROR([update-mime-database required, but unavailable...])
fi
# Valgrind optional, but used in unit testing if enabled by default...
AX_VALGRIND_CHECK
if test "x$enable_valgrind" = "xyes" && test "$VALGRIND" = ""; then
AC_MSG_ERROR([valgrind required to perform test suite, but not found; either install or reconfigure with --disable-valgrind])
fi
# xvfb-run for unit test...
AC_PATH_PROG([XVFB_RUN], [xvfb-run])
# Select our native language of C++ to perform tests in, unless we specify
# otherwise later...
AC_LANG([C++])
# Define some other preprocessor symbols of things our source needs...
# Documentation directory...
package_docdir=${prefix}/share/doc/${PACKAGE_TARNAME}
AC_DEFINE_UNQUOTED(
[DOCDIR],
["$package_docdir"],
[Location documentation for this package was installed to.])
# Substitute autoconfig macros in various non-make related files...
# Desktop entry. Note that ...desktop.in.in requires substitution.
# ...desktop.in requires no variable substitution, but needs to pass
# through msgfmt to generate the translated Desktop Entry...
AC_CONFIG_FILES([Data/com.cartesiantheatre.narayan-designer.desktop.in])
# System manual...
AC_CONFIG_FILES([Manual/narayan-designer.man])
# Update version string...
AC_CONFIG_FILES([Source/Version.h])
# Checks for system headers and features...
# SIMD extensions...
AX_CHECK_X86_FEATURES
AC_LANG([C++]) # The above clobbers AC_LANG...
# Figure out how to set a software traps on this particular hardware...
AC_MSG_CHECKING([how to trigger software traps on $host_cpu])
BREAKPOINT_TRAP=""
case "$host_cpu" in
arm*) BREAKPOINT_TRAP="asm volatile(\"bkpt\");" ;;
mips*) BREAKPOINT_TRAP="asm volatile(\"teq \$0, \$0\");" ;;
*i?86) ;&
x86_64) BREAKPOINT_TRAP="asm volatile(\"int \$0x03\");" ;;
esac
AC_DEFINE_UNQUOTED([BREAKPOINT_TRAP], $BREAKPOINT_TRAP, [Trigger a software trap on this architecture...])
AC_MSG_RESULT([$BREAKPOINT_TRAP])
# Standard C++ headers...
AC_CHECK_HEADERS(
[cassert cerrno cstddef cctype iostream stdexcept memory],
[], [AC_MSG_ERROR([missing some required standard C++ headers...])])
# Check for thread local storage...
AX_VAR_PUSHVALUE([CXXFLAGS],[""])
AX_TLS([], [AC_MSG_ERROR([thread local storage is not available on your compiler...])])
AX_VAR_POPVALUE([CXXFLAGS])
# POSIX headers for all sub-projects...
AC_LANG_PUSH([C])
AC_CHECK_HEADERS([getopt.h unistd.h], [],
[AC_MSG_ERROR([missing a required POSIX header...])])
AC_LANG_POP([C])
# Locates pkg-config tool on system, checks compatibility, verifies sane...
PKG_PROG_PKG_CONFIG([0.25])
# Bash completion requested...
if test "x${enable_bash_completion}" = xyes; then
# Initialize path for bash completion scripts to be installed to...
bash_completiondir=$sysconfdir/bash_completion.d
AC_SUBST(bash_completiondir)
fi
# Check for headers and libraries...
# Gtk+ C++ headers and libraries...
PKG_CHECK_MODULES(
[libgtkmm], [gtkmm-3.0 >= 3.22.0], [],
[AC_MSG_ERROR([gtkmm-3.0 >= 3.22.0 not found...])])
CXXFLAGS="$CXXFLAGS $libgtkmm_CFLAGS"
LIBS="$LIBS $libgtkmm_LIBS"
# GtkSourceView C++ headers and libraries...
PKG_CHECK_MODULES(
[libgtksourceviewmm], [gtksourceviewmm-3.0 >= 3.21.3], [],
[AC_MSG_ERROR([gtksourceviewmm-3.0 >= 3.21.3 not found...])])
CXXFLAGS="$CXXFLAGS $libgtksourceviewmm_CFLAGS"
LIBS="$LIBS $libgtksourceviewmm_LIBS"
# libcanberra Gtk+ 3.0 headers and libraries...
PKG_CHECK_MODULES(
[libcanberra_gtk3], [libcanberra-gtk3 >= 0.30], [],
[AC_MSG_ERROR([libcanberra-gtk3 >= 0.30 not found...])])
CXXFLAGS="$CXXFLAGS $libcanberra_gtk3_CFLAGS"
LIBS="$LIBS $libcanberra_gtk3_LIBS"
# OpenCL dispatch library (loader) acts as a proxy to the actual vendor
# implementation. The dispatch library is what we link to, but the actual
# vendor implementation (ICD), or Installable Client Driver, comes in the
# form of...
#
# [Package] [Maintainer] [Hardware] [License]
#
# amd-opencl-icd AMD AMD non-free
# beignet-opencl-icd fd.o Intel free
# mesa-opencl-icd Mesa AMD / Radeon free
# nvidia-opencl-icd nVidia nVidia non-free
# pocl-opencl-icd pocl Software based free
#
# First try to find loader via pkg-config...
PKG_CHECK_MODULES(
[libOpenCL], [OpenCL >= 2.1],
# Found it...
[
# Save compiler and linker flags...
CXXFLAGS="$CXXFLAGS $libOpenCL_CFLAGS"
LIBS="$LIBS $libOpenCL_LIBS"
],
# Didn't find it...
[
# Notify user...
AC_MSG_NOTICE([OpenCL dispatch library detected via pkg-config, attempting manual fallback...])
# Try compiling and linking against any available OpenCL library
# installed on the system. Then try dynamically loading an
# expecting function. If successful store compiler and linker
# flags...
AC_CHECK_LIB(
[OpenCL], [clGetPlatformInfo],
[],
[AC_MSG_ERROR([missing OpenCL dispatch library or no clGetPlatformfInfo function found...])])
])
# OpenCL C++ headers...
AC_CHECK_HEADERS(
[CL/cl2.hpp],
[], [AC_MSG_ERROR([missing OpenCL 2.0 header...])])
# YAML C++ headers and libraries...
PKG_CHECK_MODULES(
[libyaml_cpp], [yaml-cpp >= 0.5.2], [],
[AC_MSG_ERROR([yaml-cpp >= 0.5.2 not found...])])
CXXFLAGS="$CXXFLAGS $libyaml_cpp_CFLAGS"
LIBS="$LIBS $libyaml_cpp_LIBS"
# Checks for typedefs, structures, and compiler characteristics...
# Endianness...
AC_C_BIGENDIAN
# Signedness of char...
AC_C_CHAR_UNSIGNED
# Fixed width primitives...
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
# Other basic types...
AC_TYPE_SIZE_T
# Checks for individual functions within libraries...
# POSIX, Standard C, GNU C library extensions...
AC_CHECK_FUNCS([clock getenv getopt_long realpath sigaction], [],
[AC_MSG_ERROR([missing some POSIX, standard C, or GNU C library functions...])])
# Set additional compilation flags...
# Enable all warnings and treat them as errors...
CXXFLAGS="$CXXFLAGS -Wall -Werror -Wshadow -Wextra"
# Generate makefiles from templates containing Autoconf substitution variables
# for root makefile...
AC_CONFIG_FILES([ \
Makefile \
Tests/Makefile \
Translations/Makefile.in])
# Generates config.status which generates all files from templates...
AC_OUTPUT
# Show a user summary of the configuration...
echo \
"-----------------------------------------------------
${PACKAGE_NAME} ${PACKAGE_VERSION}
$copyright_notice
Prefix........................: $prefix
Optional package features:
Update caches.............: $enable_caches
Bash completion...........: $enable_bash_completion
Native language support...: $USE_NLS
Valgrind unit test........: $enable_valgrind
Compiler......................: $CXX
Linker........................: $LD
C++ Flags.....................: $CFLAGS $CXXFLAGS
C++ Preprocessor..............: $CPPFLAGS
Linker Flags..................: $LDFLAGS
Linker Libs...................: $LIBS
Now type 'make @<:@<target>@:>@' where the optional
<target> is:
all ...builds all products (default)
check ...perform all self diagnostics
clean ...clean the build
dist ...builds redistributable archive
distcheck ...self diagnostics on previous
install ...install to $prefix
-----------------------------------------------------"