Mercurial > hg > octave-nkf > gnulib-hg
annotate m4/getline.m4 @ 7148:06ddea502cf5
.
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Wed, 16 Aug 2006 08:04:38 +0000 |
parents | 518e17651b9d |
children | d445de86b311 |
rev | line source |
---|---|
7016
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
1 # getline.m4 serial 14 |
4166
053cd474cdc5
(gl_PREREQ_GETLINE): Require AC_HEADER_STDC.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
2 |
7016
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
3 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software |
4166
053cd474cdc5
(gl_PREREQ_GETLINE): Require AC_HEADER_STDC.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
4 dnl Foundation, Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4809
diff
changeset
|
5 dnl |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4809
diff
changeset
|
6 dnl This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4809
diff
changeset
|
7 dnl gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4809
diff
changeset
|
8 dnl with or without modifications, as long as this notice is preserved. |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
9 |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
10 AC_PREREQ(2.52) |
820 | 11 |
12 dnl See if there's a working, system-supplied version of the getline function. | |
1095 | 13 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems |
820 | 14 dnl have a function by that name in -linet that doesn't have anything |
15 dnl to do with the function we need. | |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
16 AC_DEFUN([gl_FUNC_GETLINE], |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
17 [ |
5721
abd018cd6020
Use AC_LIBSOURCES and AC_LIBOBJ to indicate source and object files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5611
diff
changeset
|
18 AC_LIBSOURCES([getline.c, getline.h]) |
abd018cd6020
Use AC_LIBSOURCES and AC_LIBOBJ to indicate source and object files.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5611
diff
changeset
|
19 |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
20 dnl Persuade glibc <stdio.h> to declare getline(). |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
21 AC_REQUIRE([AC_GNU_SOURCE]) |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
22 |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
23 AC_CHECK_DECLS([getline]) |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
24 |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
25 gl_getline_needs_run_time_check=no |
820 | 26 AC_CHECK_FUNC(getline, |
27 dnl Found it in some library. Verify that it works. | |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
28 gl_getline_needs_run_time_check=yes, |
820 | 29 am_cv_func_working_getline=no) |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
30 if test $gl_getline_needs_run_time_check = yes; then |
820 | 31 AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline, |
1912
14abc42d2378
Rename test file from conftestdata to conftest.data
Jim Meyering <jim@meyering.net>
parents:
1702
diff
changeset
|
32 [echo fooN |tr -d '\012'|tr N '\012' > conftest.data |
820 | 33 AC_TRY_RUN([ |
34 # include <stdio.h> | |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
35 # include <stdlib.h> |
3314
0cbeff087afe
(AM_FUNC_GETLINE): Quote first arg of AC_DEFUN.
Jim Meyering <jim@meyering.net>
parents:
2685
diff
changeset
|
36 # include <string.h> |
820 | 37 int main () |
38 { /* Based on a test program from Karl Heuer. */ | |
39 char *line = NULL; | |
40 size_t siz = 0; | |
41 int len; | |
1912
14abc42d2378
Rename test file from conftestdata to conftest.data
Jim Meyering <jim@meyering.net>
parents:
1702
diff
changeset
|
42 FILE *in = fopen ("./conftest.data", "r"); |
820 | 43 if (!in) |
44 return 1; | |
45 len = getline (&line, &siz, in); | |
46 exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1); | |
47 } | |
48 ], am_cv_func_working_getline=yes dnl The library version works. | |
49 , am_cv_func_working_getline=no dnl The library version does NOT work. | |
7016
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
50 , dnl We're cross compiling. Assume it works on glibc2 systems. |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
51 [AC_EGREP_CPP([Lucky GNU user], |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
52 [ |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
53 #include <features.h> |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
54 #ifdef __GNU_LIBRARY__ |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
55 #if (__GLIBC__ >= 2) |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
56 Lucky GNU user |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
57 #endif |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
58 #endif |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
59 ], |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
60 [am_cv_func_working_getline=yes], |
518e17651b9d
Avoid causing trouble in relocatable.c.
Bruno Haible <bruno@clisp.org>
parents:
6011
diff
changeset
|
61 [am_cv_func_working_getline=no])] |
820 | 62 )]) |
63 fi | |
64 | |
65 if test $am_cv_func_working_getline = no; then | |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
66 dnl We must choose a different name for our function, since on ELF systems |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
67 dnl a broken getline() in libc.so would override our getline() in |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
68 dnl libgettextlib.so. |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
69 AC_DEFINE([getline], [gnu_getline], |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
70 [Define to a replacement function name for getline().]) |
2685 | 71 AC_LIBOBJ(getline) |
4809
cde3aec825b9
Don't include getndelim2.o twice into LIBOBJS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
72 |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
73 gl_PREREQ_GETLINE |
820 | 74 fi |
75 ]) | |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
76 |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
77 # Prerequisites of lib/getline.c. |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
78 AC_DEFUN([gl_PREREQ_GETLINE], |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
79 [ |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
5721
diff
changeset
|
80 gl_FUNC_GETDELIM |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3314
diff
changeset
|
81 ]) |