Tizen 2.0 Release
[external/tizen-coreutils.git] / m4 / jm-macros.m4
1 #serial 105   -*- autoconf -*-
2
3 dnl Misc type-related macros for coreutils.
4
5 # Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
6 # Foundation, Inc.
7
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 # Written by Jim Meyering.
23
24 AC_DEFUN([coreutils_MACROS],
25 [
26   GNU_PACKAGE="GNU $PACKAGE"
27   AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
28     [The concatenation of the strings `GNU ', and PACKAGE.])
29   AC_SUBST(GNU_PACKAGE)
30
31   AM_MISSING_PROG(HELP2MAN, help2man)
32   AC_SUBST(OPTIONAL_BIN_PROGS)
33   AC_SUBST(MAN)
34   AC_SUBST(DF_PROG)
35
36   dnl This macro actually runs replacement code.  See isc-posix.m4.
37   AC_REQUIRE([AC_ISC_POSIX])dnl
38
39   gl_CHECK_ALL_TYPES
40
41   AC_REQUIRE([gl_CHECK_DECLS])
42
43   AC_REQUIRE([gl_PREREQ])
44
45   AC_REQUIRE([AC_FUNC_FSEEKO])
46
47   # By default, argmatch should fail calling usage (1).
48   AC_DEFINE(ARGMATCH_DIE, [usage (1)],
49             [Define to the function xargmatch calls on failures.])
50   AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
51             [Define to the declaration of the xargmatch failure function.])
52
53   # used by ls
54   AC_REQUIRE([gl_CLOCK_TIME])
55   # used by shred
56   AC_CHECK_FUNCS_ONCE(directio)
57
58   AC_CHECK_FUNCS_ONCE( \
59     endgrent \
60     endpwent \
61     fchown \
62     fchmod \
63     ftruncate \
64     iswspace \
65     mkfifo \
66     mbrlen \
67     setgroups \
68     sethostname \
69     siginterrupt \
70     sync \
71     sysctl \
72     sysinfo \
73     tcgetpgrp \
74   )
75
76   dnl This can't use AC_REQUIRE; I'm not quite sure why.
77   cu_PREREQ_STAT_PROG
78
79   # for dd.c and shred.c
80   coreutils_saved_libs=$LIBS
81     AC_SEARCH_LIBS([fdatasync], [rt posix4],
82                    [test "$ac_cv_search_fdatasync" = "none required" ||
83                     LIB_FDATASYNC=$ac_cv_search_fdatasync])
84     AC_SUBST([LIB_FDATASYNC])
85     AC_CHECK_FUNCS(fdatasync)
86   LIBS=$coreutils_saved_libs
87
88   # See if linking `seq' requires -lm.
89   # It does on nearly every system.  The single exception (so far) is
90   # BeOS which has all the math functions in the normal runtime library
91   # and doesn't have a separate math library.
92
93   AC_SUBST(SEQ_LIBM)
94   ac_seq_body='
95      static double x, y;
96      x = floor (x);
97      x = rint (x);
98      x = modf (x, &y);'
99   AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
100     [ac_seq_save_LIBS="$LIBS"
101      LIBS="$LIBS -lm"
102      AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
103      LIBS="$ac_seq_save_LIBS"
104     ])
105
106   AC_REQUIRE([AM_LANGINFO_CODESET])
107
108   # Build df only if there's a point to it.
109   if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
110     DF_PROG='df$(EXEEXT)'
111   fi
112 ])
113
114 AC_DEFUN([gl_CHECK_ALL_HEADERS],
115 [
116   AC_CHECK_HEADERS_ONCE( \
117     hurd.h \
118     paths.h \
119     priv.h \
120     stropts.h \
121     sys/ioctl.h \
122     sys/param.h \
123     sys/resource.h \
124     sys/systeminfo.h \
125     sys/time.h \
126     sys/wait.h \
127     syslog.h \
128     termios.h \
129   )
130   AC_CHECK_HEADERS(sys/sysctl.h, [], [],
131     [AC_INCLUDES_DEFAULT
132      [#if HAVE_SYS_PARAM_H
133        #include <sys/param.h>
134       #endif]])
135 ])
136
137 # This macro must be invoked before any tests that run the compiler.
138 AC_DEFUN([gl_CHECK_ALL_TYPES],
139 [
140   dnl This test must come as early as possible after the compiler configuration
141   dnl tests, because the choice of the file model can (in principle) affect
142   dnl whether functions and headers are available, whether they work, etc.
143   AC_REQUIRE([AC_SYS_LARGEFILE])
144
145   dnl This test must precede tests of compiler characteristics like
146   dnl that for the inline keyword, since it may change the degree to
147   dnl which the compiler supports such features.
148   AC_REQUIRE([AM_C_PROTOTYPES])
149
150   dnl Checks for typedefs, structures, and compiler characteristics.
151   AC_REQUIRE([AC_C_BIGENDIAN])
152   AC_REQUIRE([AC_C_VOLATILE])
153   AC_REQUIRE([AC_C_INLINE])
154   AC_REQUIRE([AC_C_LONG_DOUBLE])
155   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
156
157   AC_REQUIRE([gl_CHECK_ALL_HEADERS])
158   AC_CHECK_MEMBERS(
159     [struct stat.st_author],,,
160     [$ac_includes_default
161 #include <sys/stat.h>
162   ])
163   AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
164
165   AC_REQUIRE([AC_TYPE_GETGROUPS])
166   AC_REQUIRE([AC_TYPE_MBSTATE_T])
167   AC_REQUIRE([AC_TYPE_MODE_T])
168   AC_REQUIRE([AC_TYPE_OFF_T])
169   AC_REQUIRE([AC_TYPE_PID_T])
170   AC_REQUIRE([AC_TYPE_SIZE_T])
171   AC_REQUIRE([AC_TYPE_UID_T])
172   AC_CHECK_TYPE(ino_t, unsigned long int)
173
174   dnl This relies on the fact that Autoconf's implementation of
175   dnl AC_CHECK_TYPE checks includes unistd.h.
176   AC_CHECK_TYPE(major_t, unsigned int)
177   AC_CHECK_TYPE(minor_t, unsigned int)
178
179   AC_REQUIRE([AC_HEADER_MAJOR])
180 ])