001
2009-08-04
alex
#!/bin/sh
003
2009-08-04
alex
# ngIRCd -- The Next Generation IRC Daemon
004
2016-01-06
alex
# Copyright (c)2001-2016 Alexander Barton (alex@barton.de) and Contributors
006
2009-08-04
alex
# This program is free software; you can redistribute it and/or modify
007
2009-08-04
alex
# it under the terms of the GNU General Public License as published by
008
2009-08-04
alex
# the Free Software Foundation; either version 2 of the License, or
009
2009-08-04
alex
# (at your option) any later version.
010
2009-08-04
alex
# Please read the file COPYING, README and AUTHORS for more information.
013
2009-08-04
alex
# This script analyzes the build process of ngIRCd and generates output
014
2009-08-04
alex
# suitable for inclusion in doc/Platforms.txt -- please send reports
015
2009-08-04
alex
# to the ngIRCd mailing list: <ngircd-ml@ngircd.barton.de>.
017
2016-10-21
alex
NAME=$(basename "$0")
018
2009-08-04
alex
VERBOSE=
021
2009-08-04
alex
PLATFORM=
022
2009-08-04
alex
COMPILER="unknown"
023
2009-08-04
alex
VERSION="unknown"
024
2016-10-21
alex
DATE=$(date "+%y-%m-%d")
025
2009-08-04
alex
COMMENT=
027
2012-04-27
alex
R_CONFIGURE=
029
2012-04-27
alex
R_CHECK=
030
2014-06-04
alex
R_CHECK_Y="?"
033
2016-10-21
alex
SRC_D=$(dirname "$0")
034
2014-01-11
alex
MY_D="$PWD"
036
2012-04-27
alex
[ -n "$MAKE" ] || MAKE="make"
037
2012-04-27
alex
export MAKE CC
039
2009-08-04
alex
while [ $# -gt 0 ]; do
040
2009-08-04
alex
case "$1" in
042
2009-08-04
alex
VERBOSE=1
048
2014-01-11
alex
echo "Usage: $NAME [-v] [-x]"
050
2014-01-11
alex
echo " -v Verbose output"
051
2014-01-11
alex
echo " -x Don't regenerate build system, even when possible"
058
2015-12-19
alex
for cmd in telnet expect; do
059
2015-12-19
alex
command -v "$cmd" >/dev/null 2>&1 \
060
2015-12-19
alex
|| echo "$NAME: WARNING: $cmd(1) not found, \"make check\" won't run all tests!"
063
2009-08-04
alex
echo "$NAME: Checking ngIRCd base source directory ..."
064
2014-01-11
alex
grep "ngIRCd" "$SRC_D/ChangeLog" >/dev/null 2>&1
065
2009-08-04
alex
if [ $? -ne 0 ]; then
066
2014-01-11
alex
grep "ngIRCd" "$SRC_D/../ChangeLog" >/dev/null 2>&1
067
2009-08-04
alex
if [ $? -ne 0 ]; then
068
2009-08-04
alex
echo "$NAME: ngIRCd base source directory not found!?"
071
2014-01-11
alex
SRC_D="$SRC_D/.."
073
2014-01-11
alex
echo "$NAME: - source directory: $SRC_D"
074
2014-01-11
alex
echo "$NAME: - working directory: $MY_D"
076
2013-10-14
alex
echo "$NAME: Checking for GIT tree ..."
077
2014-01-11
alex
if [ -d "$SRC_D/.git" ]; then
078
2013-10-14
alex
echo "$NAME: Checking for \"git\" command ..."
079
2013-10-14
alex
git version >/dev/null 2>&1
080
2015-12-19
alex
if [ $? -eq 0 ] && [ -n "$CLEAN" ]; then
081
2013-10-14
alex
echo "$NAME: Running \"git clean\" ..."
082
2014-01-11
alex
cd "$SRC_D" || exit 1
083
2016-10-21
alex
if [ -n "$VERBOSE" ]; then
084
2016-10-21
alex
git clean -dxf
086
2016-10-21
alex
git clean -dxf >/dev/null
088
2014-01-11
alex
cd "$MY_D" || exit 1
092
2014-01-11
alex
echo "$NAME: Checking for \"$SRC_D/configure\" script ..."
093
2014-01-11
alex
if [ ! -r "$SRC_D/configure" ]; then
094
2014-01-11
alex
echo "$NAME: Running \"$SRC_D/autogen.sh\" ..."
095
2014-01-11
alex
cd "$SRC_D" || exit 1
096
2016-10-21
alex
if [ -n "$VERBOSE" ]; then
097
2016-10-21
alex
./autogen.sh
099
2016-10-21
alex
./autogen.sh >/dev/null
101
2017-01-20
alex
if [ $? -ne 0 ]; then
102
2017-01-20
alex
echo "$NAME: \"$SRC_D/autogen.sh\" script failed, aborting!"
105
2014-01-11
alex
cd "$MY_D" || exit 1
108
2014-01-11
alex
if [ -r "$SRC_D/configure" ]; then
109
2014-01-11
alex
echo "$NAME: Running \"$SRC_D/configure\" script ..."
110
2016-10-21
alex
if [ -n "$VERBOSE" ]; then
111
2016-10-21
alex
"$SRC_D/configure" -C
113
2016-10-21
alex
"$SRC_D/configure" -C >/dev/null
115
2015-12-19
alex
if [ $? -eq 0 ] && [ -r ./Makefile ]; then
116
2012-04-27
alex
R_CONFIGURE=1
117
2016-01-10
alex
rm -f "src/ngircd/ngircd"
118
2012-04-27
alex
echo "$NAME: Running \"$MAKE\" ..."
119
2016-10-21
alex
if [ -n "$VERBOSE" ]; then
120
2016-10-21
alex
"$MAKE"
122
2016-10-21
alex
"$MAKE" >/dev/null
124
2015-12-19
alex
if [ $? -eq 0 ] && [ -x src/ngircd/ngircd ]; then
125
2012-04-27
alex
R_MAKE=1
126
2012-04-27
alex
echo "$NAME: Running \"$MAKE check\" ..."
127
2016-10-21
alex
if [ -n "$VERBOSE" ]; then
128
2016-10-21
alex
"$MAKE" check
130
2016-10-21
alex
"$MAKE" check >/dev/null
132
2009-08-04
alex
if [ $? -eq 0 ]; then
133
2012-04-27
alex
R_CHECK=1
134
2012-04-27
alex
R_RUN=$R_CHECK
135
2014-06-04
alex
[ -r ./src/testsuite/tests-skipped.lst ] \
136
2014-06-04
alex
&& R_CHECK_Y="y" || R_CHECK_Y="Y"
138
2009-08-04
alex
./src/ngircd/ngircd --help 2>/dev/null \
139
2012-11-13
alex
| grep "^ngIRCd" >/dev/null
140
2012-04-27
alex
[ $? -eq 0 ] && R_RUN=1
146
2009-08-04
alex
# Get target platform information
147
2009-08-04
alex
if [ -r "src/config.h" ]; then
148
2016-10-21
alex
CPU=$(grep "HOST_CPU" "src/config.h" | cut -d'"' -f2)
149
2016-10-21
alex
OS=$(grep "HOST_OS" "src/config.h" | cut -d'"' -f2)
150
2016-10-21
alex
VENDOR=$(grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2)
151
2009-08-04
alex
PLATFORM="$CPU/$VENDOR/$OS"
153
2009-08-04
alex
if [ -z "$PLATFORM" ]; then
154
2016-10-21
alex
PLATFORM="$(uname 2>/dev/null) $(uname -r 2>/dev/null), $(uname -m 2>/dev/null)"
157
2009-08-04
alex
# Get compiler information
158
2009-08-04
alex
if [ -r "Makefile" ]; then
159
2010-10-25
alex
CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
160
2009-08-04
alex
$CC --version 2>&1 | grep -i "GCC" >/dev/null
161
2009-08-04
alex
if [ $? -eq 0 ]; then
162
2013-10-16
alex
# GCC, or compiler that mimics GCC
163
2012-04-24
alex
$CC --version 2>&1 | grep -i "Open64" >/dev/null
164
2012-04-24
alex
if [ $? -eq 0 ]; then
165
2012-04-24
alex
COMPILER="Open64"
167
2012-04-24
alex
COMPILER=$($CC --version | head -1 \
168
2012-04-24
alex
| cut -d')' -f2 | cut -d' ' -f2)
169
2012-04-24
alex
COMPILER="gcc $COMPILER"
172
2013-10-16
alex
# Non-GCC compiler
173
2013-10-20
alex
$CC --version 2>&1 | grep -i "clang" >/dev/null
174
2013-10-14
alex
if [ $? -eq 0 ]; then
175
2013-10-14
alex
COMPILER=$($CC --version 2>/dev/null | head -1 \
176
2013-10-20
alex
| cut -d'(' -f1 | cut -d'-' -f1 \
177
2020-10-20
alex
| sed -e 's/version //g; s/^\([A-Z]\)[A-Za-z]* clang/\1-clang/g; s/LLVM /clang /g')
179
2013-10-16
alex
$CC -version 2>&1 | grep -i "tcc" >/dev/null
180
2013-10-16
alex
if [ $? -eq 0 ]; then
181
2013-10-16
alex
COMPILER=$($CC -version 2>/dev/null | head -1 \
182
2013-10-16
alex
| cut -d'(' -f1 | sed -e 's/version //g')
184
2013-10-14
alex
if [ "$COMPILER" = "unknown" ]; then
185
2016-10-21
alex
v="$($CC --version 2>/dev/null | head -1)"
186
2016-10-21
alex
[ -z "$v" ] && v="$($CC -version 2>/dev/null | head -1)"
187
2013-10-14
alex
[ -n "$v" ] && COMPILER="$v"
192
2009-08-04
alex
# Get ngIRCd version information
193
2015-08-26
alex
eval "$(grep "^VERSION = " Makefile | sed -e 's/ //g')"
194
2010-10-25
alex
case "$VERSION" in
196
2016-10-21
alex
VERSION=$(echo "$VERSION" | cut -b1-10)
199
2009-08-04
alex
[ -n "$VERSION" ] || VERSION="unknown"
201
2009-08-04
alex
# Get IO interface information
202
2009-08-04
alex
if [ "$OS" = "linux-gnu" ]; then
203
2013-10-23
alex
COMMENT="1"
205
2009-08-04
alex
grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
206
2013-10-23
alex
[ $? -eq 0 ] && COMMENT="4"
207
2009-08-04
alex
grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
208
2013-10-23
alex
[ $? -eq 0 ] && COMMENT="5"
209
2009-08-04
alex
grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
210
2013-10-23
alex
[ $? -eq 0 ] && COMMENT="3"
213
2012-04-27
alex
[ -n "$R_CONFIGURE" ] && C="Y" || C="N"
214
2012-04-27
alex
[ -n "$R_MAKE" ] && M="Y" || M="N"
215
2014-06-04
alex
[ -n "$R_CHECK" ] && T="$R_CHECK_Y" || T="N"
216
2016-01-10
alex
if [ -n "$R_RUN" ]; then
217
2016-01-10
alex
# Mark "runs" with "Y" only when the test suite succeeded:
218
2016-01-10
alex
[ "$T" = "N" ] && R="?" || R="Y"
222
2009-08-04
alex
[ -n "$COMMENT" ] && COMMENT=" $COMMENT"
225
2013-10-23
alex
echo " the executable works (\"runs\") as expected --+"
226
2013-10-23
alex
echo " tests run successfully (\"make check\") --+ |"
227
2013-10-23
alex
echo " ngIRCd compiles (\"make\") --+ | |"
228
2013-10-23
alex
echo " ./configure works --+ | | |"
229
2013-10-23
alex
echo " | | | |"
230
2013-10-23
alex
echo "Platform Compiler ngIRCd Date Tester C M T R *"
231
2013-10-23
alex
echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
232
2015-12-19
alex
command -v printf >/dev/null 2>&1
233
2010-10-26
alex
if [ $? -eq 0 ]; then
234
2014-06-04
alex
printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s\n" \
235
2016-01-06
alex
"$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$LOGNAME" \
236
2010-10-26
alex
"$C" "$M" "$T" "$R" "$COMMENT"
238
2016-01-06
alex
echo "$PLATFORM $COMPILER $VERSION $DATE $LOGNAME" \
239
2010-10-26
alex
"$C" "$M" "$T" "$R" "$COMMENT"
243
2016-01-10
alex
double_check() {
244
2016-01-10
alex
echo "Please double check that the ngIRCd daemon starts up, runs and handles IRC"
245
2016-01-10
alex
echo "connections successfully!"
248
2014-06-04
alex
if [ "$R_CHECK_Y" = "y" ]; then
249
2016-01-10
alex
echo "WARNING: Some tests have been skipped!"
250
2016-01-10
alex
double_check
253
2016-01-10
alex
if [ "$R" = "?" ]; then
254
2016-01-10
alex
echo "WARNING: The resulting binary passed simple tests, but the test suite failed!"
255
2016-01-10
alex
double_check