-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathconfigure.ac
More file actions
214 lines (180 loc) · 9.87 KB
/
configure.ac
File metadata and controls
214 lines (180 loc) · 9.87 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
dnl +------------------------------------------------------------------+
dnl | Network UPS Tools - Website: configure.ac |
dnl +------------------------------------------------------------------+
dnl Note: funny markup in the next line is m4-escaped square braces
dnl for glob-expression text in an m4 macro
AC_INIT(nut_website, m4_esyscmd_s(cd nut && (test -x "`dirname \"$0\"`/tools/gitlog2version.sh" && NUT_VERSION_QUERY=VER50 "`dirname \"$0\"`/tools/gitlog2version.sh" || (git describe --tags --match 'v@<:@0-9@:>@*.@<:@0-9@:>@*.@<:@0-9@:>@' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' || git describe --tags --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*' ) 2>/dev/null | sed -e 's/^v//' -e 's/-\(1\|2\|3\|4\|5\|6\|7\|8\|9\)\(1\|2\|3\|4\|5\|6\|7\|8\|9\|0\)*@<:@+-@:>@g.*//')))
dnl we use macros like AC_CONFIG_MACRO_DIRS (multiple) introduced in 2.70
dnl but apparently backported to 2.69 in some distros (with aclocal-1.16)
AC_PREREQ([2.69])
dnl Detect usable grep and egrep as soon as possible, to let called scripts
dnl use them. Unfortunately, init must happen before macros that output text,
dnl so the first call above misses out on the detected values.
AC_PROG_EGREP
export GREP
export EGREP
AC_CONFIG_MACRO_DIRS([m4 nut/m4])
echo "Network UPS Tools - Website (most recently tagged NUT version ${PACKAGE_VERSION})"
AM_INIT_AUTOMAKE([foreign no-dist])
NUT_WITH_DOC="--with-doc"
AC_ARG_WITH([doc],
[AS_HELP_STRING([--with-doc(=...)], [options for documentation generation, passed to NUT sources (should only be constrained for e.g. spellcheck on systems that can not build PDF)])],
[AS_CASE(["${withval}"],
[''], [],
[NUT_WITH_DOC="--with-doc=${withval}"]
)],
[]
)
dnl NOTE: Macro seems to have some issues carrying over whitespace after
dnl the "--with-doc" entry if pretty whitespace is applied to finish the
dnl code block (end of line, indentations etc). So we use none here!
AX_SUBDIRS_CONFIGURE([nut],
[[--without-all], [--without-dev], [--without-cgi], [--without-ssl], [${NUT_WITH_DOC}], [--enable-docs-man-for-progs-built-only=no]])
dnl ----------------------------------------------------------------------
OUTDIR_BASE="output"
AC_ARG_WITH(outdir-base,
[AS_HELP_STRING([--with-outdir-base=PATH], [base location for current website build (e.g. 'output'), note NUT_HISTORIC_RELEASE would be in a subdirectory])],
[AS_CASE(["${withval}"],
[''], [OUTDIR_BASE="output"],
[OUTDIR_BASE="${withval}"]
)],
[]
)
AC_SUBST([OUTDIR_BASE])
AM_CONDITIONAL([WITH_CUSTOM_OUTDIR_BASE], [test x"${OUTDIR_BASE}" != "xoutput"])
dnl # Not defaulting NUT_HISTORIC_RELEASE as it may be just exported by caller
AC_ARG_WITH(NUT_HISTORIC_RELEASE,
[AS_HELP_STRING([--with-NUT_HISTORIC_RELEASE=GITTAG], [enable page marking for old release (e.g. 'v2.7.4') and impact actual sub-location for current website build])],
[AS_CASE(["${withval}"],
[''], [],
[NUT_HISTORIC_RELEASE="${withval}"]
)],
[]
)
AC_SUBST([NUT_HISTORIC_RELEASE])
AM_CONDITIONAL([WITH_NUT_HISTORIC_RELEASE], [test x"${NUT_HISTORIC_RELEASE}" != x])
dnl Check for AsciiDoc (using NUT source's m4 scripts)
NUT_CHECK_ASCIIDOC
AS_IF([test -z "${nut_have_asciidoc}"],[
AC_MSG_CHECKING([if asciidoc version can build website (minimum required 8.6.3)])
AX_COMPARE_VERSION([${ASCIIDOC_VERSION}], [ge], [8.6.3], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR(["Unable to build website: check asciidoc!"])
])
AC_MSG_CHECKING([if a2x version can build website (minimum required 8.6.3)])
AX_COMPARE_VERSION([${A2X_VERSION}], [ge], [8.6.3], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR(["Unable to build website: check a2x!"])
])
AC_MSG_CHECKING([if dblatex version can build website (minimum required 0.2.5)])
AX_COMPARE_VERSION([${DBLATEX_VERSION}], [ge], [0.2.5], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR(["Unable to build website: check dblatex!"])
])
], [AC_MSG_NOTICE([Newer NUT sources are in use and suitability of asciidoc and other tools was already tested])
AS_IF([test "${nut_have_asciidoc}" = "no"], [
AC_MSG_ERROR(["Unable to build website: check asciidoc and other tools versions!"])
])
])
dnl ----------------------------------------------------------------------
AC_PATH_PROGS([ASCIIDOC], [asciidoc], [none])
AC_PATH_PROGS([A2X], [a2x], [none])
dnl ----------------------------------------------------------------------
AC_PATH_PROGS([HTMLPROOFER], [htmlproofer html-proofer], [none])
AC_ARG_WITH(htmlproofer,
[AS_HELP_STRING([--with-htmlproofer=PATH], [program location for htmlproofer (default: auto-detect)])],
[AS_CASE(["${withval}"],
[no|none], [
AS_IF([test x"${HTMLPROOFER}" != xnone], [AC_MSG_WARN([HTMLPROOFER='${HTMLPROOFER}' was detected, but we are explicitly configured to not use it])])
HTMLPROOFER="none"],
[''|auto|yes], [],
[HTMLPROOFER="${withval}"]
)],
[]
)
AM_CONDITIONAL([WITH_HTMLPROOFER], [test x"$HTMLPROOFER" != x -a x"$HTMLPROOFER" != xnone])
AM_COND_IF([WITH_HTMLPROOFER], [
AC_MSG_CHECKING([if provided/detected HTMLPROOFER='${HTMLPROOFER}' is what it says it is])
LANG=C LC_ALL=C ${HTMLPROOFER} --help | grep -iE '^htmlproofer *@<:@0-9@:>@' \
|| LANG=C LC_ALL=C ${HTMLPROOFER} --help | grep -iE '^Usage:.*htmlproofer*.*PATH\/LINK' \
|| AC_MSG_ERROR([no])
AC_MSG_RESULT([yes])
])
dnl ----------------------------------------------------------------------
dnl Note AC_INIT defines a constrained PACKAGE_VERSION based on last tag
dnl in NUT codebase, not its configure.ac version or detailed revision.
dnl For the rolling web-site we want to track origins more precisely:
NUT_VERSION="$(cd nut && (test -x "`dirname \"$0\"`/tools/gitlog2version.sh" && "`dirname \"$0\"`/tools/gitlog2version.sh" || (git describe --tags --match 'v@<:@0-9@:>@*.@<:@0-9@:>@*.@<:@0-9@:>@' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' || git describe --tags --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*' ) 2>/dev/null ))"
DDL_VERSION="$(cd ddl && (git describe --tags --match 'v@<:@0-9@:>@*.@<:@0-9@:>@*.@<:@0-9@:>@' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' || git describe --tags --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*' ) 2>/dev/null )"
WEB_VERSION="$( (git describe --tags --match 'v@<:@0-9@:>@*.@<:@0-9@:>@*.@<:@0-9@:>@' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' || git describe --tags --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*' ) 2>/dev/null )"
WEB_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
WEBSITE_VERSION="${PACKAGE_VERSION}"
dnl The "{revision}" for "nut::docs/download.txt" for currently served release
dnl Currently a tripled for latest stable release/tag
dnl Maybe a longer NUT SEMVER later if we would build serve dist tarballs from
dnl committed "master" branch iterations:
RELEASED_TARBALL_VERSION="`echo \"${PACKAGE_VERSION}\" | sed 's,^\(@<:@0-9@:>@@<:@0-9@:>@*\.@<:@0-9@:>@@<:@0-9@:>@*\.@<:@0-9@:>@@<:@0-9@:>@*\)\(@<:@^0-9@:>@.*\)*$,\1,'`"
dnl Last-moment string fixups
AS_CASE(["${NUT_VERSION}"],
[0*|1*|2*|3*|4*|5*|6*|7*|8*|9*], [NUT_VERSION="v${NUT_VERSION}"]
)
AS_CASE(["${NUT_VERSION}"],
[''], [AC_MSG_NOTICE(Seems there was a problem getting NUT_VERSION)],
[*-*-g*|*-*+g*], [dnl e.g. "v2.7.4-130-g20ff10c2" with last tag, count of commits since it in current branch, and latest commit (plus-separated since NUT v2.8.3, at least from its gitlog2version.sh)
WEBSITE_VERSION="nut:${NUT_VERSION} ddl:${DDL_VERSION} web:${WEB_VERSION}-${WEB_BRANCH}"
],
[dnl Default: exact tag hit, e.g. "v2.7.4" or "v2.8.0-rc1" for the release site
dnl This is a problem for publishing a non-historic site when master HEAD is the most recently tagged commit
AS_IF([test -z "${NUT_HISTORIC_RELEASE-}"], [
WEBSITE_VERSION="nut:${NUT_VERSION} ddl:${DDL_VERSION} web:${WEB_VERSION}-${WEB_BRANCH}"
])
]
)
AC_SUBST(RELEASED_TARBALL_VERSION)
AC_SUBST(WEBSITE_VERSION)
AC_SUBST(NUT_VERSION)
AC_SUBST(DDL_VERSION)
AC_SUBST(WEB_VERSION)
NUT_HISTORIC_RELEASE_EXPLODED=""
AS_CASE(["${NUT_HISTORIC_RELEASE-}"],
[v*], [NUT_HISTORIC_RELEASE_EXPLODED_NOV="`echo \"$NUT_HISTORIC_RELEASE\" | sed 's,^v,,'`"],
[NUT_HISTORIC_RELEASE_EXPLODED_NOV="${NUT_HISTORIC_RELEASE-}"]
)
NUT_VERSION_EXTRA_WIDTH=6
export NUT_VERSION_EXTRA_WIDTH
NUT_VERSION_MIN_COMPONENTS=5
export NUT_VERSION_MIN_COMPONENTS
AS_IF([test -n "${NUT_HISTORIC_RELEASE_EXPLODED_NOV}"], [
AS_IF([test -x "nut/tools/gitlog2version.sh" && grep -w VER5X "nut/tools/gitlog2version.sh" > /dev/null], [
NUT_HISTORIC_RELEASE_EXPLODED="`NUT_VERSION_QUERY=VER5X NUT_VERSION_FORCED=${NUT_HISTORIC_RELEASE_EXPLODED_NOV} ./nut/tools/gitlog2version.sh 2>/dev/null`" || NUT_HISTORIC_RELEASE_EXPLODED=""
])
AS_IF([test -z "${NUT_HISTORIC_RELEASE_EXPLODED}"], [
dnl No script, older script - releases before v2.8.5
NUT_HISTORIC_RELEASE_EXPLODED="`./tools/semver-compare.sh --expand \"$NUT_HISTORIC_RELEASE_EXPLODED_NOV\"`"
])
])
AC_SUBST(NUT_HISTORIC_RELEASE_EXPLODED)
dnl ----------------------------------------------------------------------
TREE_VERSION="`echo \"$PACKAGE_VERSION\" | awk '{ print substr($0,1,3) }'`"
AC_SUBST(TREE_VERSION)
TARBALL_VERSION="`echo \"$NUT_VERSION\" | sed 's,^v,,'`"
AC_SUBST(TARBALL_VERSION)
dnl ----------------------------------------------------------------------
# Some statistics for the front page:
COUNT_HCL_MANUFACTURERS="$(grep -E '^"' nut/data/driver.list.in | awk -F'"' '{print $2}' | sort | uniq | wc -l)"
COUNT_HCL_MODELS="$(grep -E '^"' nut/data/driver.list.in | awk -F'"' '{print $2" "$8" "$10}' | sort | uniq -c | wc -l)"
AC_SUBST(COUNT_HCL_MANUFACTURERS)
AC_SUBST(COUNT_HCL_MODELS)
dnl ----------------------------------------------------------------------
AC_CONFIG_FILES([
protocols/Makefile
Makefile
website.txt
])
AC_OUTPUT