File: configure.ac

package info (click to toggle)
libetonyek 0.1.9-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 7,076 kB
  • sloc: cpp: 41,221; sh: 4,553; makefile: 707; xml: 9; ansic: 4
file content (436 lines) | stat: -rw-r--r-- 13,421 bytes parent folder | download | duplicates (2)
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
# Process this file with autoconf to create configure.

AC_PREREQ([2.65])

# ====================
# Version informations
# ====================
m4_define([libetonyek_version_major],[0])
m4_define([libetonyek_version_minor],[1])
m4_define([libetonyek_version_micro],[9])
m4_define([libetonyek_version],[libetonyek_version_major.libetonyek_version_minor.libetonyek_version_micro])

# =============
# Automake init
# =============
AC_INIT([libetonyek],[libetonyek_version])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([1.11 foreign dist-xz dist-bzip2 subdir-objects])
AM_SILENT_RULES([yes])
AC_LANG([C++])

# =================
# Configure options
# =================
AC_ARG_WITH([mdds],
            AS_HELP_STRING([--with-mdds=1.4|1.2|1.0|0.x], [Specify which version of mdds to use (1.2 is the default)]),
            [], [with_mdds="1.2"])

# ===========================
# Find required base packages
# ===========================
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
LT_INIT([win32-dll disable-static pic-only])
AC_CANONICAL_HOST

PKG_PROG_PKG_CONFIG([0.20])

AC_PROG_EGREP
AC_PROG_SED

AM_MISSING_PROG([GPERF], [gperf])

AX_CXX_COMPILE_STDCXX_11
AX_GCC_FUNC_ATTRIBUTE([format])
DLP_FALLTHROUGH

# ===============
# Find librevenge
# ===============
PKG_CHECK_MODULES([REVENGE],[librevenge-0.0])
AC_SUBST([REVENGE_CFLAGS])
AC_SUBST([REVENGE_LIBS])

# ============
# Find libxml2
# ============
PKG_CHECK_MODULES([XML],[libxml-2.0])

# =========
# Find zlib
# =========
PKG_CHECK_MODULES([ZLIB],[zlib])
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS)

# ===============
# Find liblangtag
# ===============
AC_ARG_WITH([liblangtag],
    [AS_HELP_STRING([--without-liblangtag], [Disable use of liblangtag])],
    [with_liblangtag="$withval"],
    [with_liblangtag="yes"]
)
AS_IF([test "x$with_liblangtag" = "xyes"], [
        PKG_CHECK_MODULES([LANGTAG],[liblangtag])
        AC_DEFINE([WITH_LIBLANGTAG], [1], [Build with liblangtag])
    ],
    []
)
AM_CONDITIONAL([WITH_LIBLANGTAG], [test "x$with_liblangtag" = "xyes"])

# ==================
# Find boost headers
# ==================
saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${BOOST_CFLAGS} ${CPPFLAGS}"
AC_CHECK_HEADERS(
        boost/algorithm/string/predicate.hpp \
        boost/any.hpp \
        boost/container/deque.hpp \
        boost/cstdint.hpp \
        boost/fusion/adapted/std_pair.hpp \
        boost/fusion/include/adapt_struct.hpp \
        boost/lexical_cast.hpp \
        boost/none.hpp \
        boost/numeric/conversion/cast.hpp \
        boost/optional.hpp \
        boost/spirit/include/phoenix.hpp \
        boost/spirit/include/qi.hpp \
        boost/variant/recursive_variant.hpp \
        boost/variant/variant.hpp \
        ,
    [],
    [AC_MSG_ERROR([Required boost headers not found.])],
    []
)
CPPFLAGS="${saved_CPPFLAGS}"
AC_SUBST([BOOST_CFLAGS])

# ================
# Find glm headers
# ================
saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${GLM_CFLAGS} ${CPPFLAGS}"
AC_CHECK_HEADERS([glm/glm.hpp], [], [AC_MSG_ERROR([Required glm headers not found.])])
CPPFLAGS="${saved_CPPFLAGS}"
AC_SUBST([GLM_CFLAGS])

# =========
# Find mdds
# =========
AS_IF([test "$with_mdds" != "0.x"],
    [PKG_CHECK_MODULES([MDDS], [mdds-][$with_mdds])],
    [
        PKG_CHECK_MODULES([MDDS], [mdds])
        AC_MSG_CHECKING([checking if mdds::flat_segment_tree can store values of any type])
        old_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="$MDDS_CFLAGS $CPPFLAGS"
        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
            #include <mdds/flat_segment_tree.hpp>
            struct Value {};
            mdds::flat_segment_tree<int, Value> tree(0, 4, Value());
        ])], [
            AC_MSG_RESULT([yes])
        ], [
            AC_MSG_RESULT([no])
            AC_MSG_ERROR([please install mdds >= 0.12.1])
        ])
        CPPFLAGS="$old_CPPFLAGS"
    ]
)

# =================================
# Libtool/Version Makefile settings
# =================================
AC_SUBST(ETONYEK_MAJOR_VERSION, [libetonyek_version_major])
AC_SUBST(ETONYEK_MINOR_VERSION, [libetonyek_version_minor])
AC_SUBST(ETONYEK_MICRO_VERSION, [libetonyek_version_micro])
AC_SUBST(KN_VERSION, [libetonyek_version])
# AC_SUBST(LT_RELEASE, [libetonyek_version_major.libetonyek_version_minor])
LT_CURRENT=`expr 100 '*' libetonyek_version_major + libetonyek_version_minor`
# For 1.0.0 comment the first line and uncomment the second
LT_AGE=0
# LT_AGE=libetonyek_version_minor
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION, [libetonyek_version_micro])
AC_SUBST(LT_AGE)

# ==========================
# Platform check for windows
# ==========================
AC_MSG_CHECKING([for native Win32])
AS_CASE([$host],
	[*-*-mingw*], [
		native_win32=yes
		LIBETONYEK_WIN32_RESOURCE=libetonyek-win32res.lo
		KEY2RAW_WIN32_RESOURCE=key2raw-win32res.lo
		KEY2TEXT_WIN32_RESOURCE=key2text-win32res.lo
		KEY2XHTML_WIN32_RESOURCE=key2xhtml-win32res.lo
		NUMBERS2CSV_WIN32_RESOURCE=numbers2csv-win32res.lo
		NUMBERS2RAW_WIN32_RESOURCE=numbers2raw-win32res.lo
		NUMBERS2TEXT_WIN32_RESOURCE=numbers2text-win32res.lo
		PAGES2HTML_WIN32_RESOURCE=pages2html-win32res.lo
		PAGES2RAW_WIN32_RESOURCE=pages2raw-win32res.lo
		PAGES2TEXT_WIN32_RESOURCE=pages2text-win32res.lo
	], [
		native_win32=no
		LIBETONYEK_WIN32_RESOURCE=
		KEY2RAW_WIN32_RESOURCE=
		KEY2TEXT_WIN32_RESOURCE=
		KEY2XHTML_WIN32_RESOURCE=
		NUMBERS2CSV_WIN32_RESOURCE=
		NUMBERS2RAW_WIN32_RESOURCE=
		NUMBERS2TEXT_WIN32_RESOURCE=
		PAGES2HTML_WIN32_RESOURCE=
		PAGES2RAW_WIN32_RESOURCE=
		PAGES2TEXT_WIN32_RESOURCE=
	]
)
AC_MSG_RESULT([$native_win32])
AM_CONDITIONAL(OS_WIN32, [test "x$native_win32" = "xyes"])
AC_SUBST(LIBETONYEK_WIN32_RESOURCE)
AC_SUBST(KEY2RAW_WIN32_RESOURCE)
AC_SUBST(KEY2TEXT_WIN32_RESOURCE)
AC_SUBST(KEY2XHTML_WIN32_RESOURCE)
AC_SUBST(NUMBERS2CSV_WIN32_RESOURCE)
AC_SUBST(NUMBERS2RAW_WIN32_RESOURCE)
AC_SUBST(NUMBERS2TEXT_WIN32_RESOURCE)
AC_SUBST(PAGES2HTML_WIN32_RESOURCE)
AC_SUBST(PAGES2RAW_WIN32_RESOURCE)
AC_SUBST(PAGES2TEXT_WIN32_RESOURCE)

AC_MSG_CHECKING([for Win32 platform in general])
AS_CASE([$host],
	[*-*-mingw*|*-*-cygwin*], [platform_win32=yes],
	[platform_win32=no]
)
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL([PLATFORM_WIN32], [test "x$platform_win32" = "xyes"])

AS_IF([test "x$platform_win32" = "xyes"],
    [],
    [
        AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
        saved_CXXFLAGS="$CXXFLAGS"
        CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
        AC_TRY_COMPILE([], [], [have_visibility=yes], [have_visibility=no])
        AC_MSG_RESULT([$have_visibility])
        CXXFLAGS="$saved_CXXFLAGS"
        AX_GCC_FUNC_ATTRIBUTE([visibility])
        AM_CONDITIONAL([HAVE_VISIBILITY],
            [test "$have_visibility" = "yes" && test "$ax_cv_have_func_attribute_visibility" = "yes"])
    ]
)

