-
Notifications
You must be signed in to change notification settings - Fork 16
/
configure.ac
198 lines (174 loc) · 5.42 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
dnl Process this file with autoconf to produce a configure script.
AC_INIT([esmon],[m4_esyscmd(./version-gen.sh)])
AC_CONFIG_SRCDIR(./pyesmon/esmon_install.py)
AC_CONFIG_HEADERS(config.h)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([tar-pax dist-bzip2 foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_LANG(C)
AC_PREFIX_DEFAULT("/usr")
#
# Checks for programs.
#
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_CC_C_O
AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_LEX
AC_PROG_YACC
PKG_PROG_PKG_CONFIG
#
# MB_CHECK_FILE
#
# Check for file existance even when cross compiling
# $1 - file to check
# $2 - do 'yes'
# $3 - do 'no'
#
AC_DEFUN([MB_CHECK_FILE], [
AS_VAR_PUSHDEF([mb_file], [mb_cv_file_$1])dnl
AC_CACHE_CHECK([for $1], mb_file, [
AS_IF([test -r "$1"],
[AS_VAR_SET(mb_file, [yes])],
[AS_VAR_SET(mb_file, [no])])
])
AS_IF([test AS_VAR_GET(mb_file) = yes], [$2], [$3])[]dnl
AS_VAR_POPDEF([mb_file])dnl
]) # MB_CHECK_FILE
#
# MB_ARG_REPLACE_PATH(PACKAGE, PATH)
#
AC_DEFUN([MB_ARG_REPLACE_PATH], [
new_configure_args=
eval set -- $ac_configure_args
for arg; do
case $arg in
--with-[$1]=*)
arg=--with-[$1]=[$2] ;;
*\'*)
arg=$(printf %s\n ["$arg"] | \
sed "s/'/'\\\\\\\\''/g") ;;
esac
dnl AS_VAR_APPEND([new_configure_args], [" '$arg'"])
new_configure_args="$new_configure_args '$arg'"
done
ac_configure_args=$new_configure_args
])
#
# __MB_ARG_CANON_PATH
#
# this is the work-horse of the next function
#
AC_DEFUN([__MB_ARG_CANON_PATH], [
[$3]=$(readlink -f $with_$2)
MB_ARG_REPLACE_PATH([$1], $[$3])
])
#
# MB_ARG_CANON_PATH
#
# a front-end for the above function that transforms - and . in the
# PACKAGE portion of --with-PACKAGE into _ suitable for variable names
#
AC_DEFUN([MB_ARG_CANON_PATH], [
__MB_ARG_CANON_PATH([$1], m4_translit([$1], [-.], [__]), [$2])
])
# -------- check for distro version --------
AC_MSG_CHECKING([for distro version])
DISTRO=$(sh detect-distro.sh)
DISTRO_NAME=$(echo $DISTRO | awk -F '-' '{print $1}')
if [[[ "$DISTRO_NAME" != "rhel" ]]]; then
AC_MSG_ERROR([$DISTRO_NAME is not a supported distro.])
fi
DISTRO_RELEASE=$(echo $DISTRO | awk -F 'rhel-' '{print $2}' | awk -F '.' '{print $1}')
AC_MSG_RESULT([$DISTRO_RELEASE])
AC_SUBST(DISTRO_RELEASE)
# ------- check for target_cpu --------
AC_SUBST(target_cpu)
# -------- check for package version --------
AC_MSG_CHECKING([for package version])
MONSYSTEM_PKGVER=$(sh ./version-gen.sh)
AC_MSG_RESULT([$MONSYSTEM_PKGVER])
AC_SUBST(MONSYSTEM_PKGVER)
# -------- check whether to only build XML definition rpm --------
AC_MSG_CHECKING([Only build XML rpm])
AC_ARG_ENABLE([xmlonly],
AC_HELP_STRING([--enable-xmlonly],
[only build xml definition rpm]),
[], [enable_xmlonly="no"])
AC_MSG_RESULT([$enable_xmlonly])
AM_CONDITIONAL([XMLONLY], [test x$enable_xmlonly = xyes])
# -------- check whether to enable XML test --------
AC_MSG_CHECKING([whether to enable XML test])
AC_ARG_ENABLE([test],
AC_HELP_STRING([--disable-test],
[disable test]),
[], [enable_test="no"])
AC_MSG_RESULT([$enable_test])
if [[[ $enable_xmlonly == 'no' ]]]; then
# -------- check for cached ISO --------
AC_MSG_CHECKING([for cached ISO])
AC_ARG_WITH([cached_iso],
AC_HELP_STRING([--with-cached-iso=path],
[set path to cached ISO]),
[MB_ARG_CANON_PATH([cached-iso], [CACHED_ISO_PATH])],
[])
AC_MSG_RESULT([$CACHED_ISO_PATH])
AC_SUBST(CACHED_ISO_PATH)
MB_CHECK_FILE([$CACHED_ISO_PATH], [],
[AC_MSG_ERROR([cached ISO dir $CACHED_ISO_PATH could not be found.])])
fi
# -------- check for xml_definition version --------
AC_MSG_CHECKING([for xml_definition version])
XML_DEFINITION_REV=$(git rev-parse --short HEAD)
if [[[ $? -ne 0 ]]]; then
AC_MSG_ERROR([monsystem_package is not a git repository.])
fi
AC_SUBST(XML_DEFINITION_REV)
XML_DEFINITION_VERSION=$(awk '/^Version/{print $2}' \
xml_definition/xml_definition.spec)
AC_MSG_RESULT([$XML_DEFINITION_VERSION])
AC_SUBST(XML_DEFINITION_VERSION)
# -------- check for xml_definition release --------
AC_MSG_CHECKING([for xml_definition release])
XML_DEFINITION_RELEASE=$(awk '/^Release/{print $2}' \
xml_definition/xml_definition.spec | \
sed -e "s|%{?dist}||g" -e "s|%{?rev}|${XML_DEFINITION_REV}|g")
AC_MSG_RESULT([$XML_DEFINITION_RELEASE])
AC_SUBST(XML_DEFINITION_RELEASE)
# -------- check for xml_definition RPM --------
AC_MSG_CHECKING([for xml_definition RPM])
XML_DEFINITION_RPM=xml_definition-${XML_DEFINITION_VERSION}-${XML_DEFINITION_RELEASE}.noarch.rpm
AC_MSG_RESULT([$XML_DEFINITION_RPM])
AC_SUBST(XML_DEFINITION_RPM)
# ------- check for python --------
AC_CHECK_PROGS([PYTHON], [python3 python-3 python], [])
if test "x$PYTHON" = "x"; then
AC_MSG_ERROR([Python3 is needed for test of xml_definition. Install python.])
fi
# ------- check for pylint --------
AC_CHECK_PROGS([PYLINT], [pylint3 pylint-3 pylint], [])
if test "x$PYLINT" = "x"; then
AC_MSG_ERROR([pylint is needed to check python coding style. Install pylint.])
fi
# ------- check for ElementTree of python --------
AC_MSG_CHECKING([for ElementTree of python])
if [[[ "${DISTRO_RELEASE}" != "5" ]]]; then
$PYTHON -c "import xml.etree.ElementTree";
if [[[ $? -ne 0 ]]]; then
AC_MSG_ERROR([ElementTree is need for test of xml files.])
AC_MSG_RESULT([no])
fi
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([skipped])
fi
ESMON_RELEASE="7"
AC_DEFINE_UNQUOTED(RELEASE, "$ESMON_RELEASE", [release info] )
AC_SUBST(ESMON_RELEASE)
AC_CONFIG_FILES([Makefile esmon.spec xml_definition/Makefile])
AC_OUTPUT