aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 36a1e8eaf24a9c8f15c436ef558d2c49735218fb (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
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
AC_INIT([embedlog], [0.3.2], [michal.lyszczek@bofc.pl])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_LANG([C])
AC_PROG_CC
AC_PROG_CC_C89
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_FILES([Makefile \
                 src/Makefile \
                 include/Makefile \
                 tst/Makefile \
                 man/Makefile \
                 examples/Makefile \
                 www/Makefile])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])


AC_SEARCH_LIBS([pow], [m])

###
# compile own snprintf if system doesn't provide one
#


AC_CHECK_FUNCS([snprintf])
AS_IF([test "x$ac_cv_func_snprintf" != "xyes"],
[
    ###
    # system is missing snprintf, provide one from the library
    #

    AC_DEFINE([NEED_SNPRINTF_ONLY], [1], [Library uses only snprintf])
])


###
# force portable snprintf (from library source tree) instead of provided one
# by the system
#
# --enable-portable-snprintf
#


AC_ARG_ENABLE([portable-snprintf],
    AS_HELP_STRING([--enable-portable-snprintf], [Use snprintf provided by library]),
    [], [enable_portable_snprintf="no"])

AS_IF([test "x$enable_portable_snprintf" = "xyes"],
[
    AC_DEFINE([PREFER_PORTABLE_SNPRINTF], [1], [Use snprintf provided by library])
])


###
# gcov coverage reporting
#


m4_include([m4/gcov.m4])
AC_TDD_GCOV
AC_SUBST(COVERAGE_CFLAGS)
AC_SUBST(COVERAGE_CXXFLAGS)
AC_SUBST(COVERAGE_LDFLAGS)


###
# --enable-feature options
#

###
# --enable-out-stderr
#


AC_ARG_ENABLE([out-stderr],
    AS_HELP_STRING([--enable-out-stderr], [Enable printing to stderr]),
    [], [enable_out_stderr="yes"])

AS_IF([test "x$enable_out_stderr" = "xyes"],
[
    AC_DEFINE([ENABLE_OUT_STDERR], [1], [Enable printing to stderr])
    AC_CHECK_FUNCS([fputs],,
        AC_MSG_ERROR(not found, needed by --enable-out-stderr))
])


###
# --enable-out-file
#


AC_ARG_ENABLE([out-file],
    AS_HELP_STRING([--enable-out-file], [Enable printing to file]),
    [], [enable_out_file="yes"])

AM_CONDITIONAL([ENABLE_OUT_FILE], [test "x$enable_out_file" = "xyes"])
AS_IF([test "x$enable_out_file" = "xyes"],
[
    AC_DEFINE([ENABLE_OUT_FILE], [1], [Enable printing to file])
    AC_CHECK_FUNCS(access stat fsync fileno)
    AC_CHECK_FUNCS([fopen fclose remove rename],,
        AC_MSG_ERROR(not found, needed by --enable-out-file))
])


###
# --enable-out-tty
#


AC_ARG_ENABLE([out-tty],
    AS_HELP_STRING([--enable-out-tty], [Enable printing to tty]),
    [], [enable_out_tty="yes"])

AM_CONDITIONAL([ENABLE_OUT_TTY], [test "x$enable_out_tty" = "xyes"])
AS_IF([test "x$enable_out_tty" = "xyes"],
[
    AC_DEFINE([ENABLE_OUT_TTY], [1], [Enable printing to tty])
    AC_CHECK_HEADERS(termios.h)
    AC_CHECK_FUNCS([open tcgetattr cfsetispeed tcsetattr close],,
        AC_MSG_ERROR(not found, needed by --enable-out-tty))
])


###
# --enable-out-custom
#


AC_ARG_ENABLE([out-custom],
    AS_HELP_STRING([--enable-out-custom], [Enable printing to custom]),
    [], [enable_out_custom="yes"])

AM_CONDITIONAL([ENABLE_OUT_CUSTOM], [test "x$enable_out_custom" = "xyes"])
AS_IF([test "x$enable_out_custom" = "xyes"],
[
    AC_DEFINE([ENABLE_OUT_CUSTOM], [1], [Enable printing to custom])
    AC_CHECK_FUNCS([fopen fclose remove rename],,
        AC_MSG_ERROR(not found, needed by --enable-out-custom))
])


###
# --enable-timestamp
#


AC_ARG_ENABLE([timestamp],
    AS_HELP_STRING([--enable-timestamp], [Enable printing timestamp with log]),
    [], [enable_timestamp="yes"])

AS_IF([test "x$enable_timestamp" = "xyes"],
[
    AC_DEFINE([ENABLE_TIMESTAMP], [1], [Enable printing timestamp with log])
    AC_CHECK_FUNCS([clock time sprintf],,
        AC_MSG_ERROR(not found, needed by --enable-timestamp))
])


###
# --enable-fractions
#


AC_ARG_ENABLE([fractions],
    AS_HELP_STRING([--enable-fractions], [Enable printing fractions with log]),
    [], [enable_fractions="yes"])