# ================
# Check for cflags
# ================
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" != "xno"], [
	CFLAGS="$CFLAGS -Werror"
	CXXFLAGS="$CXXFLAGS -Werror"
])
AC_ARG_ENABLE([weffc],
	[AS_HELP_STRING([--disable-weffc], [ Disable -Weffc++ warnings, useful when using an old version of gcc or of boost])],
	[enable_weffc="$enableval"],
	[enable_weffc=yes]
)
AC_ARG_ENABLE([wparanoic],
	[AS_HELP_STRING([--enable-wparanoic], [Enable a lot of warnings...])],
	[enable_wparanoic="$enableval"],
	[enable_wparanoic=no]
)
# Courtesy of Glib: Ensure MSVC-compatible struct packing convention
# is used when compiling for Win32 with gcc.
AS_IF([test "x$native_win32" = "xyes"], [
	AC_CHECK_TOOL(WINDRES, windres)
	AS_IF([test x"$GCC" = xyes], [
		AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
		AS_IF([test -z "$ac_cv_prog_CC"], [
			our_gcc="$CC"
		], [
			our_gcc="$ac_cv_prog_CC"
		])
		AS_IF([$our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null], [
			msnative_struct="-mms-bitfields"
			CFLAGS="$CFLAGS $msnative_struct"
			CXXFLAGS="$CXXFLAGS $msnative_struct"
			AC_MSG_RESULT([${msnative_struct}])
		], [
			AC_MSG_RESULT([no way])
			AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
		])
	])
	CFLAGS="$CFLAGS -Wall -Wextra -pedantic"
	CXXFLAGS="$CXXFLAGS -Wall -Wextra -pedantic -Wshadow -Wunused-variable"
], [
	AS_IF([test x"$GCC" = xyes], [
		# Be tough with warnings and produce less careless code
		CFLAGS="$CFLAGS -Wall -Wextra -pedantic"
		CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wshadow -pedantic"
		AS_IF([test x"$enable_weffc" != "xno"], [
			CXXFLAGS="$CXXFLAGS -Weffc++"
		])
		AS_IF([test x"$enable_wparanoic" != "xno"], [
			CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wchar-subscripts"
			CXXFLAGS="$CXXFLAGS -Wcomment -Wconversion -Wdisabled-optimization"
			CXXFLAGS="$CXXFLAGS -Wfloat-equal -Wformat -Wformat=2"
			CXXFLAGS="$CXXFLAGS -Wformat-nonliteral -Wformat-security"
			CXXFLAGS="$CXXFLAGS -Wformat-y2k -Wimport -Winit-self -Winvalid-pch"
			CXXFLAGS="$CXXFLAGS -Wmissing-braces -Wmissing-field-initializers"
			CXXFLAGS="$CXXFLAGS -Wmissing-format-attribute -Wmissing-include-dirs"
			CXXFLAGS="$CXXFLAGS -Wmissing-noreturn -Wpacked -Wparentheses"
			CXXFLAGS="$CXXFLAGS -Wpointer-arith -Wredundant-decls -Wreturn-type"
			CXXFLAGS="$CXXFLAGS -Wsequence-point -Wsign-compare -Wstrict-aliasing"
			CXXFLAGS="$CXXFLAGS -Wstrict-aliasing=2 -Wswitch -Wswitch-default"
			CXXFLAGS="$CXXFLAGS -Wswitch-enum -Wtrigraphs -Wunknown-pragmas -Wunused"
			CXXFLAGS="$CXXFLAGS -Wunused-function -Wunused-label -Wunused-parameter"
			CXXFLAGS="$CXXFLAGS -Wunused-value -Wvariadic-macros"
			CXXFLAGS="$CXXFLAGS -Wvolatile-register-var -Wwrite-strings"
		])
	])
])

# ============
# Debug switch
# ============
AC_ARG_ENABLE([debug],
	[AS_HELP_STRING([--enable-debug], [Turn on debugging])],
	[enable_debug="$enableval"],
	[enable_debug=no]
)
AS_IF([test "x$enable_debug" = "xyes"], [
	DEBUG_CXXFLAGS="-DDEBUG -g"
	CXXFLAGS="$CXXFLAGS -O0"
	CFLAGS="$CFLAGS -O0"
], [
	DEBUG_CXXFLAGS="-DNDEBUG"
])
AC_SUBST(DEBUG_CXXFLAGS)

