Imported Upstream version 2.2.51
[platform/upstream/acl.git] / m4 / package_utilies.m4
1 dnl Copyright (C) 2003, 2004, 2005, 2006, 2007  Silicon Graphics, Inc.
2 dnl
3 dnl This program is free software: you can redistribute it and/or modify it
4 dnl under the terms of the GNU General Public License as published by
5 dnl the Free Software Foundation, either version 2 of the License, or
6 dnl (at your option) any later version.
7 dnl
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 dnl GNU General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 #
16 # Check for specified utility (env var) - if unset, fail.
17 #
18 AC_DEFUN([AC_PACKAGE_NEED_UTILITY],
19   [ if test -z "$2"; then
20         echo
21         echo FATAL ERROR: $3 does not seem to be installed.
22         echo $1 cannot be built without a working $4 installation.
23         exit 1
24     fi
25   ])
26
27 #
28 # Generic macro, sets up all of the global build variables.
29 # The following environment variables may be set to override defaults:
30 #  CC MAKE LIBTOOL TAR ZIP MAKEDEPEND AWK SED ECHO SORT
31 #  MSGFMT MSGMERGE XGETTEXT RPM
32 #
33 AC_DEFUN([AC_PACKAGE_UTILITIES],
34   [ AC_PROG_CC
35     cc="$CC"
36     AC_SUBST(cc)
37     AC_PACKAGE_NEED_UTILITY($1, "$cc", cc, [C compiler])
38
39     search_path="$PATH$PATH_SEPARATOR/usr/freeware/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR/usr/local/bin"
40
41     AC_PATH_PROGS(MAKE, gmake make,, $search_path)
42     make=$MAKE
43     AC_SUBST(make)
44     AC_PACKAGE_NEED_UTILITY($1, "$make", make, [GNU make])
45
46     AC_PATH_PROG(TAR, tar,, $search_path)
47     tar=$TAR
48     AC_SUBST(tar)
49
50     AC_PATH_PROG(ZIP, gzip,, $search_path)
51     zip=$ZIP
52     AC_SUBST(zip)
53
54     AC_PATH_PROG(MAKEDEPEND, makedepend, /bin/true)
55     makedepend=$MAKEDEPEND
56     AC_SUBST(makedepend)
57
58     AC_PATH_PROG(AWK, awk,, $search_path)
59     awk=$AWK
60     AC_SUBST(awk)
61
62     AC_PATH_PROG(SED, sed,, $search_path)
63     sed=$SED
64     AC_SUBST(sed)
65
66     AC_PATH_PROG(ECHO, echo,, $search_path)
67     echo=$ECHO
68     AC_SUBST(echo)
69
70     AC_PATH_PROG(SORT, sort,, $search_path)
71     sort=$SORT
72     AC_SUBST(sort)
73
74     dnl check if symbolic links are supported
75     AC_PROG_LN_S
76
77     if test "$enable_gettext" = yes; then
78         AC_PATH_PROG(MSGFMT, msgfmt,, $search_path)
79         msgfmt=$MSGFMT
80         AC_SUBST(msgfmt)
81         AC_PACKAGE_NEED_UTILITY($1, "$msgfmt", msgfmt, gettext)
82
83         AC_PATH_PROG(MSGMERGE, msgmerge,, $search_path)
84         msgmerge=$MSGMERGE
85         AC_SUBST(msgmerge)
86         AC_PACKAGE_NEED_UTILITY($1, "$msgmerge", msgmerge, gettext)
87
88         AC_PATH_PROG(XGETTEXT, xgettext,, $search_path)
89         xgettext=$XGETTEXT
90         AC_SUBST(xgettext)
91         AC_PACKAGE_NEED_UTILITY($1, "$xgettext", xgettext, gettext)
92
93         AC_DEFINE([ENABLE_GETTEXT], 1, [enable gettext])
94     fi
95
96     AC_PATH_PROG(RPM, rpm,, $search_path)
97     rpm=$RPM
98     AC_SUBST(rpm)
99
100     dnl .. and what version is rpm
101     rpm_version=0
102     test -n "$RPM" && test -x "$RPM" && rpm_version=`$RPM --version \
103                         | awk '{print $NF}' | awk -F. '{V=1; print $V}'`
104     AC_SUBST(rpm_version)
105     dnl At some point in rpm 4.0, rpm can no longer build rpms, and
106     dnl rpmbuild is needed (rpmbuild may go way back; not sure)
107     dnl So, if rpm version >= 4.0, look for rpmbuild.  Otherwise build w/ rpm
108     if test $rpm_version -ge 4; then
109         AC_PATH_PROG(RPMBUILD, rpmbuild)
110         rpmbuild=$RPMBUILD
111     else
112         rpmbuild=$RPM
113     fi
114     AC_SUBST(rpmbuild)
115   ])