-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathconfigure.ac
More file actions
754 lines (642 loc) · 23 KB
/
Copy pathconfigure.ac
File metadata and controls
754 lines (642 loc) · 23 KB
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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
# -*- Autoconf -*-
# Run autoheader and autoconf to produce a header and configure script from
# this file.
AC_PREREQ([2.71])
AC_INIT([Asymptote],[3.15git],[https://github.com/vectorgraphics/asymptote/issues])
VERSION=$PACKAGE_VERSION
AC_SUBST(VERSION)
m4_include([ax_pthread.m4])
m4_include([pkg.m4])
AH_TOP([#pragma once])
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
MACOS_UNIVERSAL=no
MACOS_BUNDLING=no
MACOS_MIN_VERSION=
IS_DARWIN=no
case "$host_os" in
darwin*)
IS_DARWIN=yes
MACOS_MIN_VERSION=12.0
;;
esac
AC_ARG_ENABLE(macos-universal,
[AS_HELP_STRING(--enable-macos-universal[[[=no]]],build universal (x86_64+arm64) binaries on macOS)],
[ if test "x$IS_DARWIN" = "xyes"; then
if test "x$enableval" = "xno" ; then
MACOS_UNIVERSAL=no
else
MACOS_UNIVERSAL=yes
fi
fi
])
AC_ARG_WITH(macos-min-version,
[AS_HELP_STRING(--with-macos-min-version=VERSION,minimum macOS deployment target (default: 12.0 on macOS))],
[ if test "x$IS_DARWIN" = "xyes"; then
MACOS_MIN_VERSION=$withval
fi
])
AC_ARG_ENABLE(macos-bundling,
[AS_HELP_STRING(--enable-macos-bundling[[[=no]]],bundle macOS-specific libraries (e.g., Vulkan) for distribution)],
[ if test "x$IS_DARWIN" = "xyes"; then
MACOS_BUNDLING=$enableval
fi
])
test "$prefix" = NONE && prefix=/usr/local
Datadir=$datadir
test "$Datadir" = '${datarootdir}' && Datadir=$datarootdir
test "$Datadir" = '${prefix}/share' && Datadir=$prefix/share
AC_SUBST(Datadir)
AC_ARG_ENABLE(lsp,
[AS_HELP_STRING(--enable-lsp[[[=yes]]],enable Language Server Protocol)])
cxxstd="c++17"
CXXFLAGS=$CXXFLAGS" -std=$cxxstd"
test "$CFLAGS" || CFLAGS="-g -O3"
# macOS portability flags are applied only during the actual build, NOT during
# configure feature-detection tests. Injecting -arch into CFLAGS at configure
# time would cause AC_CHECK_LIB tests to require universal libraries, which
# breaks detection of arm64-only or x86_64-only SDK installations.
#
# Instead we emit MACOS_ARCH_FLAGS and MACOS_DEPLOYMENT_FLAGS as standalone
# Makefile variables that are appended to OPTS and the linker invocations.
MACOS_ARCH_FLAGS=
MACOS_DEPLOYMENT_FLAGS=
if test "x$IS_DARWIN" = "xyes"; then
if test "x$MACOS_UNIVERSAL" = "xyes"; then
MACOS_ARCH_FLAGS="-arch x86_64 -arch arm64"
AC_MSG_NOTICE([macOS universal build enabled (x86_64 and arm64)])
fi
if test "x$MACOS_MIN_VERSION" != "x"; then
MACOS_DEPLOYMENT_FLAGS="-mmacosx-version-min=$MACOS_MIN_VERSION"
AC_MSG_NOTICE([macOS deployment target set to $MACOS_MIN_VERSION])
fi
fi
AC_C_BIGENDIAN(
[AC_DEFINE(WORDS_BIGENDIAN,1,[Build is big endian])],
[],
[],
[AC_DEFINE(UNIVERSAL_ENDIAN_BUILD,1,[Endianness is determined at compile time])]
)
echo Compiling with $CXXFLAGS $CFLAGS
AC_ARG_WITH(latex,
[AS_HELP_STRING(--with-latex=PATH,
specify path to LaTeX installation)],
[if test "x$withval" != "x" ; then
latexdir=$withval
fi
],[
AC_CHECK_PROG(kpsewhich,kpsewhich,true)
if test "x$kpsewhich" = "xtrue"; then
latexdir=`kpsewhich -expand-var='$TEXMFLOCAL'/tex/latex`
else
latexdir=$prefix/share/texmf/tex/latex
AC_CHECK_FILE($latexdir/base/latex.ltx,,
[latexdir=/usr/share/texmf/tex/latex
AC_CHECK_FILE($latexdir/base/latex.ltx,,)])
fi
])
AC_ARG_WITH(context,
[AS_HELP_STRING(--with-context=PATH,
specify path to ConTeXt installation)],
[if test "x$withval" != "x" ; then
contextdir=$withval
fi
],[
AC_CHECK_PROG(kpsewhich,kpsewhich,true)
if test "x$kpsewhich" = "xtrue"; then
contextdir=`kpsewhich -expand-var='$TEXMFLOCAL'/tex/context/third`
else
contextdir=$prefix/share/texmf/tex/context/third
fi
])
AC_CHECK_PROGS(TEXI2ANY,[texi2any makeinfo])
if test -z "$TEXI2ANY"; then
AC_MSG_NOTICE([*** Could not find texi2any: will compile \
without documentation support ***])
fi
AC_SUBST(TEXI2ANY)
latexdir=$latexdir/asymptote
contextdir=$contextdir/asymptote
AC_MSG_NOTICE([Using $latexdir for LaTeX style file])
AC_MSG_NOTICE([Using $contextdir for ConTeXT style file])
AC_SUBST(latexdir)
AC_SUBST(contextdir)
docdir=$Datadir/doc/asymptote
AC_ARG_WITH(docdir,
[AS_HELP_STRING(--with-docdir=PATH,
alternate documentation installation directory)],
[if test "x$withval" != "x" ; then
docdir=$withval
fi
])
AC_SUBST(docdir)
licensedir=$docdir/licenses
AC_ARG_WITH(licensedir,
[AS_HELP_STRING(--with-licensedir=PATH,
alternate license files installation directory)],
[if test "x$withval" != "x" ; then
licensedir=$withval
fi
])
AC_SUBST(licensedir)
sysdir=$Datadir/asymptote
DEFS=""
OPTIONS="-D_FILE_OFFSET_BITS=64 "
INCL=""
LIBS=""
CPPFLAGS=$CPPFLAGS" -I. "
AC_ARG_ENABLE(texlive-build,
[AS_HELP_STRING(--enable-texlive-build[[[=no]]],
automatically determine sysdir from kpsewhich)],
[ if test "x$enableval" = "xyes" ; then
sysdir=""
fi
])
AC_ARG_ENABLE(relocatable,
[AS_HELP_STRING(--enable-relocatable[[[=no]]],
leave ASYMPTOTE_SYSDIR empty so the binary finds its data directory
relative to its own location at runtime (for portable/staged macOS installs))],
[ if test "x$enableval" = "xyes" ; then
OPTIONS=$OPTIONS"-DIS_RELOCATABLE "
fi
])
AC_DEFINE_UNQUOTED(ASYMPTOTE_SYSDIR,"$sysdir",
[System directory for global .asy files])
AC_DEFINE_UNQUOTED(ASYMPTOTE_DOCDIR,"$docdir",
[Directory for documentation])
AC_DEFINE_UNQUOTED(ASYMPTOTE_LICENSEDIR,"$licensedir",
[Directory for license files])
AC_CONFIG_SRCDIR([absyn.cc])
AC_LANG([C++])
# Checks for programs.
AC_PROG_LEX(noyywrap)
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_MAKE_SET
AC_ARG_VAR([BISON], [bison command])
AC_CHECK_PROG([BISON], [bison -y], [yes], [no])
AS_IF([test "x$BISON" = "xno"], [AC_MSG_ERROR([bison not found])])
AC_ARG_VAR([FLEX], [flex command])
AC_CHECK_PROG([FLEX], [flex -y], [yes], [no])
AS_IF([test "x$FLEX" = "xno"], [AC_MSG_ERROR([flex not found])])
if test "$GXX" = yes ; then
ac_gcc_version=`echo __GNUC__ | $CC -E - | grep -v ^\#`
ac_clang=`echo __clang__ | $CC -E - | grep -v ^\#`
if test "$ac_gcc_version" -lt 4; then
CFLAGS=$CFLAGS" -finline-limit=400"
else
if test "$ac_clang" != 1; then
CFLAGS=$CFLAGS" -fno-var-tracking"
fi
fi
fi
AC_DEFUN([DEFINE],[
Define to 1 if you have `$1`.
])
AC_DEFUN([DEFINE_LIB],[
Define to 1 if you have the `$1` library (-l$1).
])
ASYGLVERSION=1.03
# Checks for libraries.
#AC_SEARCH_LIBS([lgamma],[m c],,
#AC_MSG_ERROR([*** Please install libm on your system ***]))
# ----------------- zlib ----------------------------
AC_CHECK_LIB(
[z],
[deflate],
,
AC_MSG_ERROR([*** Please install libz or zlib-devel on your system ***])
)
AC_DEFINE(HAVE_ZLIB,1,[ZLib library present])
# -------------- threads -------------------
GCOPTIONS="--disable-shared --disable-dependency-tracking --enable-large-config"
AC_ARG_ENABLE(
threads,
[AS_HELP_STRING(--enable-threads[[[=yes]]],enable POSIX threads)]
)
if test "x$enable_threads" != "xno"; then
AX_PTHREAD
else
GCOPTIONS=$GCOPTIONS"--disable-threads "
fi
# --------------- sigsegv ------------------------------
AC_ARG_ENABLE(sigsegv,
[AS_HELP_STRING(--enable-sigsegv[[[=yes]]],enable GNU Stack Overflow Handler)])
if test "x$enable_sigsegv" != "xno"; then
AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler])
fi
AC_CHECK_LIB([rt], [sched_yield])
# ----------------- lsp -------------------------------
LSP_ROOT=LspCpp
AC_SUBST(LSP_ROOT)
LSPLIBS=
LSPLIB=
if test "x$enable_lsp" != "xno" -a "x$enable_threads" != "xno"; then
LSPLIB=$LSP_ROOT/liblspcpp.a
LSPLIBS=$LSPLIBS" -L$LSP_ROOT/build -L$LSP_ROOT/build/third_party/uri/src -llspcpp -lnetwork-uri"
LSP_CMAKE_OPTIONS="-DLSPCPP_USE_CPP17=ON "
if test "x$enable_gc" != "xno"; then
LSP_CMAKE_OPTIONS=$LSP_CMAKE_OPTIONS"-DLSPCPP_SUPPORT_BOEHM_GC=ON "
LSP_CMAKE_OPTIONS=$LSP_CMAKE_OPTIONS"-DLSPCPP_GC_DOWNLOADED_ROOT=../\$(GC) "
else
LSP_CMAKE_OPTIONS=$LSP_CMAKE_OPTIONS"-DLSPCPP_SUPPORT_BOEHM_GC=OFF "
fi
AC_DEFUN([ENABLE_LSP_MACRO],
AC_SUBST(LSP_CXX_BUILD_FLAGS)
AC_SUBST(LSP_CMAKE_OPTIONS)
AC_DEFINE(HAVE_LSP,1,DEFINE([Language server protocol]))
)
ENABLE_LSP_MACRO
fi
AC_ARG_ENABLE(readline,
[AS_HELP_STRING(--enable-readline[[[=yes]]],enable GNU Readline Library)])
AC_ARG_ENABLE(static,
[AS_HELP_STRING(--enable-static[[[=no]]],link against static libraries)])
AC_DEFUN([PKG_CONFIG],[
ifdef(
[PKG_CHECK_MODULES],
$1="$2 "$(pkg-config --silence-errors $3 $4 2>/dev/null || echo),
$1="$2 "
)
])
STATIC=""
DYNAMIC=""
if test "x$enable_static" = "xyes"; then
STATIC="-Wl,-Bstatic "
DYNAMIC="-Wl,-Bdynamic "
fi
AC_DEFUN([CHECK_LIB_STATIC],[
PKG_CONFIG(PKG_FLAGS,,--libs,$1)
if test "x$PKG_FLAGS" == "x "; then
PKG_FLAGS=-l"$2"
echo will try linking with $PKG_FLAGS
fi
LDFLAGS_SAVE=$LDFLAGS
LDFLAGS="$LDFLAGS "$STATIC"$PKG_FLAGS "$DYNAMIC
AC_MSG_NOTICE([Checking $2 for function $3... PKG_FLAGS:$PKG_FLAGS])
AC_CHECK_LIB(
$2,$3,
AC_DEFINE($4,1,DEFINE_LIB($2)),
if test "x$enable_static" = "xyes"; then
[
echo "Static library not found; will check for dynamic version"
LDFLAGS="$LDFLAGS_SAVE ""$PKG_FLAGS "
AS_UNSET([ac_cv_lib_$2_$3])
AC_CHECK_LIB(
$2,$3,
AC_DEFINE($4,1,DEFINE_LIB($2)),
[
LDFLAGS=$LDFLAGS_SAVE
$5
],
$PKG_FLAGS
)
]
else
[
LDFLAGS=$LDFLAGS_SAVE
$5
]
fi,
$PKG_FLAGS
)
])
if test "x$enable_readline" != "xno"; then
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,readline)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include <stdio.h>
#include <unistd.h>
#include <readline/readline.h>
],[
#ifndef RL_READLINE_VERSION
abort
#endif
])],
CHECK_LIB_STATIC(readline,readline,history_list,HAVE_LIBREADLINE,
readline="no"),readline="no")
if test "x$readline" == "xno"; then
AC_MSG_NOTICE([*** Could not find GNU readline 4.3 or later: will compile without readline support ***])
AC_CHECK_LIB([edit],[readline])
AC_CHECK_HEADERS(editline/readline.h)
fi
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,tinfo)
CHECK_LIB_STATIC(tinfo,tinfo,tgetent,HAVE_LIBTINFO,AC_MSG_NOTICE([perhaps tgetent is in -lncurses]))
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,ncurses)
AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],[break])
CHECK_LIB_STATIC(ncurses,ncurses,setupterm,HAVE_LIBCURSES,
AC_CHECK_LIB(curses,setupterm))
fi
# --------------- gc -------------------------------
GCNAME="Boehm Garbage Collector"
AC_ARG_ENABLE(gc,
[AS_HELP_STRING(--enable-gc[[[=yes]]],enable local $GCNAME)])
if test "x$enable_gc" != "xno" ; then
AC_DEFINE(USEGC,1,[GC Enabled])
GCLIB="\$(GC)/.libs/libgc.a"
INCL=$INCL"-I\$(GC)/include "
AC_MSG_NOTICE([$GCNAME is enabled])
else
AC_MSG_NOTICE([*** $GCNAME disabled by configure flag: will compile without garbage collection. ***])
fi
AC_ARG_ENABLE(gc-debug,
[AS_HELP_STRING(--enable-gc-debug[[[=no]]],enable (slow) garbage collector debugging)],
[ if test "x$enable_gc" != "xno" ; then
if test "x$enableval" = "xyes" ; then
AC_DEFINE(GC_DEBUG,1,[GC Debug is enabled])
AC_MSG_NOTICE([*** Enabling GC debugging: remember to make clean ***])
AC_MSG_NOTICE([*** Set the environment variable GC_FIND_LEAK at runtime ***])
fi
fi
])
AC_ARG_ENABLE(gc-full-debug,
[AS_HELP_STRING(--enable-gc-full-debug[[[=no]]],enable (very slow) garbage collector backtrace)],
[ if test "x$enable_gc" != "xno" ; then
if test "x$enableval" = "xyes" ; then
AC_DEFINE(GC_DEBUG,1,[GC Debug is enabled])
AC_DEFINE(GC_BACKTRACE,1,[GC backtrace is enabled])
GCOPTIONS=$GCOPTIONS"--enable-gc-debug "
AC_MSG_NOTICE([*** Enabling GC backtrace debugging; remember to make gc-clean ***])
fi
fi
])
# ---------------- curl ------------------------
AC_ARG_ENABLE(curl,
[AS_HELP_STRING(--enable-curl[[[=yes]]],enable libcurl and compile with optional URL support)])
if test "x$enable_curl" != "xno"; then
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,curl)
AC_CHECK_HEADER(curl/curl.h,
CHECK_LIB_STATIC(libcurl,curl,curl_easy_init,HAVE_LIBCURL,
AC_MSG_NOTICE([*** Could not find libcurl: will compile without optional URL support. ***])),
AC_MSG_NOTICE([*** Header file curl.h not found: will compile without optional URL support. ***]))
else
AC_MSG_NOTICE([*** libcurl support disabled by configure flag: will compile without optional URL support. ***])
fi
# --------------------- fftw -------------------------
AC_ARG_ENABLE(fftw,
[AS_HELP_STRING(--enable-fftw[[[=yes]]],enable FFTW Library)])
if test "x$enable_fftw" != "xno"; then
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,fftw3)
AC_CHECK_HEADER(fftw3.h,
CHECK_LIB_STATIC(fftw3,fftw3,fftw_execute,HAVE_LIBFFTW3,
AC_MSG_NOTICE([*** Could not find libfftw3: will compile without optional fast Fourier transforms. ***])),
AC_MSG_NOTICE([*** Header file fftw3.h not found: will compile without optional fast Fourier transforms. ***]))
fi
# ------------------- eigen -------------------------
AC_ARG_ENABLE(eigen,
[AS_HELP_STRING(--enable-eigen[[[=yes]]],enable Eigen Library)])
if test "x$enable_eigen" != "xno"; then
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,eigen3)
AC_CHECK_HEADERS(Eigen/Dense)
fi
# Checks for header files.
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fenv.h stddef.h libintl.h])
AC_CHECK_HEADERS(fpu_control.h)
AC_CHECK_FUNCS([feenableexcept])
# ------------------- GSL --------------------
AC_ARG_ENABLE(gsl,
[AS_HELP_STRING(--enable-gsl[[[=yes]]],enable GNU Scientific Library)])
if test "x$enable_gsl" != "xno"; then
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,gsl)
AC_CHECK_HEADER(gsl/gsl_sf.h,
CHECK_LIB_STATIC(gsl,gsl,gsl_sf_debye_6,HAVE_LIBGSL,
AC_MSG_NOTICE([*** Could not find libgsl: will compile without optional special functions. ***])),
AC_MSG_NOTICE([*** Header file gsl_sf.h not found: will compile without optional special functions. ***]))
fi
# ----------- glm
# glm is header only and is already on the include path
AC_CHECK_HEADER(
glm/glm.hpp,
[AC_DEFINE(
HAVE_LIBGLM,1,
DEFINE([the <glm/glm.hpp> header]))
],
AC_MSG_NOTICE([*** Could not find glm header files: will compile without WebGL or OpenGL/Vulkan support ***])
)
TINYEXR_ROOT=tinyexr
INCL=$INCL" -I$TINYEXR_ROOT"
AC_SUBST(TINYEXR_ROOT)
# ------------------- GLFW -----------------
if test "x$enable_vulkan" != "xno" -o "x$enable_gl" != "xno"; then
AC_CHECK_LIB([glfw], [glfwShowWindow],
[AC_DEFINE(HAVE_LIBGLFW,1,DEFINE_LIB([GLFW]))
LIBS=$LIBS"-lglfw "],
AC_MSG_NOTICE([*** Could not find libglfw: will compile without Vulkan or OpenGL support ***]))
fi
# ------------------- Vulkan -----------------
AC_ARG_ENABLE(vulkan,
[AS_HELP_STRING(--enable-vulkan[[[=yes]]],enable Vulkan Library)])
VMA_REPO_ROOT=VulkanMemoryAllocator
VMA_IMPL_FILES=""
if test "x$enable_vulkan" != "xno"; then
INCL=" -I$VMA_REPO_ROOT/include "$INCL" -Ithirdparty_impl/vk-mem-allocator_impl/include "
VMA_IMPL_FILES=$VMA_IMPL_FILES" vma_cxx vma_impl"
ASY_VULKAN_LIBS=""
AC_CHECK_HEADERS([ncurses/curses.h ncurses.h curses.h],[break])
dnl Check for vulkan/vulkan.hpp and VK_API_VERSION_1_4 using a C++ compile test.
dnl On some distros (e.g., Ubuntu with LunarG libvulkan-dev) the C++ header
dnl may be missing, or the headers may be too old to support Vulkan 1.4.
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <vulkan/vulkan.hpp>]],
[[(void)(uintptr_t)VK_API_VERSION_1_4;]])],
[have_vulkan_hpp=yes],
[have_vulkan_hpp=no]
)
AC_LANG_POP([C++])
case "$OSTYPE" in
*)
if test "x$have_vulkan_hpp" != "xyes"; then
AC_MSG_NOTICE([*** Could not find vulkan/vulkan.hpp with VK_API_VERSION_1_4: will compile without Vulkan support ***])
else
AC_CHECK_LIB([gccpp],[GC_throw_bad_alloc])
AC_CHECK_LIB([vulkan], [vkCreateInstance],
[
LIBS_SAVE=$LIBS
case "$OSTYPE" in
darwin*)
VULKAN_LIBS=""
;;
*)
VULKAN_LIBS="-lMachineIndependent -lOSDependent -lGenericCodeGen "
;;
esac
ASY_VULKAN_LIBS="-lvulkan $VULKAN_LIBS-lSPIRV"
dnl On some distros (e.g., Ubuntu) libglslang.a is a thin C wrapper and
dnl the actual C++ implementation is in companion libraries. Try -lglslang
dnl alone first; if that fails, try with companions.
ASY_GLSLANG_LIBS=""
LIBS_SAVE=$LIBS
LIBS="$LIBS -lglslang"
AC_LINK_IFELSE(
[AC_LANG_CALL([], [glslang_initialize_process])],
[ASY_GLSLANG_LIBS="-lglslang"],
[]
)
dnl If -lglslang alone didn't work, try with companion libraries
if test "x$ASY_GLSLANG_LIBS" = "x"; then
LIBS="$LIBS_SAVE -lglslang $VULKAN_LIBS -lOGLCompiler"
AC_LINK_IFELSE(
[AC_LANG_CALL([], [glslang_initialize_process])],
[ASY_GLSLANG_LIBS="-lglslang $VULKAN_LIBS -lOGLCompiler"],
[]
)
fi
LIBS=$LIBS_SAVE
if test "x$ASY_GLSLANG_LIBS" != "x"; then
AC_DEFINE(HAVE_LIBVULKAN,1,
DEFINE_LIB([vulkan]))
ASY_VULKAN_LIBS="$ASY_VULKAN_LIBS $ASY_GLSLANG_LIBS -lSPIRV-Tools-opt -lSPIRV-Tools"
else
AC_MSG_NOTICE([*** Could not find libglslang: will compile without Vulkan support ***])
ASY_VULKAN_LIBS=""
LIBS=$LIBS_SAVE
fi
],
AC_MSG_NOTICE([*** Could not find libvulkan: will compile without Vulkan support ***]))
fi
esac
fi
# Check if Vulkan libraries should be bundled (macOS only).
# Bundling requires --enable-macos-bundling AND Vulkan libraries to be present.
# Use $host_os (from AC_CANONICAL_HOST) rather than $OSTYPE, which is a
# bash-ism that may be empty when configure runs as /bin/sh.
# Check ASY_VULKAN_LIBS rather than $LIBS: CHECK_LIB_STATIC appends -lvulkan
# to $LDFLAGS, not $LIBS, so $LIBS never contains -lvulkan.
BUNDLE_VULKAN=no
case "$host_os" in
darwin*)
if test "x$MACOS_BUNDLING" = "xyes" -a "x$ASY_VULKAN_LIBS" != "x"; then
BUNDLE_VULKAN=yes
AC_MSG_NOTICE([Will bundle Vulkan libraries for macOS distribution])
fi
;;
esac
AC_SUBST(BUNDLE_VULKAN)
# ------------------- OpenGL (fallback) -----------------
AC_ARG_ENABLE(gl,
[AS_HELP_STRING(--enable-gl[[[=yes]]],enable OpenGL Library)])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include <GL/gl.h>]
[#if !defined(GL_VERSION_4_3) && !defined(GL_ARB_shader_storage_buffer_object)]
[#error]
[#endif ]
)],
AC_DEFINE(HAVE_SSBO,1,DEFINE([GLSL shader storage buffer objects])))
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include <GL/gl.h>]
[#if !defined(GL_VERSION_4_3) && !defined(GL_ARB_compute_shader)]
[#error]
[#endif ]
)],
AC_DEFINE(HAVE_COMPUTE_SHADER,1,DEFINE([GLSL compute shaders])))
ASY_GL_LIBS=""
SHIM_LDFLAGS=""
if test "x$enable_gl" != "xno"; then
AC_CHECK_HEADERS([ncurses/curses.h ncurses.h curses.h],[break])
case "$OSTYPE" in
darwin*)
# On macOS 11+, -undefined dynamic_lookup is incompatible with
# chained fixups. Add -no_fixup_chains to use traditional fixups
# which work correctly with dynamic_lookup for dlopen'd libraries.
SHIM_LDFLAGS="-undefined dynamic_lookup -Wl,-no_fixup_chains"
AC_CHECK_LIB([gccpp],[GC_throw_bad_alloc])
AC_CHECK_HEADER(OpenGL/gl.h,
[AC_DEFINE(HAVE_LIBGL,1,
DEFINE([<gl.h> header]))
ASY_GL_LIBS="-framework OpenGL -framework Cocoa "
INCL=$INCL" -Ibackports/glew/include"
GLEW="glew.o "],
AC_MSG_NOTICE([*** Could not find OpenGL: will compile without OpenGL support ***]))
;;
*)
# Use AC_LINK_IFELSE instead of AC_CHECK_LIB to avoid adding -lGL to LIBS.
# The OpenGL library will only be linked into libasyopengl.so, not the main binary.
LIBS_SAVE=$LIBS
LIBS="$LIBS -lGL"
AC_LINK_IFELSE([AC_LANG_CALL([], [glDepthMask])],
[AC_DEFINE(HAVE_LIBGL,1,
DEFINE_LIB([GL]))
ASY_GL_LIBS="-lGL "
GLEW="glew.o "
INCL=$INCL" -Ibackports/glew/include"],
AC_MSG_NOTICE([*** Could not find libGL: will compile without OpenGL support ***]))
LIBS=$LIBS_SAVE
esac
fi
# ----------------- xdr ------------------------
AC_ARG_ENABLE(xdr,
[AS_HELP_STRING(--enable-xdr[[[=yes]]],enable XDR/V3D support)])
if test "x$enable_xdr" != "xno"; then
case "$OSTYPE" in
darwin* | FreeBSD)
AC_DEFINE(HAVE_LIBTIRPC,1,DEFINE_LIB([tirpc]))
;;
*)
PKG_CONFIG(CPPFLAGS,$CPPFLAGS,--cflags,libtirpc)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include "xstream.h"])],
CHECK_LIB_STATIC(libtirpc,tirpc,xdrstdio_create,
HAVE_LIBTIRPC,
AC_MSG_NOTICE([*** Could not find libtirpc; XDR/V3D support disabled ***])
),
AC_MSG_NOTICE([*** Broken rpc headers; XDR/V3D support disabled ***])
)
;;
esac
fi
CPPFLAGS=$CPPFLAGS" $INCL"
CXX_STANDARD=$cxxstd
AC_SUBST(ASYGLVERSION)
AC_SUBST(GCOPTIONS)
AC_SUBST(GCLIB)
AC_SUBST(GCPPLIB)
AC_SUBST(LSPLIB)
AC_SUBST(LSPLIBS)
AC_SUBST(INCL)
AC_SUBST(CXX_STANDARD)
AC_SUBST(DEFS)
AC_SUBST(OPTIONS)
AC_SUBST(GLEW)
AC_SUBST(VMA_IMPL_FILES)
AC_SUBST(ASY_VULKAN_LIBS)
AC_SUBST(ASY_GL_LIBS)
AC_SUBST(SHIM_LDFLAGS)
AC_SUBST(MACOS_UNIVERSAL)
AC_SUBST(MACOS_MIN_VERSION)
AC_SUBST(MACOS_ARCH_FLAGS)
AC_SUBST(MACOS_DEPLOYMENT_FLAGS)
# Determine which shim shared libraries (loaded via dlopen at runtime) to
# build and link the asy binary against. Empty when both renderers are
# disabled so the main binary does not depend on libglfw, libGL, or libvulkan.
SHIMLIBS=""
if test "x$enable_vulkan" != "xno"; then
SHIMLIBS="$SHIMLIBS libasyvulkan.so"
fi
if test "x$enable_gl" != "xno"; then
SHIMLIBS="$SHIMLIBS libasyopengl.so"
fi
AC_SUBST(SHIMLIBS)
# we are on C++ >= 11, so unordered map is a guarantee
AC_DEFINE(HAVE_UNORDERED_MAP,1,[Unordered map is present])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_TYPES([long long])
AC_CHECK_TYPES([long])
AC_C_CONST
AC_C_INLINE
# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS([dup2 floor memset strchr tgamma lgamma memrchr popcount])
AC_FUNC_STRFTIME
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(strptime)
AC_CHECK_FUNCS(strnlen)
AC_CONFIG_FILES([Makefile doc/Makefile doc/png/Makefile doc/FAQ/Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT