summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 0e1435b9ec8166faa161ec5752f6963b52289a17 (plain)
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
#                            -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

# ===================
# Version information
# ===================
m4_define([orcus_major_version], [0])
m4_define([orcus_minor_version], [19])
m4_define([orcus_micro_version], [2])
m4_define([orcus_version], [orcus_major_version.orcus_minor_version.orcus_micro_version])

# ===============
# API information
# ===============
m4_define([orcus_major_api_version], [0])
m4_define([orcus_minor_api_version], [18])
m4_define([orcus_api_version], [orcus_major_version.orcus_minor_api_version])

# =============
# Automake init
# =============
AC_INIT([liborcus],[orcus_version])
AC_CONFIG_MACRO_DIR([m4])
m4_pattern_allow([^BOOST_])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 dist-xz])
AM_SILENT_RULES([yes])
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_17([noext], [mandatory])
CXXFLAGS="-fvisibility=hidden $CXXFLAGS -Wall -pthread -Wshadow"

# ===========================
# Find required base packages
# ===========================
AC_PROG_CPP
AC_PROG_CXX
LT_INIT([win32-dll disable-static pic-only])
AC_PROG_INSTALL
AC_PROG_LN_S
PKG_PROG_PKG_CONFIG([0.20])

# =====================
# Find required headers
# =====================
AC_CHECK_HEADERS([stdlib.h sys/time.h unistd.h])

# ===================================
# Check for filesystem implementation
# ===================================
AC_CHECK_HEADER([filesystem], [have_filesystem=yes], [have_filesystem=no], [])

AC_CHECK_HEADER([experimental/filesystem], [have_experimental_filesystem=yes], [have_experimental_filesystem=no], [])

AM_CONDITIONAL([HAVE_FILESYSTEM], [test "x$have_filesystem" = "xyes"])
AM_CONDITIONAL([HAVE_EXPERIMENTAL_FILESYSTEM], [test "x$have_experimental_filesystem" = "xyes"])

# =============================================================
# Checks for typedefs, structures, and compiler characteristics
# =============================================================
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_SIZE_T

AC_CHECK_SIZEOF([void *])
CXXFLAGS="$CXXFLAGS -DSIZEOF_VOID_P=$ac_cv_sizeof_void_p"

# ============================
# Checks for library functions
# ============================
AC_FUNC_STRTOD
AC_CHECK_FUNCS([gettimeofday])
AC_DEFINE([_REENTRANT], [], [Enable reentrant.])
AC_DEFINE([BOOST_ALL_NO_LIB], [], [Disable boost's evil autolink.])

# ======================
# Set required ixion api
# ======================
IXION_REQUIRED_API_VERSION=0.18
AC_SUBST(IXION_REQUIRED_API_VERSION)

# =============
# Set orcus api
# =============
ORCUS_API_VERSION=orcus_api_version
ORCUS_MAJOR_VERSION=orcus_major_version
ORCUS_MINOR_VERSION=orcus_minor_version
ORCUS_MICRO_VERSION=orcus_micro_version
AC_SUBST(ORCUS_API_VERSION)
AC_SUBST(ORCUS_MAJOR_VERSION)
AC_SUBST(ORCUS_MINOR_VERSION)
AC_SUBST(ORCUS_MICRO_VERSION)

BOOST_REQUIRE([1.36])
BOOST_SYSTEM
AS_IF([test "x$have_filesystem" != "xyes" -a "x$have_experimental_filesystem" != "xyes"], [
    BOOST_FILESYSTEM
])

# =========================================================
# Determine if we are going to build static lib (for MinGW)
# =========================================================
AM_CONDITIONAL([HAVE_STATIC_LIB],
               [test "$enable_shared" = no -a "$enable_static" = yes])

# =====================
# Development Utilities
# =====================
AC_ARG_ENABLE(debug-utils,
        AS_HELP_STRING([--enable-debug-utils], [Build with extra checks useful during development.]),
        [enable_debug_utils="$enableval"],
        [enable_debug_utils=no]
)

# =====
# Debug
# =====
AC_ARG_ENABLE(debug,
        AS_HELP_STRING([--enable-debug], [Build with debug features in mind.]),
        [enable_debug="$enableval"],
        [enable_debug=no]
)
AS_IF([test "x$enable_debug" != "xno"], [
        CXXFLAGS="$CXXFLAGS -g -O0"
        enable_debug_utils=yes
], [
        CXXFLAGS="$CXXFLAGS -O2"
        AC_DEFINE([NDEBUG], [], [Disable debugging information])
])

AS_IF([test "x$enable_debug_utils" != "xno"], [
        CXXFLAGS="$CXXFLAGS -g -D__ORCUS_DEBUG_UTILS -DMDDS_SORTED_STRING_MAP_DEBUG"
])

# zlib is a hard requirement in liborcus-parser.
PKG_CHECK_MODULES([ZLIB], [zlib])

# ==============
# tools (binary)
# ==============
AC_ARG_WITH(tools,
            AS_HELP_STRING([--without-tools],
                           [Disables building of binary executable tools.]),
        [with_tools="$withval"],
        [with_tools=yes]
)

# ==================
# ods filter support
# ==================
AC_ARG_WITH(ods-filter,
            AS_HELP_STRING([--without-ods-filter],
                           [Disables the OpenDocument Format spreadsheet import filter.]),
        [with_ods_filter="$withval"],
        [with_ods_filter=yes]
)

# ===================
# xlsx filter support
# ===================
AC_ARG_WITH(xlsx-filter,
            AS_HELP_STRING([--without-xlsx-filter],
                           [Disables the Microsoft Excel OOXML import filter.]),
        [with_xlsx_filter="$withval"],
        [with_xlsx_filter=yes]
)

# ======================
# xls xml filter support
# ======================
AC_ARG_WITH(xls-xml-filter,
            AS_HELP_STRING([--without-xls-xml-filter],
                           [Disables the Microsoft Excel XML import filter.]),
        [with_xls_xml_filter="$withval"],
        [with_xls_xml_filter=yes]
)

# =======================
# gnumeric filter support
# =======================
AC_ARG_WITH(gnumeric-filter,
            AS_HELP_STRING([--without-gnumeric-filter],
                           [Disables the gnumeric import filter. The gnumeric import filter depends on zLib.]),
        [with_gnumeric_filter="$withval"],
        [with_gnumeric_filter=yes]
)

# ======================
# parquet filter support
# ======================
AC_ARG_WITH(parquet-filter,
            AS_HELP_STRING([--with-parquet-filter],
                           [Disables the parquet import filter. The parquet import filter depends on Apache Arrow.]),
        [with_parquet_filter="$withval"],
        [with_parquet_filter=no]
)

AC_ARG_WITH(cpu-features,
        AS_HELP_STRING([--with-cpu-features], [Enables custom CPU features.]),
        [with_cpu_features="$withval"],
        [with_cpu_features=no]
)

AC_ARG_WITH(benchmark,
        AS_HELP_STRING([--without-benchmark], [Disables building of benchmark testing programs.]),
        [with_benchmark="$withval"],
        [with_benchmark=yes]
)

AC_ARG_WITH(doc-example,
        AS_HELP_STRING([--with-doc-example], [Enables building of example code used in documentation.]),
        [with_doc_example="$withval"],
        [with_doc_example=no]
)

AM_CONDITIONAL([WITH_ODS_FILTER], [test "x$with_ods_filter" != "xno"])
AM_CONDITIONAL([WITH_XLSX_FILTER], [test "x$with_xlsx_filter" != "xno"])
AM_CONDITIONAL([WITH_XLS_XML_FILTER], [test "x$with_xls_xml_filter" != "xno"])
AM_CONDITIONAL([WITH_GNUMERIC_FILTER], [test "x$with_gnumeric_filter" != "xno"])
AM_CONDITIONAL([WITH_PARQUET_FILTER], [test "x$with_parquet_filter" != "xno"])
AM_CONDITIONAL([WITH_TOOLS], [test "x$with_tools" != "xno"])
AM_CONDITIONAL([WITH_BENCHMARK], [test "x$with_benchmark" != "xno"])
AM_CONDITIONAL([WITH_DOC_EXAMPLE], [test "x$with_doc_example" != "xno"])

AS_IF([test "x$with_ods_filter" != "xno"], [
        CXXFLAGS="$CXXFLAGS -D__ORCUS_ODS"
])

AS_IF([test "x$with_xlsx_filter" != "xno"], [
        CXXFLAGS="$CXXFLAGS -D__ORCUS_XLSX"
])

AS_IF([test "x$with_xls_xml_filter" != "xno"], [
        CXXFLAGS="$CXXFLAGS -D__ORCUS_XLS_XML"
])

AS_IF([test "x$with_gnumeric_filter" != "xno"], [
        CXXFLAGS="$CXXFLAGS -D__ORCUS_GNUMERIC"
        BOOST_IOSTREAMS
])

AS_IF([test "x$with_parquet_filter" != "xno"], [
        CXXFLAGS="$CXXFLAGS -D__ORCUS_PARQUET"
        PKG_CHECK_MODULES([PARQUET], [parquet])
])

AS_IF([test "x$with_cpu_features" != "xno"], [
        CXXFLAGS="$CXXFLAGS -D__ORCUS_CPU_FEATURES"
])

AS_IF([test "x$with_tools" != "xno"], [
        BOOST_PROGRAM_OPTIONS
        BOOST_SYSTEM
])

# ============
# mdds support
# ============
PKG_CHECK_MODULES([MDDS],[mdds-2.1 >= 2.1.1])
CXXFLAGS="$CXXFLAGS $MDDS_CFLAGS"

# =================
# Spreadsheet model
# =================
AC_ARG_ENABLE(spreadsheet-model,
        AS_HELP_STRING([--disable-spreadsheet-model],
                [Disable the spreadsheet model implementation in orcus.  Note that the spreadsheet-specific command line utilities will not be built when this is disabled.]),
        [enable_spreadsheet_model="$enableval"],
        [enable_spreadsheet_model=yes]
)
AS_IF([test "x$enable_spreadsheet_model" != "xno"], [
        PKG_CHECK_MODULES([LIBIXION],[libixion-$IXION_REQUIRED_API_VERSION >= 0.19.0])
        CXXFLAGS="$CXXFLAGS -D__ORCUS_SPREADSHEET_MODEL"
        BOOST_DATE_TIME
])
AM_CONDITIONAL([BUILD_SPREADSHEET_MODEL], [test "x$enable_spreadsheet_model" != "xno"])

# ==============
# Python support
# ==============
AC_ARG_ENABLE([python],
    [AS_HELP_STRING([--disable-python], [Disable python bindings])],
    [enable_python="$enableval"],
    [enable_python=yes]
)

# Check for python.
AS_IF([test "x$enable_python" != "xno"], [
    AM_PATH_PYTHON(3)
    PKG_CHECK_MODULES([PYTHON], [python3 >= 0.28])
])
AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" != "xno"])

# csv is always enabled.
CXXFLAGS="$CXXFLAGS -D__ORCUS_PYTHON_CSV"

with_python_xlsx="no"
if test "x$enable_spreadsheet_model" != "xno"; then
    if test "x$enable_python" != "xno"; then
        if test "x$with_xlsx_filter" != "xno"; then
            with_python_xlsx="yes"
        fi
    fi
fi

if test "x$with_python_xlsx" != "xno"; then
    CXXFLAGS="$CXXFLAGS -D__ORCUS_PYTHON_XLSX"
fi

with_python_ods="no"
if test "x$enable_spreadsheet_model" != "xno"; then
    if test "x$enable_python" != "xno"; then
        if test "x$with_ods_filter" != "xno"; then
            with_python_ods="yes"
        fi
    fi
fi

if test "x$with_python_ods" != "xno"; then
    CXXFLAGS="$CXXFLAGS -D__ORCUS_PYTHON_ODS"
fi

with_python_xls_xml="no"
if test "x$enable_spreadsheet_model" != "xno"; then
    if test "x$enable_python" != "xno"; then
        if test "x$with_xls_xml_filter" != "xno"; then
            with_python_xls_xml="yes"
        fi
    fi
fi

if test "x$with_python_xls_xml" != "xno"; then
    CXXFLAGS="$CXXFLAGS -D__ORCUS_PYTHON_XLS_XML"
fi

with_python_gnumeric="no"
if test "x$enable_spreadsheet_model" != "xno"; then
    if test "x$enable_python" != "xno"; then
        if test "x$with_gnumeric_filter" != "xno"; then
            with_python_gnumeric="yes"
        fi
    fi
fi

if test "x$with_python_gnumeric" != "xno"; then
    CXXFLAGS="$CXXFLAGS -D__ORCUS_PYTHON_GNUMERIC"
fi

AM_CONDITIONAL([WITH_PYTHON_XLSX], [test "x$with_python_xlsx" != "xno"])
AM_CONDITIONAL([WITH_PYTHON_ODS], [test "x$with_python_ods" != "xno"])
AM_CONDITIONAL([WITH_PYTHON_CSV], [test "x$with_python_csv" != "xno"])
AM_CONDITIONAL([WITH_PYTHON_XLS_XML], [test "x$with_python_xls_xml" != "xno"])
AM_CONDITIONAL([WITH_PYTHON_GNUMERIC], [test "x$with_python_gnumeric" != "xno"])

# ==============
# Werror support
# ==============

# NB: This must come at the end of all the other header detections, as enabling
# it may cause some header detections to fail.

AC_ARG_ENABLE([werror],
        [AS_HELP_STRING([--enable-werror], [Treat all warnings as errors, useful for development])],
        [enable_werror="$enableval"],
        [enable_werror=no]
)
AS_IF([test x"$enable_werror" = "xyes"], [
        CXXFLAGS="$CXXFLAGS -Werror"
])

AX_VALGRIND_CHECK()

AC_CONFIG_FILES([Makefile
        liborcus-$ORCUS_API_VERSION.pc:liborcus.pc.in
        liborcus-spreadsheet-model-$ORCUS_API_VERSION.pc:liborcus-spreadsheet-model.pc.in
        include/Makefile
        include/orcus/Makefile
        include/orcus/detail/Makefile
        include/orcus/spreadsheet/Makefile
        src/Makefile
        src/include/Makefile
        src/include/mso/Makefile
        src/liborcus/Makefile
        src/liborcus/constants.inl
        src/mso/Makefile
        src/parser/Makefile
        src/python/Makefile
        src/spreadsheet/Makefile
        src/test/Makefile
        test/python/env.json
        benchmark/Makefile
        doc_example/Makefile
])
AC_OUTPUT

# ==============================================
# Display final informations about configuration
# ==============================================
AC_MSG_NOTICE([
==============================================================================
Build configuration:
        debug                  $enable_debug
        debug-utils            $enable_debug_utils
        werror                 $enable_werror
        spreadsheet-model      $enable_spreadsheet_model
        gnumeric-filter        $with_gnumeric_filter
        ods-filter             $with_ods_filter
        xlsx-filter            $with_xlsx_filter
        xls-xml-filter         $with_xls_xml_filter
        gnumeric               $with_gnumeric_filter
        parquet                $with_parquet_filter
        tools                  $with_tools
        python                 $enable_python
        python-xlsx            $with_python_xlsx
        python-ods             $with_python_ods
        python-xls-xml         $with_python_xls_xml
        python-gnumeric        $with_python_gnumeric
        cpu-features           $with_cpu_features
        benchmark              $with_benchmark
        doc-example            $with_doc_example
==============================================================================
])