File: configure.ac

package info (click to toggle)
libica 3.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,672 kB
  • sloc: ansic: 39,028; perl: 3,061; makefile: 226; sh: 51
file content (133 lines) | stat: -rw-r--r-- 4,259 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
AC_INIT([libica], [3.9.0], [https://github.com/opencryptoki/libica/issues],, [https://github.com/opencryptoki/libica])

# save cmdline flags
cmdline_CFLAGS="$CFLAGS"

AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_SRCDIR([src/ica_api.c])
AC_CONFIG_MACRO_DIRS([m4])

AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL

AC_CHECK_HEADERS([fcntl.h memory.h stddef.h stdint.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/time.h syslog.h unistd.h])

AC_CHECK_HEADER([openssl/evp.h], [], [
	AC_MSG_ERROR([OpenSSL 1.1.1 or later is required but OpenSSL headers couldn't be found])
])

AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T

AC_FUNC_MALLOC
AC_FUNC_MMAP
AC_FUNC_STRNLEN
AC_CHECK_FUNCS([bzero ftruncate gettimeofday memchr memset munmap strcasecmp strerror strstr strtol setenv strtoull])

AC_CHECK_LIB([crypto], [EVP_sha3_256], [], [
	AC_MSG_ERROR([OpenSSL 1.1.1 or later is required but OpenSSL libraries version 1.1.1 or later couldn't be found])
])

AM_PROG_AS
LT_INIT
AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign])

FLAGS="-Wall -Wextra -mzarch"

dnl --- enable_debug
AC_ARG_ENABLE(debug,
              [  --enable-debug          turn on debugging flags],
              [],[enable_debug="no"])
AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)

if test "x$enable_debug" = xyes; then
	FLAGS="$FLAGS -g -O0"
	AC_MSG_RESULT([*** Enabling debugging at user request ***])
fi

dnl --- enable_coverage
AC_ARG_ENABLE(coverage,
              [  --enable-coverage       turn on coverage testing],
              [],[enable_coverage="no"])
AM_CONDITIONAL(COVERAGE, test x$enable_coverage = xyes)

if test "x$enable_coverage" = xyes; then
	FLAGS="$FLAGS -g -O0 -fprofile-arcs -ftest-coverage"
	AC_MSG_RESULT([*** Enabling coverage testing at user request ***])
fi

dnl --- enable_fips
AC_ARG_ENABLE(fips,
              [  --enable-fips           built with FIPS mode support],
              [],[enable_fips="no"])
AM_CONDITIONAL(ICA_FIPS, test x$enable_fips = xyes)

AC_CHECK_LIB([crypto], [OSSL_PROVIDER_load], [openssl3=yes], [])
AM_CONDITIONAL(ICA_OPENSSL3, test x$openssl3 = xyes)

if test "x$enable_fips" = xyes; then
	FLAGS="$FLAGS -DICA_FIPS"
	AC_MSG_RESULT([*** Building libica-fips at user request ***])
    AC_CHECK_PROG([openssl_var],[openssl],[yes],[no])
    if test "x$openssl_var" != xyes; then
        AC_MSG_ERROR([Missing openssl binary application required for FIPS build])
    fi
    if test "x$openssl3" = "xyes"; then
        FIPSDIR=`openssl version -d | cut -f 2- -d ' ' | tr -d \"`
        AC_SUBST(FIPSDIR)
        AC_CONFIG_FILES([src/openssl3-fips.cnf])
    fi
fi

dnl --- enable_sanitizer
AC_ARG_ENABLE(sanitizer,
              [  --enable-sanitizer      turn on sanitizer (may not work on all systems)],
              [],[enable_sanitizer="no"])
AM_CONDITIONAL(SANITIZER, test x$enable_sanitizer = xyes)

if test "x$enable_sanitizer" = xyes; then
	FLAGS="$FLAGS -O3 -g -fstack-protector-all -fsanitize=address,signed-integer-overflow,undefined -Wformat-security -Werror=format-security -Warray-bounds -Werror=array-bounds -D_FORTIFY_SOURCE=2"
	LIBS="-lubsan -lasan"
	AC_MSG_RESULT([*** Enabling sanitizer at user request ***])
fi

dnl --- enable_internal tests
AC_ARG_ENABLE(internal_tests,
              [  --enable-internal-tests built internal tests],
              [],[enable_internal_tests="no"])
AM_CONDITIONAL(ICA_INTERNAL_TESTS, test x$enable_internal_tests = xyes)

if test "x$enable_internal_tests" = xyes; then
	AC_MSG_RESULT([*** Building internal tests at user request ***])
fi



if test "x$enable_coverage" = xno && test "x$enable_debug" = xno && test "x$enable_sanitizer" = xno; then
	FLAGS="$FLAGS -O3 -D_FORTIFY_SOURCE=2"
fi

# restore cmdline flags (ignore PROG_AS/PROG_CC defaults)
CFLAGS="$cmdline_CFLAGS"
CCASFLAGS="$cmdline_CFLAGS"

AC_SUBST([FLAGS], $FLAGS)
AC_SUBST([LIBS], $LIBS)
AC_CONFIG_FILES([Makefile doc/Makefile include/Makefile src/Makefile test/Makefile])
AC_OUTPUT

echo "FLAGS=$FLAGS $CFLAGS"
echo "LIBS=$LIBS"

echo "Enabled features:"
echo "  FIPS build:      $enable_fips"
echo "  Debug build:     $enable_debug"
echo "  Sanitizer build: $enable_sanitizer"
echo "  Coverage build:  $enable_coverage"
echo "  Internal tests:  $enable_internal_tests"