summaryrefslogtreecommitdiff
blob: 63e41169874563d683712b4953c232929ba1d2f6 (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
#
#	configure.ac: this file is part of the elfix package
#	Copyright (C) 2011  Anthony G. Basile
#
#	This program is free software: you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation, either version 3 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

AC_PREREQ([2.68])
AC_INIT([elfix], [0.8.5], [http://bugs.gentoo.org/])
AC_CONFIG_SRCDIR([src/fix-gnustack.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.12 foreign])
AM_SILENT_RULES([no])

LT_PREREQ([2.4])
LT_INIT([dlopen])
AC_CONFIG_MACRO_DIR([m4])

AC_ARG_ENABLE(
	[tests],
	AS_HELP_STRING(
		[--enable-tests],
		[perform tests]
	),
	[test "x$enable_tests" = "xyes"]
)
AM_CONDITIONAL([TEST],[test "x$enable_tests" = "xyes"])

# Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_SED

# Checks for header files.
AC_CHECK_HEADERS(
	[errno.h err.h fcntl.h gelf.h libgen.h stdio.h stdlib.h string.h \
	sys/mman.h sys/stat.h sys/types.h unistd.h],
	[],
	[AC_MSG_ERROR(["Missing necessary header"])]
)

# Checks for DECLs.
AC_CHECK_DECL([ELF_C_RDWR_MMAP],[],[],[[#include <libelf.h>]])
AM_CONDITIONAL([BUILD_ELF],[test "x$ac_cv_have_decl_ELF_C_RDWR_MMAP" = "xyes"])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T

# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_MMAP
AC_CHECK_FUNCS([memset strerror])

# Note: this is always needed for fix-gnustack
# and for paxctl-ng only with --enable-ptpax
AC_CHECK_LIB(
	[elf],
	[elf_begin],
	[],
	[AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])]
)

AC_ARG_ENABLE(
	[ptpax],
	AS_HELP_STRING(
		[--enable-ptpax],
		[enable support for pax markings in PT_PAX ELF phdr]
	)
)

AS_IF(
	[test "x$enable_ptpax" != "xno"],
	[
		AS_IF(
			[test "x$ac_cv_have_decl_ELF_C_RDWR_MMAP" = "xyes"],
			[
				AC_CHECK_DECLS(
					[PT_PAX_FLAGS, PF_PAGEEXEC, PF_MPROTECT, PF_RANDMMAP],
					[],
					[
						CFLAGS+=" -DNEED_PAX_DECLS"
					],
					[[#include <gelf.h>]]
				)
				CFLAGS+=" -DPTPAX"
			],
			[AC_MSG_ERROR(["Missing necessary DECL ELF_C_RDWR_MMAP in libelf"])]
		)
	],
	[
		CFLAGS+=" -UPTPAX -DNEED_PAX_DECLS"
	]
)

AC_ARG_ENABLE(
	[xtpax],
	AS_HELP_STRING(
		[--enable-xtpax],
		[enable support for pax markings in xattrs]
	)
)

AS_IF(
	[test "x$enable_xtpax" != "xno"],
	[
		AC_CHECK_HEADERS(
			[attr/xattr.h],
			[],
			[AC_MSG_ERROR(["Missing necessary attr/xattr.h"])]
		)
		AC_CHECK_LIB(
			[attr],
			[fgetxattr],
			[],
			[AC_MSG_ERROR(["Missing necessary function fgetxattr in libattr"])]
		)
		CFLAGS+=" -DXTPAX"
	],
	[
		CFLAGS+=" -UXTPAX"
	]
)

if [test "x$enable_ptpax" = "xno" -a  "x$enable_xtpax" = "xno" ]; then
	AC_MSG_ERROR(["You must enable either ptpax or xtpax"])
fi

AM_CONDITIONAL([DUALTEST],[test "x$enable_ptpax" = "xyes" -a  "x$enable_xtpax" = "xyes"])

# Ready to configure our files
AC_CONFIG_FILES([
	Makefile
	src/Makefile
	scripts/Makefile
	doc/Makefile
	tests/Makefile
	tests/gnustack/Makefile
	tests/pxtpax/Makefile
	tests/paxmodule/Makefile
	tests/revdeppaxtest/Makefile
])

AC_OUTPUT