Tizen 2.0 Release
[framework/base/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     if test -z "$MAKE"; then
40         AC_PATH_PROG(MAKE, gmake,, /usr/bin:/usr/local/bin:/usr/freeware/bin)
41     fi
42     if test -z "$MAKE"; then
43         AC_PATH_PROG(MAKE, make,, /usr/bin)
44     fi
45     make=$MAKE
46     AC_SUBST(make)
47     AC_PACKAGE_NEED_UTILITY($1, "$make", make, [GNU make])
48
49     if test -z "$TAR"; then
50         AC_PATH_PROG(TAR, tar,, /usr/freeware/bin:/bin:/usr/local/bin:/usr/bin)
51     fi
52     tar=$TAR
53     AC_SUBST(tar)
54     if test -z "$ZIP"; then
55         AC_PATH_PROG(ZIP, gzip,, /bin:/usr/bin:/usr/local/bin:/usr/freeware/bin)
56     fi
57
58     zip=$ZIP
59     AC_SUBST(zip)
60
61     if test -z "$MAKEDEPEND"; then
62         AC_PATH_PROG(MAKEDEPEND, makedepend, /bin/true)
63     fi
64     makedepend=$MAKEDEPEND
65     AC_SUBST(makedepend)
66
67     if test -z "$AWK"; then
68         AC_PATH_PROG(AWK, awk,, /bin:/usr/bin)
69     fi
70     awk=$AWK
71     AC_SUBST(awk)
72
73     if test -z "$SED"; then
74         AC_PATH_PROG(SED, sed,, /bin:/usr/bin)
75     fi
76     sed=$SED
77     AC_SUBST(sed)
78
79     if test -z "$ECHO"; then
80         AC_PATH_PROG(ECHO, echo,, /bin:/usr/bin)
81     fi
82     echo=$ECHO
83     AC_SUBST(echo)
84
85     if test -z "$SORT"; then
86         AC_PATH_PROG(SORT, sort,, /bin:/usr/bin)
87     fi
88     sort=$SORT
89     AC_SUBST(sort)
90
91     dnl check if symbolic links are supported
92     AC_PROG_LN_S
93
94     if test "$enable_gettext" = yes; then
95         if test -z "$MSGFMT"; then
96                 AC_PATH_PROG(MSGFMT, msgfmt,, /usr/bin:/usr/local/bin:/usr/freeware/bin)
97         fi
98         msgfmt=$MSGFMT
99         AC_SUBST(msgfmt)
100         AC_PACKAGE_NEED_UTILITY($1, "$msgfmt", msgfmt, gettext)
101
102         if test -z "$MSGMERGE"; then
103                 AC_PATH_PROG(MSGMERGE, msgmerge,, /usr/bin:/usr/local/bin:/usr/freeware/bin)
104         fi
105         msgmerge=$MSGMERGE
106         AC_SUBST(msgmerge)
107         AC_PACKAGE_NEED_UTILITY($1, "$msgmerge", msgmerge, gettext)
108
109         if test -z "$XGETTEXT"; then
110                 AC_PATH_PROG(XGETTEXT, xgettext,, /usr/bin:/usr/local/bin:/usr/freeware/bin)
111         fi
112         xgettext=$XGETTEXT
113         AC_SUBST(xgettext)
114         AC_PACKAGE_NEED_UTILITY($1, "$xgettext", xgettext, gettext)
115
116         AC_DEFINE([ENABLE_GETTEXT], 1, [enable gettext])
117     fi
118
119     if test -z "$RPM"; then
120         AC_PATH_PROG(RPM, rpm,, /bin:/usr/bin:/usr/freeware/bin)
121     fi
122     rpm=$RPM
123     AC_SUBST(rpm)
124
125     dnl .. and what version is rpm
126     rpm_version=0
127     test -n "$RPM" && test -x "$RPM" && rpm_version=`$RPM --version \
128                         | awk '{print $NF}' | awk -F. '{V=1; print $V}'`
129     AC_SUBST(rpm_version)
130     dnl At some point in rpm 4.0, rpm can no longer build rpms, and
131     dnl rpmbuild is needed (rpmbuild may go way back; not sure)
132     dnl So, if rpm version >= 4.0, look for rpmbuild.  Otherwise build w/ rpm
133     if test $rpm_version -ge 4; then
134         AC_PATH_PROG(RPMBUILD, rpmbuild)
135         rpmbuild=$RPMBUILD
136     else
137         rpmbuild=$RPM
138     fi
139     AC_SUBST(rpmbuild)
140   ])