| 1 |
# Adapted from https://github.com/traversc/qs/blob/master/configure.ac and |
| 2 |
# https://github.com/ropensci/git2r/blob/master/configure.ac . |
| 3 |
|
| 4 |
AC_PREREQ([2.69]) |
| 5 |
AC_INIT([pgenlibr],[0.4.0],[[email protected]]) |
| 6 |
AC_PATH_PROG([PKGCONF],[pkg-config],[],[$PATH:/usr/local/bin:ext/bin:ext:/sw/bin:/opt/bin:/opt/local/bin]) |
| 7 |
|
| 8 |
# Find the compiler and compiler flags to use for fallback version checks |
| 9 |
AC_LANG(C++) |
| 10 |
: ${R_HOME=`R RHOME`} |
| 11 |
PATH_TO_CPP_COMPILER=`"${R_HOME}/bin/R" CMD config CXX` |
| 12 |
AC_PROG_CXX([$PATH_TO_CPP_COMPILER]) |
| 13 |
AC_MSG_NOTICE([C++ compiler: $PATH_TO_CPP_COMPILER]) |
| 14 |
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS` |
| 15 |
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS` |
| 16 |
|
| 17 |
# Configure args |
| 18 |
AC_ARG_WITH([zstd-include], |
| 19 |
AS_HELP_STRING([--with-zstd-include=INCLUDE_PATH],[the location of zstd header files]), |
| 20 |
[zstd_include_path=$withval]) |
| 21 |
|
| 22 |
AC_ARG_WITH([zstd-lib], |
| 23 |
AS_HELP_STRING([--with-zstd-lib=LIB_PATH],[the location of zstd library files]), |
| 24 |
[zstd_lib_path=$withval]) |
| 25 |
|
| 26 |
AC_ARG_WITH([libdeflate-include], |
| 27 |
AS_HELP_STRING([--with-libdeflate-include=INCLUDE_PATH],[the location of libdeflate header files]), |
| 28 |
[libdeflate_include_path=$withval]) |
| 29 |
|
| 30 |
AC_ARG_WITH([libdeflate-lib], |
| 31 |
AS_HELP_STRING([--with-libdeflate-lib=LIB_PATH],[the location of libdeflate library files]), |
| 32 |
[libdeflate_lib_path=$withval]) |
| 33 |
|
| 34 |
AC_ARG_WITH([simde-include], |
| 35 |
AS_HELP_STRING([--with-simde-include=INCLUDE_PATH],[the location of simde header files]), |
| 36 |
[simde_include_path=$withval]) |
| 37 |
|
| 38 |
# pkg-config version value functions |
| 39 |
getVersion2() |
| 40 |
{ |
| 41 |
VERSION_STRING=$1 |
| 42 |
MAJOR=`echo $VERSION_STRING | cut -d. -f1` |
| 43 |
MINOR=`echo $VERSION_STRING | cut -d. -f2` |
| 44 |
echo $(($MAJOR*1000+$MINOR)) |
| 45 |
} |
| 46 |
|
| 47 |
getVersion3() |
| 48 |
{ |
| 49 |
VERSION_STRING=$1 |
| 50 |
MAJOR=`echo $VERSION_STRING | cut -d. -f1` |
| 51 |
MINOR=`echo $VERSION_STRING | cut -d. -f2` |
| 52 |
RELEASE=`echo $VERSION_STRING | cut -d. -f3` |
| 53 |
echo $(($MAJOR*100000+$MINOR*100+$RELEASE)) |
| 54 |
} |
| 55 |
|
| 56 |
# Compile zstd/libdeflate/simde checks |
| 57 |
ZSTD_COMPILE_FLAG="" |
| 58 |
ZSTD_INCLUDE_PATH="" |
| 59 |
ZSTD_LIBS="" |
| 60 |
ZSTD_SHLIB="" |
| 61 |
ZSTD_CLEAN="" |
| 62 |
COMPILE_ZSTD="" |
| 63 |
LIBDEFLATE_COMPILE_FLAG="" |
| 64 |
LIBDEFLATE_INCLUDE_PATH="" |
| 65 |
LIBDEFLATE_LIBS="" |
| 66 |
LIBDEFLATE_SHLIB="" |
| 67 |
LIBDEFLATE_CLEAN="" |
| 68 |
COMPILE_LIBDEFLATE="" |
| 69 |
SIMDE_COMPILE_FLAG="" |
| 70 |
SIMDE_INCLUDE_PATH="" |
| 71 |
USE_BUNDLED_SIMDE="" |
| 72 |
|
| 73 |
if test "xx$zstd_include_path" != "xx"; then |
| 74 |
AC_MSG_NOTICE([Using user-defined zstd install paths]) |
| 75 |
ZSTD_INCLUDE_PATH="-I${zstd_include_path}" |
| 76 |
ZSTD_LIBS="-L${zstd_lib_path}" |
| 77 |
COMPILE_ZSTD="false" |
| 78 |
else |
| 79 |
if test "xx$PKGCONF" != "xx"; then |
| 80 |
if "${PKGCONF}" --exists libzstd; then |
| 81 |
VERSION_STRING=`${PKGCONF} --modversion libzstd` |
| 82 |
VER=`getVersion3 ${VERSION_STRING}` |
| 83 |
# The bundled 1.5.5 includes a compression bugfix, but the Python/R |
| 84 |
# interfaces currently only use zstd for decompression, so we don't need |
| 85 |
# it. |
| 86 |
# 1.5.4 is over a year old, and its release notes mention 32-bit |
| 87 |
# bugfixes, so we now require it. |
| 88 |
if test "${VER}" -ge 100504; then |
| 89 |
AC_MSG_NOTICE([zstd ${VERSION_STRING} library detected -- skipping zstd compilation]) |
| 90 |
ZSTD_INCLUDE_PATH=`"${PKGCONF}" --cflags-only-I libzstd` |
| 91 |
ZSTD_LIBS=`"${PKGCONF}" --libs libzstd` |
| 92 |
COMPILE_ZSTD="false" |
| 93 |
else |
| 94 |
AC_MSG_NOTICE([zstd ${VERSION_STRING} library detected but is too old (<1.5.2) -- compiling from source]) |
| 95 |
COMPILE_ZSTD="true" |
| 96 |
fi |
| 97 |
fi |
| 98 |
fi |
| 99 |
if test "xx$COMPILE_ZSTD" = "xx"; then |
| 100 |
AC_MSG_NOTICE([zstd not detected by pkg-config; falling back on system header file check]) |
| 101 |
zstd_ver_ok=no |
| 102 |
${PATH_TO_CPP_COMPILER} ${CPPFLAGS} ${CXXFLAGS} -E tools/zstd_version.cpp >/dev/null 2>&1 && zstd_ver_ok=yes |
| 103 |
AC_MSG_RESULT([${zstd_ver_ok}]) |
| 104 |
if test "xx${zstd_ver_ok}" = "xxyes"; then |
| 105 |
ZSTD_LIBS="-lzstd" |
| 106 |
COMPILE_ZSTD="false" |
| 107 |
else |
| 108 |
COMPILE_ZSTD="true" |
| 109 |
fi |
| 110 |
fi |
| 111 |
fi |
| 112 |
|
| 113 |
if test xx$COMPILE_ZSTD = "xxtrue"; then |
| 114 |
ZSTD_COMPILE_FLAG="-DZSTD_DISABLE_ASM" |
| 115 |
ZSTD_INCLUDE_PATH="-Izstd/lib -Izstd/lib/common" |
| 116 |
ZSTD_LIBS="${LIBS} -lPGZSTD" |
| 117 |
ZSTD_SHLIB="libPGZSTD.a" |
| 118 |
ZSTD_CLEAN="\$(LIBZSTD) libPGZSTD.a" |
| 119 |
else |
| 120 |
ZSTD_COMPILE_FLAG="-DIGNORE_BUNDLED_ZSTD" |
| 121 |
fi |
| 122 |
|
| 123 |
if test "xx$libdeflate_include_path" != "xx"; then |
| 124 |
AC_MSG_NOTICE([Using user-defined libdeflate install paths]) |
| 125 |
LIBDEFLATE_INCLUDE_PATH="-I${libdeflate_include_path}" |
| 126 |
LIBDEFLATE_LIBS="-L${libdeflate_lib_path}" |
| 127 |
COMPILE_LIBDEFLATE="false" |
| 128 |
else |
| 129 |
if test "xx$PKGCONF" != "xx"; then |
| 130 |
if "${PKGCONF}" --exists libdeflate; then |
| 131 |
VERSION_STRING=`${PKGCONF} --modversion libdeflate` |
| 132 |
VER=`getVersion2 ${VERSION_STRING}` |
| 133 |
# 1.14 is over a year old, and includes significant performance |
| 134 |
# improvements. |
| 135 |
# Don't see anything important in subsequent versions. 1.20 breaks |
| 136 |
# compatibility with gcc <4.9, which I'm still using for 32-bit plink2 |
| 137 |
# builds, so bundled version is likely to remain 1.19 for a long time. |
| 138 |
if test "${VER}" -ge 1014; then |
| 139 |
AC_MSG_NOTICE([libdeflate ${VERSION_STRING} library detected -- skipping libdeflate compilation]) |
| 140 |
LIBDEFLATE_INCLUDE_PATH=`"${PKGCONF}" --cflags-only-I libdeflate` |
| 141 |
LIBDEFLATE_LIBS=`"${PKGCONF}" --libs libdeflate` |
| 142 |
COMPILE_LIBDEFLATE="false" |
| 143 |
else |
| 144 |
AC_MSG_NOTICE([libdeflate ${VERSION_STRING} library detected but is too old (<1.9) -- compiling from source]) |
| 145 |
COMPILE_LIBDEFLATE="true" |
| 146 |
fi |
| 147 |
fi |
| 148 |
fi |
| 149 |
if test "xx$COMPILE_LIBDEFLATE" = "xx"; then |
| 150 |
AC_MSG_NOTICE([libdeflate not detected by pkg-config; falling back on system header file check]) |
| 151 |
libdeflate_ver_ok=no |
| 152 |
${PATH_TO_CPP_COMPILER} ${CPPFLAGS} ${CXXFLAGS} -E tools/libdeflate_version.cpp >/dev/null 2>&1 && libdeflate_ver_ok=yes |
| 153 |
AC_MSG_RESULT([${libdeflate_ver_ok}]) |
| 154 |
if test "xx${libdeflate_ver_ok}" = "xxyes"; then |
| 155 |
LIBDEFLATE_LIBS="-ldeflate" |
| 156 |
COMPILE_LIBDEFLATE="false" |
| 157 |
else |
| 158 |
COMPILE_LIBDEFLATE="true" |
| 159 |
fi |
| 160 |
fi |
| 161 |
fi |
| 162 |
|
| 163 |
if test xx$COMPILE_LIBDEFLATE = "xxtrue"; then |
| 164 |
LIBDEFLATE_INCLUDE_PATH="-Ilibdeflate" |
| 165 |
LIBDEFLATE_LIBS="${LIBS} -lPGDEFLATE" |
| 166 |
LIBDEFLATE_SHLIB="libPGDEFLATE.a" |
| 167 |
LIBDEFLATE_CLEAN="\$(LIBDEFLATE) libPGDEFLATE.a" |
| 168 |
else |
| 169 |
LIBDEFLATE_COMPILE_FLAG="-DIGNORE_BUNDLED_LIBDEFLATE" |
| 170 |
fi |
| 171 |
|
| 172 |
if test "xx$simde_include_path" != "xx"; then |
| 173 |
AC_MSG_NOTICE([Using user-defined simde install paths]) |
| 174 |
SIMDE_INCLUDE_PATH="-I${simde_include_path}" |
| 175 |
USE_BUNDLED_SIMDE="false" |
| 176 |
else |
| 177 |
if test "xx$PKGCONF" != "xx"; then |
| 178 |
if "${PKGCONF}" --exists simde; then |
| 179 |
VERSION_STRING=`${PKGCONF} --modversion simde` |
| 180 |
VER=`getVersion3 ${VERSION_STRING}` |
| 181 |
# TODO: verify v0.8.x doesn't break anything. |
| 182 |
if test "${VER}" -ge 702; then |
| 183 |
AC_MSG_NOTICE([simde ${VERSION_STRING} library detected -- ignoring bundled simde header files]) |
| 184 |
SIMDE_INCLUDE_PATH=`"${PKGCONF}" --cflags-only-I simde` |
| 185 |
USE_BUNDLED_SIMDE="false" |
| 186 |
else |
| 187 |
AC_MSG_NOTICE([simde ${VERSION_STRING} library detected but is too old (<0.7.2) -- using bundled header files]) |
| 188 |
USE_BUNDLED_SIMDE="true" |
| 189 |
fi |
| 190 |
fi |
| 191 |
fi |
| 192 |
if test "xx$USE_BUNDLED_SIMDE" = "xx"; then |
| 193 |
AC_MSG_NOTICE([simde not detected by pkg-config; falling back on system header file check]) |
| 194 |
simde_ver_ok=no |
| 195 |
${PATH_TO_CPP_COMPILER} ${CPPFLAGS} ${CXXFLAGS} -E tools/simde_version.cpp >/dev/null 2>&1 && simde_ver_ok=yes |
| 196 |
AC_MSG_RESULT([${simde_ver_ok}]) |
| 197 |
if test "xx${simde_ver_ok}" = "xxyes"; then |
| 198 |
USE_BUNDLED_SIMDE="false" |
| 199 |
else |
| 200 |
USE_BUNDLED_SIMDE="true" |
| 201 |
fi |
| 202 |
fi |
| 203 |
fi |
| 204 |
|
| 205 |
if test xx$USE_BUNDLED_SIMDE != "xxtrue"; then |
| 206 |
SIMDE_COMPILE_FLAG="-DIGNORE_BUNDLED_SIMDE" |
| 207 |
fi |
| 208 |
|
| 209 |
|
| 210 |
AC_SUBST([ZSTD_COMPILE_FLAG], $ZSTD_COMPILE_FLAG) |
| 211 |
AC_SUBST([ZSTD_INCLUDE_PATH], $ZSTD_INCLUDE_PATH) |
| 212 |
AC_SUBST([ZSTD_LIBS], $ZSTD_LIBS) |
| 213 |
AC_SUBST([ZSTD_SHLIB], $ZSTD_SHLIB) |
| 214 |
AC_SUBST([ZSTD_CLEAN], $ZSTD_CLEAN) |
| 215 |
AC_SUBST([LIBDEFLATE_COMPILE_FLAG], $LIBDEFLATE_COMPILE_FLAG) |
| 216 |
AC_SUBST([LIBDEFLATE_INCLUDE_PATH], $LIBDEFLATE_INCLUDE_PATH) |
| 217 |
AC_SUBST([LIBDEFLATE_LIBS], $LIBDEFLATE_LIBS) |
| 218 |
AC_SUBST([LIBDEFLATE_SHLIB], $LIBDEFLATE_SHLIB) |
| 219 |
AC_SUBST([LIBDEFLATE_CLEAN], $LIBDEFLATE_CLEAN) |
| 220 |
AC_SUBST([SIMDE_COMPILE_FLAG], $SIMDE_COMPILE_FLAG) |
| 221 |
AC_SUBST([SIMDE_INCLUDE_PATH], $SIMDE_INCLUDE_PATH) |
| 222 |
|
| 223 |
|
| 224 |
AC_CONFIG_FILES([src/Makevars]) |
| 225 |
AC_OUTPUT |