-
Notifications
You must be signed in to change notification settings - Fork 70
/
configure.ac
214 lines (180 loc) · 6.89 KB
/
configure.ac
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
AC_PREREQ([2.69])
AC_INIT([liboffsetfinder64], m4_esyscmd([git rev-list --count HEAD | tr -d '\n']), [[email protected]])
AC_CANONICAL_SYSTEM
AC_CANONICAL_HOST
AM_PROG_LIBTOOL
AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_DEFINE([VERSION_COMMIT_COUNT], "m4_esyscmd([git rev-list --count HEAD | tr -d '\n'])", [Git commit count])
AC_DEFINE([VERSION_COMMIT_SHA], "m4_esyscmd([git rev-parse HEAD | tr -d '\n'])", [Git commit sha])
AC_SUBST([VERSION_COMMIT_COUNT], ["m4_esyscmd([git rev-list --count HEAD | tr -d '\n'])"])
AC_SUBST([VERSION_COMMIT_SHA], ["m4_esyscmd([git rev-parse HEAD | tr -d '\n'])"])
# Checks for programs.
AC_PROG_CXX([clang++])
AC_PROG_CC([clang])
# Check for operating system
AC_MSG_CHECKING([whether we need platform-specific build settings])
case $host_os in
darwin* )
AC_MSG_RESULT([${host_os}])
CXXFLAGS+=" -stdlib=libc++ "
;;
*mingw32*|*cygwin*|*msys*)
AC_MSG_RESULT([${host_os}])
win32=true
LDFLAGS+=" -no-undefined -lws2_32"
;;
esac
CXXFLAGS+=" -std=c++20 -O3"
CFLAGS+=" -std=c11"
CXXFLAGS+=" -D EXPECTIONNAME=OFexception"
# Checks for libraries.
IMG4TOOL_REQUIRES_STR="libimg4tool >= 198"
IMG3TOOL_REQUIRES_STR="libimg3tool >= 2"
LIBGENERAL_REQUIRES_STR="libgeneral >= 65"
LIBINSN_REQUIRES_STR="libinsn >= 38"
PKG_CHECK_MODULES(libimg4tool, $IMG4TOOL_REQUIRES_STR, have_img4tool=yes, have_img4tool=no)
PKG_CHECK_MODULES(libimg3tool, $IMG3TOOL_REQUIRES_STR, have_img3tool=yes, have_img3tool=no)
PKG_CHECK_MODULES(libgeneral, $LIBGENERAL_REQUIRES_STR)
PKG_CHECK_MODULES(libinsn, $LIBINSN_REQUIRES_STR)
AC_SUBST([libgeneral_requires], [$LIBGENERAL_REQUIRES_STR])
AC_SUBST([libinsn_requires], [$LIBINSN_REQUIRES_STR])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[enable debug build(default is no)])],
[debug_build=true],
[debug_build=false])
AC_ARG_WITH([img4tool],
[AS_HELP_STRING([--without-img4tool],
[do not build with img4tool @<:@default=yes@:>@])],
[with_img4tool=no],
[with_img4tool=yes])
AC_ARG_WITH([img3tool],
[AS_HELP_STRING([--without-img3tool],
[do not build with img3tool @<:@default=yes@:>@])],
[with_img3tool=no],
[with_img3tool=yes])
AC_ARG_ENABLE([asan],
[AS_HELP_STRING([--enable-asan],
[enable ASAN build(default is no)])],
[asan_build=true],
[asan_build=false])
AC_ARG_WITH([wtfpwndfu],
[AS_HELP_STRING([--with-wtfpwndfu],
[build with wtfpwndfu @<:@default=no@:>@])],
[with_wtfpwndfu=yes],
[with_wtfpwndfu=no])
AC_ARG_WITH([binrider],
[AS_HELP_STRING([--with-binrider],
[do build with binrider @<:@default=no@:>@])],
[with_binrider=yes],
[with_binrider=no])
AC_ARG_WITH([offsetexporter],
[AS_HELP_STRING([--with-offsetexporter],
[do build with offsetexporter @<:@default=no@:>@])],
[with_offsetexporter=yes],
[with_offsetexporter=no])
AM_CONDITIONAL(WITH_BINRIDER, test x$with_binrider == xyes)
AM_CONDITIONAL(WITH_OFFSETEXPORTER, test x$with_offsetexporter == xyes)
if test "x$have_img4tool" == "xyes"; then
if test "x$with_img4tool" = "xyes"; then
AC_DEFINE(HAVE_IMG4TOOL, 1, [Define if you have img4tool])
AC_SUBST([img4tool_requires], [$IMG4TOOL_REQUIRES_STR])
AC_SUBST(libimg4tool_CFLAGS)
AC_SUBST(libimg4tool_LIBS)
else
echo "*** Note: img4tool has been disabled ***"
fi
else
if test "x$with_img4tool" == "xyes"; then
AC_MSG_ERROR([requested building with img4tool, but library could not be found])
fi
fi
if test "x$have_img3tool" == "xyes"; then
if test "x$with_img3tool" = "xyes"; then
AC_DEFINE(HAVE_IMG3TOOL, 1, [Define if you have img3tool])
AC_SUBST([img3tool_requires], [$IMG3TOOL_REQUIRES_STR])
AC_SUBST(libimg3tool_CFLAGS)
AC_SUBST(libimg3tool_LIBS)
else
echo "*** Note: img3tool has been disabled ***"
fi
else
if test "x$with_img3tool" == "xyes"; then
AC_MSG_ERROR([requested building with img3tool, but library could not be found])
fi
fi
if test "$debug_build" = true; then
echo "*** Note: debug build requested ***"
CFLAGS+=" -g -O0 -DDEBUG=1"
CXXFLAGS+=" -g -O0 -DDEBUG=1"
fi
if test "$asan_build" = true; then
echo "*** Note: debug build requested ***"
CFLAGS+=" -g -O0 -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope"
CXXFLAGS+=" -g -O0 -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope"
fi
if test "x$with_wtfpwndfu" = "xyes"; then
AC_DEFINE(WITH_WTFPWNDFU, 1, [Define if you build with wtfpwndfu])
if test "x$CCARMV6" == "x"; then
echo "*** Assuming host CC can compile armv6 binaries ***"
CCARMV6="$CC -arch armv6"
fi
echo "*** Using CCARMV6 as $CCARMV6 ***"
AC_SUBST(CCARMV6)
if test "x$OTOOLARM" == "x"; then
echo "*** Assuming host OTOOL can otool arm64/arm32 binaries ***"
OTOOLARM=$OTOOL
fi
echo "*** Using custom OTOOLARM as $OTOOLARM ***"
AC_SUBST(OTOOLARM)
else
echo "*** Note: wtfpwndfu has been disabled ***"
fi
AM_CONDITIONAL(WITH_WTFPWNDFU, test x$with_wtfpwndfu == xyes)
# Checks for header files.
ORIG_CFLAGS=${CFLAGS}
CFLAGS+=" -I${lt_sysroot}/include -I${lt_sysroot}/${prefix}/include -I${lt_sysroot}/${ac_default_prefix}/include"
AC_CHECK_HEADERS([mach-o/loader.h mach-o/nlist.h], [
AC_DEFINE(HAVE_MACHO_O_HEADER, 1, [Define if you have apple cctools headers])
AC_SUBST([HAVE_MACHO_O_HEADER], [1])
have_macho_header=yes;
], [
AC_SUBST([HAVE_MACHO_O_HEADER], [0])
have_macho_header=no;
], [])
CFLAGS=${ORIG_CFLAGS}
if test "x$have_macho_header" != "xyes"; then
AC_MSG_ERROR(["Macho-O headers not found, are apple cctools headers installed?"])
fi
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h arpa/inet.h winsock.h])
# Check for functions
AC_CHECK_FUNCS([memmem])
LT_INIT
AC_CONFIG_FILES([Makefile
include/Makefile
libpatchfinder/Makefile
libpatchfinder/ibootpatchfinder/Makefile
libpatchfinder/kernelpatchfinder/Makefile
tools/Makefile
tools/binrider/Makefile
tools/offsetexporter/Makefile
libpatchfinder.pc])
AC_OUTPUT
echo "
Configuration for $PACKAGE-$VERSION:
-------------------------------------------
install prefix ..........: $prefix
have img4tool ...........: $with_img4tool
have img3tool ...........: $with_img3tool
have mach-o header.......: $have_macho_header
debug build ............: $debug_build
asan build .............: $asan_build
with binrider ...........: $with_binrider
with offsetexporter .....: $with_offsetexporter
with wtfpwndfu ..........: $with_wtfpwndfu"
echo " compiler ................: ${CC}
Now type 'make' to build $PACKAGE-$VERSION,
and then 'make install' for installation.
"