[lftp-devel] Fix posix_fallocate m4 check for cross-compilation.

2013-11-26 Thread Arnaud Rébillout
Dear maintainer,

I recently compiled lftp for an ARM architecture.

At first, the cross-compilation didn't work, because of the m4 macro 
LFTP_POSIX_FALLOCATE_CHECK.
More precisely, the AC_TRY_RUN part, which doesn't have the fourth argument 
action-if-cross-compiling.

When cross-compiling, we can't run code, but we can at least compile it. This 
is especially important for uClibc.
The current 0.9.33.2 version doesn't provide posix_fallocate. But, if I build 
in the latest version of buildroot,
the uClibc is patched to add support for posix_fallocate.
So, the situation is a little bit tricky, we can't know for sure if 
posix_fallocate is available until we compile it.

To solve this situation as smoothly as possible, I propose to add a test in 
case of cross-compilation:
the test simply tries a compilation, and if it's OK, we assume posix_fallocate 
works.

The patch comes in the next mail (if I manage to use git send-email correctly).
Feel free to tell me what you think about it.

Best regards,
Arnaud
___
lftp-devel mailing list
lftp-devel@uniyar.ac.ru
http://univ.uniyar.ac.ru/mailman/listinfo/lftp-devel


[lftp-devel] [PATCH] Fix posix_fallocate m4 check for cross-compilation.

2013-11-26 Thread Arnaud Rébillout
If we're cross-compiling, we can't test if the code run, we can only
test that it compiles and links. If it does, assume posix_fallocate
works, because cross-compilation for AIX or old glibc is unlikely.

Signed-off-by: Arnaud Rébillout rebill...@syscom.ch
---
 m4/lftp.m4 | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/m4/lftp.m4 b/m4/lftp.m4
index 6d7ad9c..b38364d 100644
--- a/m4/lftp.m4
+++ b/m4/lftp.m4
@@ -271,6 +271,21 @@ AC_DEFUN([LFTP_POSIX_FALLOCATE_CHECK],[
i_cv_posix_fallocate_works=yes
  ], [
i_cv_posix_fallocate_works=no
+ ], [
+   dnl * Cross-compilation: we can only test if the code compiles and 
links.
+   dnl * If it does, assume that it works, because cross-compilation for 
AIX or old glibc is unlikely.
+   AC_CACHE_VAL([i_cv_posix_fallocate_works],[
+ AC_LINK_IFELSE([
+   #include fcntl.h
+   int main() {
+ posix_fallocate(0, 0, 0);
+   }
+ ], [
+   i_cv_posix_fallocate_works=yes
+ ], [
+   i_cv_posix_fallocate_works=no
+ ])
+   ])
  ])
])
if test x$i_cv_posix_fallocate_works = xyes; then
-- 
1.8.4.4

___
lftp-devel mailing list
lftp-devel@uniyar.ac.ru
http://univ.uniyar.ac.ru/mailman/listinfo/lftp-devel