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
|
AC_INIT(ugrep,3.3)
AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER(config.h)
AC_COPYRIGHT([Copyright (C) 2019-2020 Robert van Engelen, Genivia Inc.])
AC_CONFIG_MACRO_DIR([m4])
# if CXXFLAGS is undefined, set it to our preferred default flags
: ${CXXFLAGS="-Wall -Wextra -Wunused -O2"}
: ${CFLAGS="-Wall -Wextra -Wunused -O2"}
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
AC_HEADER_DIRENT
AC_STRUCT_DIRENT_D_INO
AC_STRUCT_DIRENT_D_TYPE
AC_FUNC_MMAP
AC_CHECK_HEADERS([sys/statvfs.h])
AC_CHECK_FUNCS([statvfs])
AC_CHECK_MEMBERS([struct stat.st_atim, struct stat.st_mtim, struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_atimespec, struct stat.st_mtimespec, struct stat.st_ctimespec])
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_PROG_CXX
AM_PROG_AR
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
AC_CANONICAL_HOST
PLATFORM=${host}
AC_SUBST(PLATFORM)
# F_RDAHEAD fcntl()
AC_MSG_CHECKING(for F_RDAHEAD fcntl)
AC_TRY_COMPILE([
#include <fcntl.h>
],
[ int cmd = F_RDAHEAD; ],
[
AC_DEFINE(HAVE_F_RDAHEAD,1,[ Define if F_RDAHEAD fcntl() is supported])
AC_MSG_RESULT(yes)
], AC_MSG_RESULT(no)
)
# O_NOATIME open flag
AC_MSG_CHECKING(for O_NOATIME open flag)
AC_TRY_COMPILE([
#include <fcntl.h>
],
[ int cmd = O_NOATIME; ],
[
AC_DEFINE(HAVE_O_NOATIME,1,[ Define if O_NOATIME open flag is supported])
AC_MSG_RESULT(yes)
], AC_MSG_RESULT(no)
)
AX_CHECK_PCRE2([8],
[],
[echo "checking for Boost.Regex because PCRE2 is not usable"]
)
if test "x$pcre2_cv_libpcre2" != "xyes" || test "x$pcre2_cv_pcre2_h" != "xyes"; then
AX_BOOST_REGEX
fi
AX_CHECK_ZLIB([], [echo "zlib not found: ugrep option -z is not available"])
AX_CHECK_BZLIB([], [echo "libbz2 not found: ugrep option -z won't decompress .bz and .bz2 files"])
AX_CHECK_LZMALIB([], [echo "liblzma not found: ugrep option -z won't decompress .lzma and .xz files"])
AX_CHECK_LZ4LIB([], [echo "liblz4 not found: ugrep option -z won't decompress .lz4 files"])
AX_CHECK_ZSTDLIB([], [echo "libzstd not found: ugrep option -z won't decompress .zst files"])
AC_ARG_WITH(grep-path,
[AC_HELP_STRING([--with-grep-path=GREP_PATH],
[specifies the GREP_PATH if different than the default DATAROOTDIR/ugrep/patterns])],
[with_grep_path="$withval"],
[with_grep_path=""])
AC_MSG_CHECKING(for --with-grep-path)
if test "x$with_grep_path" != "x"; then
GREP_PATH="$with_grep_path"
AC_MSG_RESULT("$with_grep_path")
else
AC_MSG_RESULT()
GREP_PATH="${datadir}/ugrep/patterns"
fi
AC_SUBST(GREP_PATH)
AC_ARG_WITH(grep-colors,
[AC_HELP_STRING([--with-grep-colors="GREP_COLORS"],
[specifies the default ANSI SGR color parameters when variable GREP_COLORS is undefined])],
[with_grep_colors="$withval"],
[with_grep_colors=""])
AC_MSG_CHECKING(for --with-grep-colors)
if test "x$with_grep_colors" != "x"; then
AC_MSG_RESULT("$with_grep_colors")
EXTRA_CFLAGS="-DDEFAULT_GREP_COLORS=\"\\\"$with_grep_colors\\\"\" ${EXTRA_CFLAGS}"
else
AC_MSG_RESULT()
fi
AC_ARG_ENABLE(auto-color,
[AC_HELP_STRING([--disable-auto-color],
[disable automatic colors, otherwise colors are enabled by default])],
[with_no_auto_color="yes"],
[with_no_auto_color="no"])
AC_MSG_CHECKING(for --disable-auto-color)
if test "x$with_no_auto_color" = "xno"; then
AC_MSG_RESULT(no)
EXTRA_CFLAGS="-DWITH_COLOR ${EXTRA_CFLAGS}"
else
AC_MSG_RESULT(yes)
fi
AC_ARG_ENABLE(color,
[AC_HELP_STRING([--enable-color],
[deprecated, use --disable-auto-color])],
[],
[])
AC_MSG_CHECKING(for --enable-color)
if test "x$with_no_auto_color" = "xno"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_ARG_ENABLE(pretty,
[AC_HELP_STRING([--enable-pretty],
[enable pretty output by default without requiring ugrep flag --pretty])],
[with_pretty="$enable_pretty"],
[with_pretty="no"])
AC_MSG_CHECKING(for --enable-pretty)
if test "x$with_pretty" = "xyes"; then
AC_MSG_RESULT(yes)
EXTRA_CFLAGS="-DWITH_PRETTY ${EXTRA_CFLAGS}"
else
AC_MSG_RESULT(no)
fi
AC_ARG_ENABLE(pager,
[AC_HELP_STRING([--enable-pager],
[enable the pager by default without requiring ugrep flag --pager])],
[with_pager="$enable_pager"],
[with_pager="no"])
AC_MSG_CHECKING(for --enable-pager)
if test "x$with_pager" = "xyes"; then
AC_MSG_RESULT(yes)
EXTRA_CFLAGS="-DWITH_PAGER ${EXTRA_CFLAGS}"
else
AC_MSG_RESULT(no)
fi
AC_ARG_ENABLE(hidden,
[AC_HELP_STRING([--enable-hidden],
[enable searching hidden files and directories by default unless explicitly disabled with ugrep flag --no-hidden])],
[with_hidden="yes"],
[with_hidden="no"])
AC_MSG_CHECKING(for --enable-hidden)
if test "x$with_hidden" = "xno"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
EXTRA_CFLAGS="-DWITH_HIDDEN ${EXTRA_CFLAGS}"
fi
AC_ARG_ENABLE(mmap,
[AC_HELP_STRING([--disable-mmap],
[disable memory mapped files unless explicitly enabled with --mmap])],
[with_no_mmap="yes"],
[with_no_mmap="no"])
AC_MSG_CHECKING(for --disable-mmap)
if test "x$with_no_mmap" = "xno"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
EXTRA_CFLAGS="-DWITH_NO_MMAP ${EXTRA_CFLAGS}"
fi
AC_SUBST(EXTRA_CFLAGS)
AC_ARG_ENABLE(avx,
[AC_HELP_STRING([--disable-avx],
[disable AVX optimizations])],
[with_no_avx="yes"],
[with_no_avx="no"])
AC_MSG_CHECKING(for --disable-avx)
if test "x$with_no_avx" = "xno"; then
AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether ${CXX} supports AVX intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]], [[__m512 n = _mm512_set1_epi8(42); (void)_mm512_cmpeq_epi8_mask(n, n);]])],
[mavx_ok=yes],
[mavx_ok=no])
if test "x$mavx_ok" = "xyes"; then
SIMD_FLAGS="-mavx512bw -DHAVE_AVX512BW"
else
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]], [[__m256i n = _mm256_set1_epi8(42); (void)_mm256_movemask_epi8(_mm256_and_si256(n, n));]])],
[mavx_ok=yes],
[mavx_ok=no])
if test "x$mavx_ok" = "xyes"; then
SIMD_FLAGS="-mavx2 -DHAVE_AVX2"
fi
fi
AC_MSG_RESULT($mavx_ok)
else
AC_MSG_RESULT(yes)
SIMD_FLAGS=
fi
if test "x$SIMD_FLAGS" = "x"; then
AC_ARG_ENABLE(sse2,
[AC_HELP_STRING([--disable-sse2],
[disable SSE2 optimizations])],
[with_no_sse2="yes"],
[with_no_sse2="no"])
AC_MSG_CHECKING(for --disable-sse2)
if test "x$with_no_sse2" = "xno"; then
AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether ${CXX} supports SSE2 intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <emmintrin.h>]], [[__m128i n = _mm_set1_epi8(42);]])],
[msse2_ok=yes],
[msse2_ok=no])
AC_MSG_RESULT($msse2_ok)
if test "x$msse2_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_SSE2"
fi
else
AC_MSG_RESULT(yes)
SIMD_FLAGS=
fi
fi
if test "x$SIMD_FLAGS" = "x"; then
AC_ARG_ENABLE(neon,
[AC_HELP_STRING([--disable-neon],
[disable ARM NEON/AArch64 optimizations])],
[with_no_neon="yes"],
[with_no_neon="no"])
AC_MSG_CHECKING(for --disable-neon)
if test "x$with_no_neon" = "xno"; then
AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether ${CXX} supports ARM NEON/AArch64 intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-DHAVE_NEON"
else
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-DHAVE_NEON"
else
CXXFLAGS="-mfpu=neon"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-mfpu=neon -DHAVE_NEON"
fi
fi
fi
fi
AC_MSG_RESULT($mneon_ok)
else
AC_MSG_RESULT(yes)
SIMD_FLAGS=
fi
fi
AC_SUBST(SIMD_FLAGS)
AC_SUBST([PTHREAD_CFLAGS], [""])
AC_SUBST([PTHREAD_LIBS], ["-lpthread"])
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile])
AC_OUTPUT
|