build: remove IRIX-specific build logic
[xfstests-dev.git] / m4 / package_utilies.m4
1 #
2 # Check for specified utility (env var) - if unset, fail.
3
4 AC_DEFUN([AC_PACKAGE_NEED_UTILITY],
5   [ if test -z "$2"; then
6         echo
7         echo FATAL ERROR: $3 does not seem to be installed.
8         echo $1 cannot be built without a working $4 installation.
9         exit 1
10     fi
11   ])
12
13 #
14 #check compiler can generate dependencies
15 #
16 AC_DEFUN([AC_PACKAGE_GCC_DEPS],
17   [AC_CACHE_CHECK(whether gcc -MM is supported,
18                   ac_cv_gcc_nodeps,
19                   [cat > conftest.c <<EOF
20                    #include <stdio.h>
21                    int main() { exit(0); }
22 EOF
23                   ac_cv_gcc_nodeps=no
24                   if ${CC} -MM conftest.c >/dev/null 2>&1; then
25                      ac_cv_gcc_nodeps=yes
26                   fi
27                   rm -f conftest.c a.out
28                   ])
29   ])
30
31 #
32 # Generic macro, sets up all of the global build variables.
33 # The following environment variables may be set to override defaults:
34 #  CC MAKE LIBTOOL TAR ZIP eMAKEDEPEND AWK SED ECHO SORT
35 #  MSGFMT MSGMERGE RPM
36 #
37 AC_DEFUN([AC_PACKAGE_UTILITIES],
38   [ AC_PROG_CC
39     cc="$CC"
40     AC_SUBST(cc)
41     AC_PACKAGE_NEED_UTILITY($1, "$cc", cc, [C compiler])
42
43     if test -z "$MAKE"; then
44         AC_PATH_PROG(MAKE, gmake,, /usr/bin:/usr/local/bin)
45     fi
46     if test -z "$MAKE"; then
47         AC_PATH_PROG(MAKE, make,, /usr/bin)
48     fi
49     make=$MAKE
50     AC_SUBST(make)
51     AC_PACKAGE_NEED_UTILITY($1, "$make", make, [GNU make])
52
53     if test -z "$LIBTOOL"; then
54         AC_PATH_PROG(LIBTOOL, glibtool,, /usr/bin)
55     fi
56     if test -z "$LIBTOOL"; then
57         AC_PATH_PROG(LIBTOOL, libtool,, /usr/bin:/usr/local/bin)
58     fi
59     libtool=$LIBTOOL
60     AC_SUBST(libtool)
61     AC_PACKAGE_NEED_UTILITY($1, "$libtool", libtool, [GNU libtool])
62
63     if test -z "$TAR"; then
64         AC_PATH_PROG(TAR, tar,, /bin:/usr/local/bin:/usr/bin)
65     fi
66     tar=$TAR
67     AC_SUBST(tar)
68     if test -z "$ZIP"; then
69         AC_PATH_PROG(ZIP, gzip,, /bin:/usr/bin:/usr/local/bin)
70     fi
71
72     zip=$ZIP
73     AC_SUBST(zip)
74
75     AC_PACKAGE_GCC_DEPS()
76     makedepend="$cc -MM"
77     if test $ac_cv_gcc_nodeps = no; then
78         makedepend=/bin/true
79     fi
80     AC_SUBST(makedepend)
81
82     if test -z "$AWK"; then
83         AC_PATH_PROG(AWK, awk,, /bin:/usr/bin)
84     fi
85     awk=$AWK
86     AC_SUBST(awk)
87
88     if test -z "$SED"; then
89         AC_PATH_PROG(SED, sed,, /bin:/usr/bin)
90     fi
91     sed=$SED
92     AC_SUBST(sed)
93
94     if test -z "$ECHO"; then
95         AC_PATH_PROG(ECHO, echo,, /bin:/usr/bin)
96     fi
97     echo=$ECHO
98     AC_SUBST(echo)
99
100     if test -z "$SORT"; then
101         AC_PATH_PROG(SORT, sort,, /bin:/usr/bin)
102     fi
103     sort=$SORT
104     AC_SUBST(sort)
105
106     dnl check if symbolic links are supported
107     AC_PROG_LN_S
108
109     if test "$enable_gettext" = yes; then
110         if test -z "$MSGFMT"; then
111                 AC_PATH_PROG(MSGFMT, msgfmt,, /usr/bin:/usr/local/bin)
112         fi
113         msgfmt=$MSGFMT
114         AC_SUBST(msgfmt)
115         AC_PACKAGE_NEED_UTILITY($1, "$msgfmt", msgfmt, gettext)
116
117         if test -z "$MSGMERGE"; then
118                 AC_PATH_PROG(MSGMERGE, msgmerge,, /usr/bin:/usr/local/bin)
119         fi
120         msgmerge=$MSGMERGE
121         AC_SUBST(msgmerge)
122         AC_PACKAGE_NEED_UTILITY($1, "$msgmerge", msgmerge, gettext)
123     fi
124
125     if test -z "$RPM"; then
126         AC_PATH_PROG(RPM, rpm,, /bin:/usr/bin)
127     fi
128     rpm=$RPM
129     AC_SUBST(rpm)
130
131     dnl .. and what version is rpm
132     rpm_version=0
133     test -n "$RPM" && test -x "$RPM" && rpm_version=`$RPM --version \
134                         | awk '{print $NF}' | awk -F. '{V=1; print $V}'`
135     AC_SUBST(rpm_version)
136     dnl At some point in rpm 4.0, rpm can no longer build rpms, and
137     dnl rpmbuild is needed (rpmbuild may go way back; not sure)
138     dnl So, if rpm version >= 4.0, look for rpmbuild.  Otherwise build w/ rpm
139     if test $rpm_version -ge 4; then
140         AC_PATH_PROG(RPMBUILD, rpmbuild)
141         rpmbuild=$RPMBUILD
142     else
143         rpmbuild=$RPM
144     fi
145     AC_SUBST(rpmbuild)
146   ])