AS_IF([test "x$enable_fractions" = "xyes"],
[
    AS_IF([test "x$enable_timestamp" = "xyes"],
    [
        AC_DEFINE([ENABLE_FRACTIONS], [1], [Enable printing fractions with log])
        AC_CHECK_FUNCS([sprintf],,
            AC_MSG_ERROR(not found, needed by --enable-fractions))
    ],
    #else
    [
        AC_MSG_WARN(--enable-fractions without --enable_timestamp has no effect)
        enable_fractions="no (unmet dependency)"
    ])
])


###
# --enable-realtime
#


AC_ARG_ENABLE([realtime],
    AS_HELP_STRING([--enable-realtime], [Enable using CLOCK_REALTIME in log]),
    [], [enable_realtime="yes"])

AS_IF([test "x$enable_realtime" = "xyes"],
[
    AS_IF([test "x$enable_timestamp" = "xyes"],
    [
        AC_DEFINE([ENABLE_REALTIME], [1], [Enable using CLOCK_REALTIME in log])
        AC_CHECK_FUNCS([clock_gettime],,
            AC_MSG_ERROR(not found, needed by --enable-realtime))
    ],
    #else
    [
        AC_MSG_WARN(--enable-realtime without --enable-timestamp has no effect)
        enable_realtime="no (unmet dependency)"
    ])
])


###
# --enable-monotonic
#


AC_ARG_ENABLE([monotonic],
    AS_HELP_STRING([--enable-monotonic], [Enable using CLOCK_MONOTONIC in log]),
    [], [enable_monotonic="yes"])

AS_IF([test "x$enable_monotonic" = "xyes"],
[
    AS_IF([test "x$enable_timestamp" = "xyes"],
    [
        AC_DEFINE([ENABLE_MONOTONIC], [1], [Enable using CLOCK_MONOTONIC in log])
        AC_CHECK_FUNCS([clock_gettime],,
            AC_MSG_ERROR(not found, needed by --enable-monotonic))
    ],
    #else
    [
        AC_MSG_WARN(--enable-monotonic without --enable-timestamp has no effect)
        enable_monotonic="no (unmet dependency)"
    ])
])


###
# --enable-clock
#


AC_ARG_ENABLE([clock],
    AS_HELP_STRING([--enable-clock], [Enable using clock() as tme source in log]),
    [], [enable_clock="yes"])

AS_IF([test "x$enable_clock" = "xyes"],
[
    AS_IF([test "x$enable_timestamp" = "xyes"],
    [
        AC_DEFINE([ENABLE_CLOCK], [1], [Enable using clock() as time source in log])
        AC_CHECK_FUNCS([clock],,
            AC_MSG_ERROR(not found, needed by --enable-clock))
    ],
    # else
    [
        AC_MSG_WARN(--enable-clock without --enable-timestamp has no effect)
        enable_clock="no (unmet dependency)"
    ])
])


###
# --enable-binary
#


AC_ARG_ENABLE([binary-logs],
    AS_HELP_STRING([--enable-binary-logs], [Enable printing binary logs]),
    [], [enable_binary_logs="no"])

AM_CONDITIONAL([ENABLE_BINARY_LOGS], [test "x$enable_binary_logs" = "xyes"])

AS_IF([test "x$enable_binary_logs" = "xyes"],
[
    AS_IF([test "x$enable_out_file" = "xyes"],
    [
        AC_DEFINE([ENABLE_BINARY_LOGS], [1], [Enable printing binary logs])
    ],
    # else
    [
        AC_MSG_WARN(--enable-binary-logs without --enable-out-file has no effect)
        enable_binary_logs="no (unmet dependency)"
    ])
])


###
# --enable-prefix
#


AC_ARG_ENABLE([prefix],
    AS_HELP_STRING([--enable-prefix], [Enable printing prefix to each message]),
    [], [enable_prefix="yes"])

AS_IF([test "x$enable_prefix" = "xyes"],
[
    AC_DEFINE([ENABLE_PREFIX], [1], [Enable printing prefix to each message])
    AC_CHECK_FUNCS([strncat strlen],,
        AC_MSG_ERROR(not found, needed by --enable-prefix))
])


###
# --enable-finfo
#


AC_ARG_ENABLE([finfo],
    AS_HELP_STRING([--enable-finfo], [Enable printing file info with log]),
    [], [enable_finfo="yes"])

AS_IF([test "x$enable_finfo" = "xyes"],
[
    AC_DEFINE([ENABLE_FINFO], [1], [Enable printing file info with log])
    AC_CHECK_FUNCS([strncat strlen sprintf],,
        AC_MSG_ERROR(not found, needed by --enable-finfo))
])


###
# --enable-colors
#


AC_ARG_ENABLE([colors],
    AS_HELP_STRING([--enable-colors], [Enable output colorization]),
    [], [enable_colors="yes"])

