File: configure.ac

package info (click to toggle)
detox 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,468 kB
  • sloc: ansic: 2,495; sh: 1,347; yacc: 234; makefile: 158; lex: 68; php: 32
file content (133 lines) | stat: -rw-r--r-- 3,031 bytes parent folder | download
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
# Process this file with autoconf to produce a configure script.
AC_INIT([detox], [2.0.0], [detox.dharple at gmail.com], [], [https://github.com/dharple/detox])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])

AC_PROG_CC
AC_PROG_LEX([noyywrap])
AC_PROG_YACC

AC_CHECK_FUNCS([getopt_long])
AC_STRUCT_ST_BLOCKS

AC_SYS_LARGEFILE

AC_CHECK_PROGS([MANDOC], [mandoc])
AM_CONDITIONAL([MANDOC_INSTALLED], [test -n "$MANDOC"])

AC_SEARCH_LIBS([ceil], [m])

#
# References and reasons for compiler flags:
#
# https://github.com/klange/prboom/blob/master/autotools/ac_c_compile_flags.m4
# https://github.com/dharple/detox/issues/31
# https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_cjh1548250046139.htm
# https://developers.redhat.com/blog/2020/05/22/stack-clash-mitigation-in-gcc-part-3/
# https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
#

AC_DEFUN([AC_CHECK_CFLAG], [
	HOLD="$CFLAGS"
	AC_MSG_CHECKING(whether compiler supports $1)
	CFLAGS="$HOLD $1 -Werror"
	AC_COMPILE_IFELSE(
		[AC_LANG_PROGRAM(
			[[]],
			[[]]
		)],
		[
			HOLD="$CFLAGS"
			AC_MSG_RESULT(yes)
		],
		[
			AC_MSG_RESULT(no)
		]
	)
	CFLAGS="$HOLD"
])

AC_CHECK_CFLAG([[-flto=auto]])
AC_CHECK_CFLAG([[-fstack-clash-protection]])
AC_CHECK_CFLAG([[-fstack-protector-strong]])

#
# Support for check unit tests
#

#
# source: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/External-Software.html
#

AC_ARG_WITH([check],
	[AS_HELP_STRING([--with-check],
		[enable experimental support for check])],
	[],
	[with_check=no]
)

AS_IF([test "x$with_check" != xno], [
	PKG_CHECK_EXISTS([CHECK], [check >= 0.10.0],
		[
			# the name of this macro is deceiving, it checks to see
			# if the module is available, and configures it

			PKG_CHECK_MODULES([CHECK], [check >= 0.10.0])
			AC_DEFINE([HAVE_LIBCHECK], [1], [Define if you have libcheck])
		],
		[
			AC_MSG_FAILURE([--with-check was given, but test for check failed])
		]
	)
])
AM_CONDITIONAL([WITH_CHECK], [test "x$with_check" != xno])

#
# Support for code coverage
#

AC_ARG_WITH([coverage],
	[AS_HELP_STRING([--with-coverage],
		[enable experimental support for coverage])],
	[],
	[with_coverage=no]
)

AS_IF([test "x$with_coverage" != xno], [
	AC_CHECK_CFLAG([[-fprofile-arcs]])

	# see src/Makefile.am
	# AC_CHECK_CFLAG([[-ftest-coverage]])

	AC_DEFINE([SUPPORT_COVERAGE], [1], [Define if you want to support coverage tests])
])
AM_CONDITIONAL([WITH_COVERAGE], [test "x$with_coverage" != xno])

#
# Support for debugging
#

AC_ARG_ENABLE([debug],
	[AS_HELP_STRING([--enable-debug], [Turn on debugging])],
	[case "${enableval}" in
	  yes) debug=true ;;
	  no)  debug=false ;;
	  *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
	esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
AM_COND_IF([DEBUG], [
	AC_DEFINE([DEBUG], [1], [Enables verbose debugging in key points])
]);

#
#
#

AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([
	Makefile
	src/Makefile
	tests/Makefile
	tests/legacy/Makefile
	tests/unit/Makefile
])
AC_OUTPUT