Blame


1 21bb2bd6 2009-08-04 alex #!/bin/sh
2 21bb2bd6 2009-08-04 alex #
3 21bb2bd6 2009-08-04 alex # ngIRCd -- The Next Generation IRC Daemon
4 4dcd5f12 2016-01-06 alex # Copyright (c)2001-2016 Alexander Barton (alex@barton.de) and Contributors
5 21bb2bd6 2009-08-04 alex #
6 21bb2bd6 2009-08-04 alex # This program is free software; you can redistribute it and/or modify
7 21bb2bd6 2009-08-04 alex # it under the terms of the GNU General Public License as published by
8 21bb2bd6 2009-08-04 alex # the Free Software Foundation; either version 2 of the License, or
9 21bb2bd6 2009-08-04 alex # (at your option) any later version.
10 21bb2bd6 2009-08-04 alex # Please read the file COPYING, README and AUTHORS for more information.
11 21bb2bd6 2009-08-04 alex #
12 21bb2bd6 2009-08-04 alex
13 21bb2bd6 2009-08-04 alex # This script analyzes the build process of ngIRCd and generates output
14 21bb2bd6 2009-08-04 alex # suitable for inclusion in doc/Platforms.txt -- please send reports
15 21bb2bd6 2009-08-04 alex # to the ngIRCd mailing list: <ngircd-ml@ngircd.barton.de>.
16 21bb2bd6 2009-08-04 alex
17 804c2403 2016-10-21 alex NAME=$(basename "$0")
18 21bb2bd6 2009-08-04 alex VERBOSE=
19 97b4fd8a 2014-01-11 alex CLEAN=1
20 21bb2bd6 2009-08-04 alex
21 21bb2bd6 2009-08-04 alex PLATFORM=
22 21bb2bd6 2009-08-04 alex COMPILER="unknown"
23 21bb2bd6 2009-08-04 alex VERSION="unknown"
24 804c2403 2016-10-21 alex DATE=$(date "+%y-%m-%d")
25 21bb2bd6 2009-08-04 alex COMMENT=
26 21bb2bd6 2009-08-04 alex
27 b2743af0 2012-04-27 alex R_CONFIGURE=
28 b2743af0 2012-04-27 alex R_MAKE=
29 b2743af0 2012-04-27 alex R_CHECK=
30 3de972e0 2014-06-04 alex R_CHECK_Y="?"
31 b2743af0 2012-04-27 alex R_RUN=
32 b2743af0 2012-04-27 alex
33 804c2403 2016-10-21 alex SRC_D=$(dirname "$0")
34 2560e5f1 2014-01-11 alex MY_D="$PWD"
35 2560e5f1 2014-01-11 alex
36 b2743af0 2012-04-27 alex [ -n "$MAKE" ] || MAKE="make"
37 b2743af0 2012-04-27 alex export MAKE CC
38 b2743af0 2012-04-27 alex
39 21bb2bd6 2009-08-04 alex while [ $# -gt 0 ]; do
40 21bb2bd6 2009-08-04 alex case "$1" in
41 21bb2bd6 2009-08-04 alex "-v")
42 21bb2bd6 2009-08-04 alex VERBOSE=1
43 21bb2bd6 2009-08-04 alex ;;
44 97b4fd8a 2014-01-11 alex "-x")
45 97b4fd8a 2014-01-11 alex CLEAN=
46 97b4fd8a 2014-01-11 alex ;;
47 21bb2bd6 2009-08-04 alex *)
48 97b4fd8a 2014-01-11 alex echo "Usage: $NAME [-v] [-x]"
49 97b4fd8a 2014-01-11 alex echo
50 97b4fd8a 2014-01-11 alex echo " -v Verbose output"
51 97b4fd8a 2014-01-11 alex echo " -x Don't regenerate build system, even when possible"
52 97b4fd8a 2014-01-11 alex echo
53 21bb2bd6 2009-08-04 alex exit 2
54 21bb2bd6 2009-08-04 alex esac
55 21bb2bd6 2009-08-04 alex shift
56 21bb2bd6 2009-08-04 alex done
57 21bb2bd6 2009-08-04 alex
58 7b7ee6a3 2015-12-19 alex for cmd in telnet expect; do
59 7b7ee6a3 2015-12-19 alex command -v "$cmd" >/dev/null 2>&1 \
60 7b7ee6a3 2015-12-19 alex || echo "$NAME: WARNING: $cmd(1) not found, \"make check\" won't run all tests!"
61 7b7ee6a3 2015-12-19 alex done
62 7b7ee6a3 2015-12-19 alex
63 21bb2bd6 2009-08-04 alex echo "$NAME: Checking ngIRCd base source directory ..."
64 2560e5f1 2014-01-11 alex grep "ngIRCd" "$SRC_D/ChangeLog" >/dev/null 2>&1
65 21bb2bd6 2009-08-04 alex if [ $? -ne 0 ]; then
66 2560e5f1 2014-01-11 alex grep "ngIRCd" "$SRC_D/../ChangeLog" >/dev/null 2>&1
67 21bb2bd6 2009-08-04 alex if [ $? -ne 0 ]; then
68 21bb2bd6 2009-08-04 alex echo "$NAME: ngIRCd base source directory not found!?"
69 21bb2bd6 2009-08-04 alex exit 1
70 21bb2bd6 2009-08-04 alex fi
71 2560e5f1 2014-01-11 alex SRC_D="$SRC_D/.."
72 21bb2bd6 2009-08-04 alex fi
73 2560e5f1 2014-01-11 alex echo "$NAME: - source directory: $SRC_D"
74 2560e5f1 2014-01-11 alex echo "$NAME: - working directory: $MY_D"
75 21bb2bd6 2009-08-04 alex
76 45d3e6aa 2013-10-14 alex echo "$NAME: Checking for GIT tree ..."
77 2560e5f1 2014-01-11 alex if [ -d "$SRC_D/.git" ]; then
78 45d3e6aa 2013-10-14 alex echo "$NAME: Checking for \"git\" command ..."
79 45d3e6aa 2013-10-14 alex git version >/dev/null 2>&1
80 46838510 2015-12-19 alex if [ $? -eq 0 ] && [ -n "$CLEAN" ]; then
81 45d3e6aa 2013-10-14 alex echo "$NAME: Running \"git clean\" ..."
82 2560e5f1 2014-01-11 alex cd "$SRC_D" || exit 1
83 804c2403 2016-10-21 alex if [ -n "$VERBOSE" ]; then
84 804c2403 2016-10-21 alex git clean -dxf
85 804c2403 2016-10-21 alex else
86 804c2403 2016-10-21 alex git clean -dxf >/dev/null
87 804c2403 2016-10-21 alex fi
88 2560e5f1 2014-01-11 alex cd "$MY_D" || exit 1
89 45d3e6aa 2013-10-14 alex fi
90 45d3e6aa 2013-10-14 alex fi
91 45d3e6aa 2013-10-14 alex
92 2560e5f1 2014-01-11 alex echo "$NAME: Checking for \"$SRC_D/configure\" script ..."
93 2560e5f1 2014-01-11 alex if [ ! -r "$SRC_D/configure" ]; then
94 2560e5f1 2014-01-11 alex echo "$NAME: Running \"$SRC_D/autogen.sh\" ..."
95 2560e5f1 2014-01-11 alex cd "$SRC_D" || exit 1
96 804c2403 2016-10-21 alex if [ -n "$VERBOSE" ]; then
97 804c2403 2016-10-21 alex ./autogen.sh
98 804c2403 2016-10-21 alex else
99 804c2403 2016-10-21 alex ./autogen.sh >/dev/null
100 3890304b 2017-01-20 alex fi
101 3890304b 2017-01-20 alex if [ $? -ne 0 ]; then
102 3890304b 2017-01-20 alex echo "$NAME: \"$SRC_D/autogen.sh\" script failed, aborting!"
103 3890304b 2017-01-20 alex exit 1
104 804c2403 2016-10-21 alex fi
105 2560e5f1 2014-01-11 alex cd "$MY_D" || exit 1
106 21bb2bd6 2009-08-04 alex fi
107 21bb2bd6 2009-08-04 alex
108 2560e5f1 2014-01-11 alex if [ -r "$SRC_D/configure" ]; then
109 2560e5f1 2014-01-11 alex echo "$NAME: Running \"$SRC_D/configure\" script ..."
110 804c2403 2016-10-21 alex if [ -n "$VERBOSE" ]; then
111 804c2403 2016-10-21 alex "$SRC_D/configure" -C
112 804c2403 2016-10-21 alex else
113 804c2403 2016-10-21 alex "$SRC_D/configure" -C >/dev/null
114 804c2403 2016-10-21 alex fi
115 46838510 2015-12-19 alex if [ $? -eq 0 ] && [ -r ./Makefile ]; then
116 b2743af0 2012-04-27 alex R_CONFIGURE=1
117 0a6e2845 2016-01-10 alex rm -f "src/ngircd/ngircd"
118 b2743af0 2012-04-27 alex echo "$NAME: Running \"$MAKE\" ..."
119 804c2403 2016-10-21 alex if [ -n "$VERBOSE" ]; then
120 804c2403 2016-10-21 alex "$MAKE"
121 804c2403 2016-10-21 alex else
122 804c2403 2016-10-21 alex "$MAKE" >/dev/null
123 804c2403 2016-10-21 alex fi
124 46838510 2015-12-19 alex if [ $? -eq 0 ] && [ -x src/ngircd/ngircd ]; then
125 b2743af0 2012-04-27 alex R_MAKE=1
126 b2743af0 2012-04-27 alex echo "$NAME: Running \"$MAKE check\" ..."
127 804c2403 2016-10-21 alex if [ -n "$VERBOSE" ]; then
128 804c2403 2016-10-21 alex "$MAKE" check
129 804c2403 2016-10-21 alex else
130 804c2403 2016-10-21 alex "$MAKE" check >/dev/null
131 804c2403 2016-10-21 alex fi
132 21bb2bd6 2009-08-04 alex if [ $? -eq 0 ]; then
133 b2743af0 2012-04-27 alex R_CHECK=1
134 b2743af0 2012-04-27 alex R_RUN=$R_CHECK
135 3de972e0 2014-06-04 alex [ -r ./src/testsuite/tests-skipped.lst ] \
136 3de972e0 2014-06-04 alex && R_CHECK_Y="y" || R_CHECK_Y="Y"
137 21bb2bd6 2009-08-04 alex else
138 21bb2bd6 2009-08-04 alex ./src/ngircd/ngircd --help 2>/dev/null \
139 301d4915 2012-11-13 alex | grep "^ngIRCd" >/dev/null
140 b2743af0 2012-04-27 alex [ $? -eq 0 ] && R_RUN=1
141 21bb2bd6 2009-08-04 alex fi
142 21bb2bd6 2009-08-04 alex fi
143 21bb2bd6 2009-08-04 alex fi
144 21bb2bd6 2009-08-04 alex fi
145 21bb2bd6 2009-08-04 alex
146 21bb2bd6 2009-08-04 alex # Get target platform information
147 21bb2bd6 2009-08-04 alex if [ -r "src/config.h" ]; then
148 804c2403 2016-10-21 alex CPU=$(grep "HOST_CPU" "src/config.h" | cut -d'"' -f2)
149 804c2403 2016-10-21 alex OS=$(grep "HOST_OS" "src/config.h" | cut -d'"' -f2)
150 804c2403 2016-10-21 alex VENDOR=$(grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2)
151 21bb2bd6 2009-08-04 alex PLATFORM="$CPU/$VENDOR/$OS"
152 21bb2bd6 2009-08-04 alex fi
153 21bb2bd6 2009-08-04 alex if [ -z "$PLATFORM" ]; then
154 804c2403 2016-10-21 alex PLATFORM="$(uname 2>/dev/null) $(uname -r 2>/dev/null), $(uname -m 2>/dev/null)"
155 21bb2bd6 2009-08-04 alex fi
156 21bb2bd6 2009-08-04 alex
157 21bb2bd6 2009-08-04 alex # Get compiler information
158 21bb2bd6 2009-08-04 alex if [ -r "Makefile" ]; then
159 05d1df97 2010-10-25 alex CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
160 21bb2bd6 2009-08-04 alex $CC --version 2>&1 | grep -i "GCC" >/dev/null
161 21bb2bd6 2009-08-04 alex if [ $? -eq 0 ]; then
162 a2479bb9 2013-10-16 alex # GCC, or compiler that mimics GCC
163 1dea0d91 2012-04-24 alex $CC --version 2>&1 | grep -i "Open64" >/dev/null
164 1dea0d91 2012-04-24 alex if [ $? -eq 0 ]; then
165 1dea0d91 2012-04-24 alex COMPILER="Open64"
166 1dea0d91 2012-04-24 alex else
167 1dea0d91 2012-04-24 alex COMPILER=$($CC --version | head -1 \
168 1dea0d91 2012-04-24 alex | cut -d')' -f2 | cut -d' ' -f2)
169 1dea0d91 2012-04-24 alex COMPILER="gcc $COMPILER"
170 1dea0d91 2012-04-24 alex fi
171 864f3df5 2010-10-26 alex else
172 a2479bb9 2013-10-16 alex # Non-GCC compiler
173 beb9f65d 2013-10-20 alex $CC --version 2>&1 | grep -i "clang" >/dev/null
174 0bd3fb88 2013-10-14 alex if [ $? -eq 0 ]; then
175 0bd3fb88 2013-10-14 alex COMPILER=$($CC --version 2>/dev/null | head -1 \
176 beb9f65d 2013-10-20 alex | cut -d'(' -f1 | cut -d'-' -f1 \
177 e699325f 2020-10-20 alex | sed -e 's/version //g; s/^\([A-Z]\)[A-Za-z]* clang/\1-clang/g; s/LLVM /clang /g')
178 0bd3fb88 2013-10-14 alex fi
179 a2479bb9 2013-10-16 alex $CC -version 2>&1 | grep -i "tcc" >/dev/null
180 a2479bb9 2013-10-16 alex if [ $? -eq 0 ]; then
181 a2479bb9 2013-10-16 alex COMPILER=$($CC -version 2>/dev/null | head -1 \
182 a2479bb9 2013-10-16 alex | cut -d'(' -f1 | sed -e 's/version //g')
183 a2479bb9 2013-10-16 alex fi
184 0bd3fb88 2013-10-14 alex if [ "$COMPILER" = "unknown" ]; then
185 804c2403 2016-10-21 alex v="$($CC --version 2>/dev/null | head -1)"
186 804c2403 2016-10-21 alex [ -z "$v" ] && v="$($CC -version 2>/dev/null | head -1)"
187 0bd3fb88 2013-10-14 alex [ -n "$v" ] && COMPILER="$v"
188 0bd3fb88 2013-10-14 alex fi
189 21bb2bd6 2009-08-04 alex fi
190 21bb2bd6 2009-08-04 alex fi
191 21bb2bd6 2009-08-04 alex
192 21bb2bd6 2009-08-04 alex # Get ngIRCd version information
193 c2e4c304 2015-08-26 alex eval "$(grep "^VERSION = " Makefile | sed -e 's/ //g')"
194 05d1df97 2010-10-25 alex case "$VERSION" in
195 1f5508d0 2014-01-11 alex *~*-*)
196 804c2403 2016-10-21 alex VERSION=$(echo "$VERSION" | cut -b1-10)
197 05d1df97 2010-10-25 alex ;;
198 05d1df97 2010-10-25 alex esac
199 21bb2bd6 2009-08-04 alex [ -n "$VERSION" ] || VERSION="unknown"
200 21bb2bd6 2009-08-04 alex
201 21bb2bd6 2009-08-04 alex # Get IO interface information
202 21bb2bd6 2009-08-04 alex if [ "$OS" = "linux-gnu" ]; then
203 48698f14 2013-10-23 alex COMMENT="1"
204 21bb2bd6 2009-08-04 alex else
205 21bb2bd6 2009-08-04 alex grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
206 48698f14 2013-10-23 alex [ $? -eq 0 ] && COMMENT="4"
207 21bb2bd6 2009-08-04 alex grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
208 48698f14 2013-10-23 alex [ $? -eq 0 ] && COMMENT="5"
209 21bb2bd6 2009-08-04 alex grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
210 48698f14 2013-10-23 alex [ $? -eq 0 ] && COMMENT="3"
211 21bb2bd6 2009-08-04 alex fi
212 21bb2bd6 2009-08-04 alex
213 b2743af0 2012-04-27 alex [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
214 b2743af0 2012-04-27 alex [ -n "$R_MAKE" ] && M="Y" || M="N"
215 3de972e0 2014-06-04 alex [ -n "$R_CHECK" ] && T="$R_CHECK_Y" || T="N"
216 2254e92e 2016-01-10 alex if [ -n "$R_RUN" ]; then
217 2254e92e 2016-01-10 alex # Mark "runs" with "Y" only when the test suite succeeded:
218 2254e92e 2016-01-10 alex [ "$T" = "N" ] && R="?" || R="Y"
219 2254e92e 2016-01-10 alex else
220 2254e92e 2016-01-10 alex R="N"
221 2254e92e 2016-01-10 alex fi
222 21bb2bd6 2009-08-04 alex [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
223 21bb2bd6 2009-08-04 alex
224 21bb2bd6 2009-08-04 alex echo
225 48698f14 2013-10-23 alex echo " the executable works (\"runs\") as expected --+"
226 48698f14 2013-10-23 alex echo " tests run successfully (\"make check\") --+ |"
227 48698f14 2013-10-23 alex echo " ngIRCd compiles (\"make\") --+ | |"
228 48698f14 2013-10-23 alex echo " ./configure works --+ | | |"
229 48698f14 2013-10-23 alex echo " | | | |"
230 48698f14 2013-10-23 alex echo "Platform Compiler ngIRCd Date Tester C M T R *"
231 48698f14 2013-10-23 alex echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
232 46838510 2015-12-19 alex command -v printf >/dev/null 2>&1
233 864f3df5 2010-10-26 alex if [ $? -eq 0 ]; then
234 3de972e0 2014-06-04 alex printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s\n" \
235 4dcd5f12 2016-01-06 alex "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$LOGNAME" \
236 864f3df5 2010-10-26 alex "$C" "$M" "$T" "$R" "$COMMENT"
237 864f3df5 2010-10-26 alex else
238 4dcd5f12 2016-01-06 alex echo "$PLATFORM $COMPILER $VERSION $DATE $LOGNAME" \
239 864f3df5 2010-10-26 alex "$C" "$M" "$T" "$R" "$COMMENT"
240 864f3df5 2010-10-26 alex fi
241 3de972e0 2014-06-04 alex echo
242 2254e92e 2016-01-10 alex
243 2254e92e 2016-01-10 alex double_check() {
244 2254e92e 2016-01-10 alex echo "Please double check that the ngIRCd daemon starts up, runs and handles IRC"
245 2254e92e 2016-01-10 alex echo "connections successfully!"
246 2254e92e 2016-01-10 alex }
247 2254e92e 2016-01-10 alex
248 3de972e0 2014-06-04 alex if [ "$R_CHECK_Y" = "y" ]; then
249 2254e92e 2016-01-10 alex echo "WARNING: Some tests have been skipped!"
250 2254e92e 2016-01-10 alex double_check
251 3de972e0 2014-06-04 alex echo
252 3de972e0 2014-06-04 alex fi
253 2254e92e 2016-01-10 alex if [ "$R" = "?" ]; then
254 2254e92e 2016-01-10 alex echo "WARNING: The resulting binary passed simple tests, but the test suite failed!"
255 2254e92e 2016-01-10 alex double_check
256 2254e92e 2016-01-10 alex echo
257 2254e92e 2016-01-10 alex fi