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