diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-11-26 17:06:04 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-11-26 17:06:04 +0300 |
commit | 7738609fe2e0c465769bbfd2763eba01855ddd98 (patch) | |
tree | deeaa9fae88eedd4e21f32080a70ebf395a4e80b | |
parent | 7a66082eeeb55ebef8caff1588145d99cd2d37d1 (diff) | |
download | libmicrohttpd-7738609fe2e0c465769bbfd2763eba01855ddd98.tar.gz libmicrohttpd-7738609fe2e0c465769bbfd2763eba01855ddd98.zip |
configure: added parameter to disable sendfile().
-rw-r--r-- | configure.ac | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac index a2714940..25c00baa 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1248,11 +1248,22 @@ AC_FUNC_FSEEKO | |||
1248 | AC_CHECK_FUNCS([lseek64 pread64 pread]) | 1248 | AC_CHECK_FUNCS([lseek64 pread64 pread]) |
1249 | 1249 | ||
1250 | # check for various sendfile functions | 1250 | # check for various sendfile functions |
1251 | found_sendfile="no" | 1251 | AC_ARG_ENABLE([sendfile], |
1252 | AC_MSG_CHECKING([[for Linux-style sendfile(2)]]) | 1252 | [AS_HELP_STRING([--disable-sendfile], |
1253 | AC_LINK_IFELSE( | 1253 | [disable usage of sendfile() for HTTP connections [auto]])], |
1254 | [AC_LANG_PROGRAM( | 1254 | [], |
1255 | [[ | 1255 | [enable_sendfile="auto"]) |
1256 | AS_CASE([$enable_sendfile], | ||
1257 | [[auto | yes]],[[found_sendfile="no"]], | ||
1258 | [[no]],[[found_sendfile="disabled"]], | ||
1259 | [AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])] | ||
1260 | ) | ||
1261 | AS_VAR_IF([[found_sendfile]], [["no"]], | ||
1262 | [ | ||
1263 | AC_MSG_CHECKING([[for Linux-style sendfile(2)]]) | ||
1264 | AC_LINK_IFELSE( | ||
1265 | [AC_LANG_PROGRAM( | ||
1266 | [[ | ||
1256 | #include <sys/sendfile.h> | 1267 | #include <sys/sendfile.h> |
1257 | 1268 | ||
1258 | static void empty_func(void) | 1269 | static void empty_func(void) |
@@ -1262,25 +1273,27 @@ static void empty_func(void) | |||
1262 | } | 1273 | } |
1263 | /* Declare again to check form match */ | 1274 | /* Declare again to check form match */ |
1264 | ssize_t sendfile(int, int, off_t*, size_t); | 1275 | ssize_t sendfile(int, int, off_t*, size_t); |
1265 | ]], | 1276 | ]], |
1266 | [[ | 1277 | [[ |
1267 | int fd1=0, fd2=2; | 1278 | int fd1=0, fd2=2; |
1268 | off_t o = 0; | 1279 | off_t o = 0; |
1269 | size_t s = 5; | 1280 | size_t s = 5; |
1270 | ssize_t r; | 1281 | ssize_t r; |
1271 | r = sendfile (fd1, fd2, &o, s); | 1282 | r = sendfile (fd1, fd2, &o, s); |
1272 | if (r) | 1283 | if (r) |
1273 | empty_func(); | 1284 | empty_func(); |
1274 | ]] | 1285 | ]] |
1275 | ) | 1286 | ) |
1276 | ], | 1287 | ], |
1277 | [ | 1288 | [ |
1278 | AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).]) | 1289 | AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).]) |
1279 | found_sendfile="yes, Linux-style" | 1290 | found_sendfile="yes, Linux-style" |
1280 | AC_MSG_RESULT([[yes]]) | 1291 | AC_MSG_RESULT([[yes]]) |
1281 | AC_CHECK_FUNCS([sendfile64]) | 1292 | AC_CHECK_FUNCS([sendfile64]) |
1282 | ], | 1293 | ], |
1283 | [AC_MSG_RESULT([[no]]) | 1294 | [AC_MSG_RESULT([[no]]) |
1295 | ] | ||
1296 | ) | ||
1284 | ] | 1297 | ] |
1285 | ) | 1298 | ) |
1286 | AS_VAR_IF([[found_sendfile]], [["no"]], | 1299 | AS_VAR_IF([[found_sendfile]], [["no"]], |
@@ -1411,6 +1424,9 @@ ssize_t sendfile(int out_fd, int in_fd, | |||
1411 | LIBS="$SAVE_LIBS" | 1424 | LIBS="$SAVE_LIBS" |
1412 | ] | 1425 | ] |
1413 | ) | 1426 | ) |
1427 | AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]], | ||
1428 | AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]]) | ||
1429 | ) | ||
1414 | 1430 | ||
1415 | # optional: have error messages ? | 1431 | # optional: have error messages ? |
1416 | AC_MSG_CHECKING([[whether to generate error messages]]) | 1432 | AC_MSG_CHECKING([[whether to generate error messages]]) |