forked from sile-typesetter/sile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
318 lines (274 loc) · 11.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
AC_PREREQ([2.69])
AC_INIT([sile], [m4_esyscmd(build-aux/git-version-gen .tarball-version)], [[email protected]])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign tar-pax dist-zstd dist-zip no-dist-gzip color-tests subdir-objects])
AM_SILENT_RULES([yes])
# Load up re-usable m4 bits shared across Caleb's projects
QUE_GIT_VERSION
QUE_TRANSFORM_PACKAGE_NAME
QUE_DEVELOPER_MODE
QUE_DIST_CHECKSUMS
# Extend the QUE checksums feature with support for the PDF manual
SILE_DIST_CHECKSUMS
# Check for and set variables for tooling used during our build process
AC_PROG_AWK
AC_PROG_CC
AC_PROG_GREP
AC_PROG_OBJC
AC_PROG_SED
QUE_PROGVAR([cmp])
QUE_PROGVAR([diff])
QUE_PROGVAR([find])
QUE_PROGVAR([head])
QUE_PROGVAR([jq])
QUE_PROGVAR([luarocks])
QUE_PROGVAR([pdfinfo])
QUE_PROGVAR([sort])
QUE_PROGVAR([xargs])
# Disable ranlib to avoid it being run on our rusile.so module, already LTO
# optimized but libtool wants to relink it...
RANLIB=:
LT_PREREQ([2.2])
LT_INIT([dlopen])
AC_CANONICAL_HOST
QUE_RUST_BOILERPLATE
QUE_DOCKER_BOILERPLATE
AM_CONDITIONAL([SHARED], [test "x$enable_shared" = "xyes"])
AM_CONDITIONAL([STATIC], [test "x$enable_static" = "xyes"])
AC_ARG_ENABLE([embedded],
AS_HELP_STRING([--enable-embedded-resources],
[Compile resources such as Lua module files directly into the Rust CLI binary]))
AM_CONDITIONAL([EMBEDDED_RESOURCES], [test "x$enable_embedded_resources" = "xyes"])
AC_ARG_ENABLE([font-variations],
AS_HELP_STRING([--disable-font-variations],
[Disable support for OpenType variations and variable fonts that requires HarfBuzz subsetter library]))
AM_CONDITIONAL([FONT_VARIATIONS], [test "x$enable_font_variations" != "xno"])
AC_ARG_ENABLE([linklua],
AS_HELP_STRING([--disable-linklua],
[Don’t link lua library with dylibs]))
AM_CONDITIONAL([LINKLUA], [test "x$enable_linklua" != "xno"])
# TODO: Refactor fontconfig check to allow Appkit/DirectWrite as alternatives, maybe default to off on Darwin
# AC_ARG_WITH([fontconfig],
# AS_HELP_STRING([--without-fontconfig],
# [Compile without fontconfig font manager support]))
AM_CONDITIONAL([FONTCONFIG], [test "x$with_fontconfig" != "xno"])
AC_ARG_WITH([harfbuzz],
AS_HELP_STRING([--without-harfbuzz],
[Compile without HarfBuzz support used as default shaping backend]))
AM_CONDITIONAL([HARFBUZZ], [test "x$with_harfbuzz" != "xno"])
AC_ARG_WITH([system-libtexpdf],
AS_HELP_STRING([--with-system-libtexpdf],
[Don’t bundle libtexpdf, use system provided version]))
AM_CONDITIONAL([SYSTEM_LIBTEXPDF], [test "x$with_system_libtexpdf" = "xyes"])
AC_ARG_WITH([system-luarocks],
AS_HELP_STRING([--with-system-luarocks],
[Don’t bundle LuaRocks, use system provided versions]))
AM_CONDITIONAL([SYSTEM_LUAROCKS], [test "x$with_system_luarocks" = "xyes"])
AC_SUBST([SYSTEM_LUAROCKS])
AC_ARG_WITH([vendored-luarocks-dir],
AS_HELP_STRING([--with-vendored-luarocks-dir=PATH],
[Specify a custom vendored location from which to load ‘system’ luarocks]),
[],
[with_vendored_luarocks_dir=no])
AM_CONDITIONAL([VENDORED_LUAROCKS], [test "x$with_vendored_luarocks_dir" != "xno"])
AC_SUBST([VENDORED_LUAROCKS])
AC_ARG_WITH([system-lua-sources],
AS_HELP_STRING([--with-system-lua-sources],
[Don’t compile against vendored Lua sources, use system headers]))
AM_CONDITIONAL([SYSTEM_LUA_SOURCES], [test "x$with_system_lua_sources" = "xyes"])
AC_SUBST([SYSTEM_LUA_SOURCES])
AC_ARG_WITH([manual],
AS_HELP_STRING([--with-manual],
[Rebuild manual and install to system’s PDF documentation directory]))
AM_CONDITIONAL([MANUAL], [test "x$with_manual" = "xyes"])
AM_CONDITIONAL([FONT_DOWNLOAD_TOOLS], [test -z ${DEVELOPER_MODE_TRUE} || (test -z ${SOURCE_IS_DIST_TRUE} && test -z ${MANUAL_TRUE})])
AC_SUBST([FONT_DOWNLOAD_TOOLS])
AM_COND_IF([MANUAL], [
QUE_PROGVAR([dot])
QUE_PROGVAR([gs])
])
AC_MSG_CHECKING([for OS X])
have_appkit=no
case $host_os in
darwin*)
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for AppKit works])
save_LIBS="$LIBS"
LIBS="$LIBS -framework AppKit -fmodules"
AC_LANG_PUSH([Objective C])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[@import AppKit;]],[[]])],
[
have_appkit=yes
AC_MSG_RESULT([yes])
], [
have_appkit=no
AC_MSG_RESULT([no])
])
AC_LANG_POP([Objective C])
LIBS="$save_LIBS"
;;
*)
AC_MSG_RESULT([no])
;;
esac
AM_CONDITIONAL([APPKIT], [test "x$have_appkit" = "xyes"])
AM_COND_IF([FONTCONFIG],
[PKG_CHECK_MODULES(FONTCONFIG, [fontconfig],
[],
[AC_MSG_FAILURE([Fontconfig package not found])])])
AM_COND_IF([HARFBUZZ],
[PKG_CHECK_MODULES(HARFBUZZ, [harfbuzz >= 2.7.4],
[],
[AC_MSG_FAILURE([--with-harfbuzz was given, but harfbuzz not found])]) ])
AM_COND_IF([FONT_VARIATIONS],
[PKG_CHECK_MODULES(HARFBUZZ_SUBSET, [harfbuzz-subset >= 6.0.0],
[AC_DEFINE(HAVE_HARFBUZZ_SUBSET, [1], [Have harfbuzz-subset library])],
[AC_MSG_FAILURE([--enable-font-variations was given, but harfbuzz version not new enough to include required subset library functions])])])
AM_COND_IF([SYSTEM_LIBTEXPDF],
[AC_CHECK_LIB([texpdf], [texpdf_doc_set_verbose],
[],
[AC_MSG_FAILURE([--with-system-libtexpdf was given, but test for libtexpdf failed])])],
[AC_CONFIG_SUBDIRS([libtexpdf])])
PKG_CHECK_MODULES(ICU, icu-uc icu-i18n icu-io, [
with_icu=yes
],[
AC_CHECK_TOOL(ICU_CONFIG, icu-config, no)
AC_MSG_CHECKING([for ICU by using icu-config fallback])
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; then
ICU_LIBS=`icu-config --ldflags-libsonly --ldflags-icuio`
ICU_CFLAGS=`icu-config --cppflags`
with_icu=yes
AC_MSG_RESULT([yes])
else
AC_MSG_FAILURE([Required ICU library not found])
fi
])
AM_CONDITIONAL([ICU], [test "x$with_icu" = "xyes"])
# Required for downloading fonts for the manual and for tests
# Since the source tarball includes a prebuilt manual we only need this for Git source builds
AM_COND_IF([FONT_DOWNLOAD_TOOLS], [
QUE_PROGVAR([bsdtar])
QUE_PROGVAR([curl])
])
AM_COND_IF([DEVELOPER_MODE], [
AX_WITH_PROG([DELTA], [delta], [cat])
AX_WITH_PROG([PERL], [perl])
])
AM_COND_IF([DEVELOPER_TOOLS], [
QUE_PROGVAR([busted])
QUE_PROGVAR([cargosetversion], [cargo-set-version])
QUE_PROGVAR([curl])
QUE_PROGVAR([ldoc])
QUE_PROGVAR([luacheck])
QUE_PROGVAR([nix])
QUE_PROGVAR([npm])
QUE_PROGVAR([perl])
QUE_PROGVAR([stylua])
QUE_PROGVAR([taplo])
QUE_PROGVAR([tr])
QUE_PROGVAR([typos])
QUE_PROGVAR([xsltproc])
])
AX_PROG_LUA([5.1], [], [], [], [prefer])
AX_LUA_HEADERS
AX_LUA_LIBS
AM_COND_IF([SYSTEM_LUAROCKS], [
AS_IF([test "$LUA_SHORT_VERSION" -lt 52], [
AM_COND_IF([LUAJIT], [], [AX_LUA_MODULE(bit32)])
])
AX_LUA_MODULE(cassowary)
AS_IF([test "$LUA_SHORT_VERSION" -lt 53], [AX_LUA_MODULE(compat53)])
AX_LUA_MODULE(cldr)
AX_LUA_MODULE(fluent)
AX_LUA_MODULE(linenoise)
AX_LUA_MODULE(loadkit)
AX_LUA_MODULE(lpeg)
AX_LUA_MODULE(lua-zlib, zlib)
AX_LUA_MODULE(lua_cliargs, cliargs)
AX_LUA_MODULE(luaepnf, epnf)
AX_LUA_MODULE(luaexpat, lxp)
AX_LUA_MODULE(luafilesystem, lfs)
AX_LUA_MODULE(luafilesystem)
AX_LUA_MODULE(luarepl, repl)
AX_LUA_MODULE(luasec, ssl)
AX_LUA_MODULE(luasocket, socket)
AX_LUA_MODULE(luautf8, lua-utf8)
AX_LUA_MODULE(penlight, pl)
AX_LUA_MODULE(vstruct)
], [
QUE_PROGVAR([git]) # required for luarocks to install zlib rock
])
QUE_FONT(Gentium Plus)
AC_SUBST([APPKIT_TRUE])
AC_SUBST([FONTCONFIG_TRUE])
AC_SUBST([FONT_VARIATIONS_TRUE])
AC_SUBST([HARFBUZZ_TRUE])
AC_SUBST([HARFBUZZ_CFLAGS])
AC_SUBST([HARFBUZZ_LIBS])
AC_SUBST([HARFBUZZ_SUBSET_CFLAGS])
AC_SUBST([HARFBUZZ_SUBSET_LIBS])
AC_SUBST([ICU_TRUE])
AC_SUBST([ICU_CFLAGS])
AC_SUBST([ICU_LIBS])
case $host_os in
darwin*)
LUAROCKSARGS="EXPAT_DIR=/usr/local/opt/expat OPENSSL_DIR=/usr/local/opt/openssl ZLIB_DIR=/usr/local/opt/zlib"
SHARED_LIB_EXT="so"
;;
cygwin*|mingw*)
SHARED_LIB_EXT="dll"
;;
*)
SHARED_LIB_EXT="so"
;;
esac
AC_SUBST([SHARED_LIB_EXT])
AC_SUBST([LUAROCKSARGS])
# Avoid need for `--datarootdir=$(cd ..; pwd)` hack to run locally for
# tests/manual build when developer mode is enabled
AM_COND_IF([DEVELOPER_MODE], [
adl_RECURSIVE_EVAL(["$(pwd)"], [SILE_PATH])
datarootdir="$(cd ..; pwd)"
],[
adl_RECURSIVE_EVAL(["${datadir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_PATH])
])
AC_DEFINE_UNQUOTED([SILE_PATH], ["${SILE_PATH}"], [Path for SILE packages and classes])
AC_SUBST([SILE_PATH])
# In order for our Rust CLI binary to use the same default package.(c)path as the system Lua,
# we test the system Lua (required only at build not run time) for its current package.(c)path.
adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.path)')"], [SYSTEM_LUA_PATH])
adl_RECURSIVE_EVAL(["$(${LUA} -e 'print(package.cpath)')"], [SYSTEM_LUA_CPATH])
AC_DEFINE_UNQUOTED([SYSTEM_LUA_PATH], ["${SYSTEM_LUA_PATH}"],[System Lua package path])
AC_DEFINE_UNQUOTED([SYSTEM_LUA_CPATH], ["${SYSTEM_LUA_CPATH}"], [System Lua package cpath])
AC_SUBST([SYSTEM_LUA_PATH])
AC_SUBST([SYSTEM_LUA_CPATH])
# Accommodate Homebrew and/or other distros that pretend a vendored location is the system.
AM_COND_IF([VENDORED_LUAROCKS],
[VENDORED_LUAROCKS_DIR="$with_vendored_luarocks_dir"])
AC_SUBST([VENDORED_LUAROCKS_DIR])
adl_RECURSIVE_EVAL(["${libdir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_LIB_PATH])
AC_DEFINE_UNQUOTED([SILE_LIB_PATH],["${SILE_LIB_PATH}"], [Path for SILE libraries])
AC_SUBST([SILE_LIB_PATH])
AC_SUBST([ROCKSPECWARNING], ["DO NOT EDIT! Modify template sile.rockspec.in"])
AC_SUBST([ROCKREV], [1])
QUE_SUBST_MAN_DATE
AC_CONFIG_FILES([build-aux/list-distfiles.sh], [chmod +x build-aux/list-distfiles.sh])
AC_CONFIG_FILES([build-aux/import-tex-hyphens.sh], [chmod +x build-aux/import-tex-hyphens.sh])
AC_CONFIG_FILES([build-aux/transpile-tex-hyphen-patterns.lua], [chmod +x build-aux/transpile-tex-hyphen-patterns.lua])
AC_CONFIG_FILES([Makefile justenough/Makefile sile-lua.1 core/features.lua core/pathsetup.lua core/version.lua])
AC_CONFIG_FILES([sile-lua:sile.in], [chmod +x sile-lua])
AC_CONFIG_FILES([tests/regressions.pl], [chmod +x tests/regressions.pl])
AC_CONFIG_FILES([rusile-dev-1.rockspec:rusile.rockspec.in])
AC_CONFIG_FILES([sile-dev-1.rockspec:sile.rockspec.in])
AC_CONFIG_FILES([src/sile-entry.sh], [chmod +x src/sile-entry.sh])
AC_OUTPUT
AC_MSG_NOTICE([monkey-patching configure to ignore core directory])
m4_esyscmd_s([build-aux/decore-automake.sh])
# Avoid the perceived need to run automake again when building from source
# tarballs. The assorted AM include macros assume two passes are needed to
# generate a makefile since one pass has to generate the includes and the
# second one inlines them, but we're distributing a ready-to-use version and
# hence one pass is enough. We can skip ahead and assume the Makefile template
# is ready to go an this point, avoiding the need for autotools at all.
AM_COND_IF([SOURCE_IS_DIST], [touch -r aminclude.am Makefile.in])