# ==========
# Unit tests
# ==========
AC_ARG_ENABLE([tests],
    [AS_HELP_STRING([--enable-tests], [Build and run unit tests])],
    [enable_tests="$enableval"],
    [enable_tests=yes]
)
AS_IF([test "x$enable_tests" = "xyes"], [
    PKG_CHECK_MODULES([CPPUNIT], [cppunit])
    PKG_CHECK_MODULES([REVENGE_STREAM],[librevenge-stream-0.0])
], [])
AC_SUBST([CPPUNIT_CFLAGS])
AC_SUBST([CPPUNIT_LIBS])
AM_CONDITIONAL(TESTS, [test "x$enable_tests" = "xyes"])

# =============
# Documentation
# =============
AC_ARG_WITH(docs,
	[AS_HELP_STRING([--without-docs], [Do not build documentation])],
	[with_docs="$withval"],
	[AS_IF([test "x$native_win32" = "xyes"], [with_docs=no], [with_docs=yes])]
)
AS_IF([test "x$with_docs" != "xno"], [
	AC_PATH_PROG(DOXYGEN, [doxygen])
	AS_IF([test -z "$DOXYGEN"], [
		AC_MSG_WARN([*** Could not find doxygen in your PATH.])
		AC_MSG_WARN([*** The documentation will not be built.])
		build_docs=no
	], [build_docs=yes])
], [build_docs=no])
AM_CONDITIONAL([WITH_LIBETONYEK_DOCS], [test "x$build_docs" != "xno"])

# ================
# Conversion tools
# ================
AC_ARG_WITH(tools,
	[AS_HELP_STRING([--without-tools], [Do not build command line conversion tools])],
	[with_tools="$withval"],
	[]
)
AS_IF([test "x$with_tools" != "xno"], [build_tools=yes], [build_tools=no])
AM_CONDITIONAL([WITH_LIBETONYEK_TOOLS], [test "x$build_tools" != "xno"])

# =======
# Fuzzers
# =======
AC_ARG_ENABLE([fuzzers],
	[AS_HELP_STRING([--enable-fuzzers], [Build fuzzer(s)])],
	[enable_fuzzers="$enableval"],
	[enable_fuzzers=no]
)
AM_CONDITIONAL(BUILD_FUZZERS, [test "x$enable_fuzzers" = "xyes"])

AS_IF([test "x$build_tools" = "xyes" -o "x$enable_fuzzers" = "xyes"], [
    PKG_CHECK_MODULES([REVENGE_GENERATORS],[librevenge-generators-0.0])
    PKG_CHECK_MODULES([REVENGE_STREAM],[librevenge-stream-0.0])
])
AC_SUBST([REVENGE_GENERATORS_CFLAGS])
AC_SUBST([REVENGE_GENERATORS_LIBS])
AC_SUBST([REVENGE_STREAM_CFLAGS])
AC_SUBST([REVENGE_STREAM_LIBS])

# =====================
# Prepare all .in files
# =====================
AC_CONFIG_FILES([
Makefile
src/Makefile
src/conv/Makefile
src/conv/csv/numbers2csv.rc
src/conv/csv/Makefile
src/conv/html/Makefile
src/conv/html/pages2html.rc
src/conv/raw/Makefile
src/conv/raw/key2raw.rc
src/conv/raw/numbers2raw.rc
src/conv/raw/pages2raw.rc
src/conv/svg/Makefile
src/conv/svg/key2xhtml.rc
src/conv/text/Makefile
src/conv/text/key2text.rc
src/conv/text/numbers2text.rc
src/conv/text/pages2text.rc
src/fuzz/Makefile
src/lib/Makefile
src/lib/libetonyek.rc
src/test/Makefile
inc/Makefile
inc/libetonyek/Makefile
build/Makefile
build/win32/Makefile
docs/Makefile
docs/doxygen/Makefile
libetonyek-$ETONYEK_MAJOR_VERSION.$ETONYEK_MINOR_VERSION.pc:libetonyek.pc.in
])
AC_OUTPUT

# ==============================================
# Display final informations about configuration
# ==============================================
AC_MSG_NOTICE([
==============================================================================
Build configuration:
	debug:           ${enable_debug}
	docs:            ${build_docs}
	fuzzers:         ${enable_fuzzers}
	liblangtag:      ${with_liblangtag}
	tests:           ${enable_tests}
	tools:           ${build_tools}
	werror:          ${enable_werror}
==============================================================================
])