AS_IF([test "x$enable_colors" = "xyes"],
[
    AC_DEFINE([ENABLE_COLORS], [1], [Enable output colorization])
    AC_CHECK_FUNCS([strcpy strlen],,
        AC_MSG_ERROR(not found, needed by --enable-colors))
])


###
# --enable-colors-extended
#


AC_ARG_ENABLE([colors-extended],
    AS_HELP_STRING([--enable-colors-extended], [Enable more colors in logs]),
    [], [enable_colors_extended="no"])

AS_IF([test "x$enable_colors_extended" = "xyes"],
[
    AS_IF([test "x$enable_colors" = "xyes"],
    [
        AC_DEFINE([ENABLE_COLORS_EXTENDED], [1], [Enable more colors in logs])
    ],
    #else
    [
        AC_MSG_WARN(--enable-colors-extended without --enable-colors has no effect)
        enable_colors_extended="no (unmet dependency)"
    ])
])


###
# --enable-reentrant
#


AC_ARG_ENABLE([reentrant],
    AS_HELP_STRING([--enable-reentrant], [Enable reentrant functions]),
    [], [enable_reentrant="yes"])

AS_IF([test "x$enable_reentrant" = "xyes"],
[
    AC_DEFINE([ENABLE_REENTRANT], [1], [Enable reentrant functions])
    AC_CHECK_FUNCS([gmtime_r],,
        AC_MSG_ERROR(not found, needed by --enable-reentrant))
])


###
# VARIABLES=value options
#

###
# EL_PREFIX_MAX
#


AC_ARG_VAR([EL_PREFIX_MAX], [Maximum size of prefix])
AS_IF([test "x$EL_PREFIX_MAX" = x], [EL_PREFIX_MAX="128"])
AC_DEFINE_UNQUOTED([EL_PREFIX_MAX], [$EL_PREFIX_MAX], [Maximum size of prefix])


###
# EL_LOG_MAX
#


AC_ARG_VAR([EL_LOG_MAX], [Maximum size of single log message])
AS_IF([test "x$EL_LOG_MAX" = x], [EL_LOG_MAX="8192"])
AC_DEFINE_UNQUOTED([EL_LOG_MAX], [$EL_LOG_MAX], [Maximum size of single log message])


###
# EL_FLEN_MAX
#


AC_ARG_VAR([EL_FLEN_MAX], [Maximum size of file info in message])
AS_IF([test "x$EL_FLEN_MAX" = x], [EL_FLEN_MAX="32"])
AC_DEFINE_UNQUOTED([EL_FLEN_MAX], [$EL_FLEN_MAX], [Maximum size of file info in message])

###
# EL_MEM_LINE_SIZE
#


AC_ARG_VAR([EL_MEM_LINE_SIZE], [Number of bytes to print in single lin in pmemory function])
AS_IF([test "x$EL_MEM_LINE_SIZE" = x], [EL_MEM_LINE_SIZE="16"])
AC_DEFINE_UNQUOTED([EL_MEM_LINE_SIZE], [$EL_MEM_LINE_SIZE],
    [Number of bytes to print in one line in el_pmemory function])


###
# MAX_PATH
#

AC_ARG_VAR([MAX_PATH], [Maximum length of path to log file (used when PATH_MAX is not available)])
AS_IF([test "x$MAX_PATH" = x], [MAX_PATH="4096"])
AC_DEFINE_UNQUOTED([MAX_PATH], [$MAX_PATH],
    [Maximum length of path to open when printing to file])


###
# --enable-analyzer
#


AC_ARG_ENABLE([analyzer],
    AS_HELP_STRING([--enable-analyzer], [Enable static code analyzer]),
    [enable_analyzer="yes"], [enable_analyzer="no"])
AM_CONDITIONAL([ENABLE_ANALYZER], [test "x$enable_analyzer" = "xyes"])


AC_OUTPUT


echo
echo "embedlog compilation configuration summary"
echo
echo "print to stderr............. : $enable_out_stderr"
echo "print to file............... : $enable_out_file"
echo "print to tty................ : $enable_out_tty"
echo "print to custom routine..... : $enable_out_custom"
echo "print timestamp enabled..... : $enable_timestamp"
echo "print fractions of seconds.. : $enable_fractions"
echo "clock_realtime timestamp.... : $enable_realtime"
echo "clock_monotonic timestamp... : $enable_monotonic"
echo "clock() timestamp........... : $enable_clock"
echo "print prefix with each msg.. : $enable_prefix"
echo "print file info with log.... : $enable_finfo"
echo "force portable snprintf..... : $enable_portable_snprintf"
echo "binary logs................. : $enable_binary_logs"
echo "colorize output............. : $enable_colors"
echo "extended colors............. : $enable_colors_extended"
echo "reentrant functions......... : $enable_reentrant"
echo "maximum prefix length....... : $EL_PREFIX_MAX"
echo "maximum file length......... : $EL_FLEN_MAX"
echo "maximum log message......... : $EL_LOG_MAX"
echo "maximum path length......... : $MAX_PATH"
echo "pmemory line size........... : $EL_MEM_LINE_SIZE"