]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/platformtest.sh
New "Debian release" 21.1-0ab2
[ngircd-alex.git] / contrib / platformtest.sh
1 #!/bin/sh
2 #
3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
11 #
12
13 # This script analyzes the build process of ngIRCd and generates output
14 # suitable for inclusion in doc/Platforms.txt -- please send reports
15 # to the ngIRCd mailing list: <ngircd-ml@ngircd.barton.de>.
16
17 NAME=`basename "$0"`
18 VERBOSE=
19 CLEAN=1
20
21 PLATFORM=
22 COMPILER="unknown"
23 VERSION="unknown"
24 DATE=`date "+%y-%m-%d"`
25 COMMENT=
26
27 R_CONFIGURE=
28 R_MAKE=
29 R_CHECK=
30 R_CHECK_Y="?"
31 R_RUN=
32
33 SRC_D=`dirname "$0"`
34 MY_D="$PWD"
35
36 [ -n "$MAKE" ] || MAKE="make"
37 export MAKE CC
38
39 while [ $# -gt 0 ]; do
40         case "$1" in
41                 "-v")
42                         VERBOSE=1
43                         ;;
44                 "-x")
45                         CLEAN=
46                         ;;
47                 *)
48                         echo "Usage: $NAME [-v] [-x]"
49                         echo
50                         echo "  -v   Verbose output"
51                         echo "  -x   Don't regenerate build system, even when possible"
52                         echo
53                         exit 2
54         esac
55         shift
56 done
57
58 echo "$NAME: Checking ngIRCd base source directory ..."
59 grep "ngIRCd" "$SRC_D/ChangeLog" >/dev/null 2>&1
60 if [ $? -ne 0 ]; then
61         grep "ngIRCd" "$SRC_D/../ChangeLog" >/dev/null 2>&1
62         if [ $? -ne 0 ]; then
63                 echo "$NAME: ngIRCd base source directory not found!?"
64                 exit 1
65         fi
66         SRC_D="$SRC_D/.."
67 fi
68 echo "$NAME:  - source directory: $SRC_D"
69 echo "$NAME:  - working directory: $MY_D"
70
71 echo "$NAME: Checking for GIT tree ..."
72 if [ -d "$SRC_D/.git" ]; then
73         echo "$NAME: Checking for \"git\" command ..."
74         git version >/dev/null 2>&1
75         if [ $? -eq 0 -a -n "$CLEAN" ]; then
76                 echo "$NAME: Running \"git clean\" ..."
77                 cd "$SRC_D" || exit 1
78                 [ -n "$VERBOSE" ] && git clean -dxf || git clean -dxf >/dev/null
79                 cd "$MY_D" || exit 1
80         fi
81 fi
82
83 echo "$NAME: Checking for \"$SRC_D/configure\" script ..."
84 if [ ! -r "$SRC_D/configure" ]; then
85         echo "$NAME: Running \"$SRC_D/autogen.sh\" ..."
86         cd "$SRC_D" || exit 1
87         [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
88         cd "$MY_D" || exit 1
89 fi
90
91 if [ -r "$SRC_D/configure" ]; then
92         echo "$NAME: Running \"$SRC_D/configure\" script ..."
93         [ -n "$VERBOSE" ] && "$SRC_D/configure" -C || "$SRC_D/configure" -C >/dev/null
94         if [ $? -eq 0 -a -r ./Makefile ]; then
95                 R_CONFIGURE=1
96                 echo "$NAME: Running \"$MAKE\" ..."
97                 [ -n "$VERBOSE" ] && "$MAKE" || "$MAKE" >/dev/null
98                 if [ $? -eq 0 -a -x src/ngircd/ngircd ]; then
99                         R_MAKE=1
100                         echo "$NAME: Running \"$MAKE check\" ..."
101                         [ -n "$VERBOSE" ] && "$MAKE" check || "$MAKE" check >/dev/null
102                         if [ $? -eq 0 ]; then
103                                 R_CHECK=1
104                                 R_RUN=$R_CHECK
105                                 [ -r ./src/testsuite/tests-skipped.lst ] \
106                                         && R_CHECK_Y="y" || R_CHECK_Y="Y"
107                         else
108                                 ./src/ngircd/ngircd --help 2>/dev/null \
109                                  | grep "^ngIRCd" >/dev/null
110                                 [ $? -eq 0 ] && R_RUN=1
111                         fi
112                 fi
113         fi
114 fi
115
116 # Get target platform information
117 if [ -r "src/config.h" ]; then
118         CPU=`grep "HOST_CPU" "src/config.h" | cut -d'"' -f2`
119         OS=`grep "HOST_OS" "src/config.h" | cut -d'"' -f2`
120         VENDOR=`grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2`
121         PLATFORM="$CPU/$VENDOR/$OS"
122 fi
123 if [ -z "$PLATFORM" ]; then
124         PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
125 fi
126
127 # Get compiler information
128 if [ -r "Makefile" ]; then
129         CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
130         $CC --version 2>&1 | grep -i "GCC" >/dev/null
131         if [ $? -eq 0 ]; then
132                 # GCC, or compiler that mimics GCC
133                 $CC --version 2>&1 | grep -i "Open64" >/dev/null
134                 if [ $? -eq 0 ]; then
135                         COMPILER="Open64"
136                 else
137                         COMPILER=$($CC --version | head -1 \
138                           | cut -d')' -f2 | cut -d' ' -f2)
139                         COMPILER="gcc $COMPILER"
140                 fi
141         else
142                 # Non-GCC compiler
143                 $CC --version 2>&1 | grep -i "clang" >/dev/null
144                 if [ $? -eq 0 ]; then
145                         COMPILER=$($CC --version 2>/dev/null | head -1 \
146                           | cut -d'(' -f1 | cut -d'-' -f1 \
147                           | sed -e 's/version //g' | sed -e 's/Apple /A-/g' \
148                           | sed -e 's/Debian //g' | sed -e 's/LLVM /clang /g')
149                 fi
150                 $CC -version 2>&1 | grep -i "tcc" >/dev/null
151                 if [ $? -eq 0 ]; then
152                         COMPILER=$($CC -version 2>/dev/null | head -1 \
153                           | cut -d'(' -f1 | sed -e 's/version //g')
154                 fi
155                 if [ "$COMPILER" = "unknown" ]; then
156                         v="`$CC --version 2>/dev/null | head -1`"
157                         [ -z "$v" ] && v="`$CC -version 2>/dev/null | head -1`"
158                         [ -n "$v" ] && COMPILER="$v"
159                 fi
160         fi
161 fi
162
163 # Get ngIRCd version information
164 eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
165 case "$VERSION" in
166         *~*-*)
167                 VERSION=`echo "$VERSION" | cut -b1-10`
168                 ;;
169 esac
170 [ -n "$VERSION" ] || VERSION="unknown"
171
172 # Get IO interface information
173 if [ "$OS" = "linux-gnu" ]; then
174         COMMENT="1"
175 else
176         grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
177         [ $? -eq 0 ] && COMMENT="4"
178         grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
179         [ $? -eq 0 ] && COMMENT="5"
180         grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
181         [ $? -eq 0 ] && COMMENT="3"
182 fi
183
184 [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
185 [ -n "$R_MAKE" ] && M="Y" || M="N"
186 [ -n "$R_CHECK" ] && T="$R_CHECK_Y" || T="N"
187 [ -n "$R_RUN" ] && R="Y" || R="N"
188 [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
189
190 echo
191 echo "                                the executable works (\"runs\") as expected --+"
192 echo "                                  tests run successfully (\"make check\") --+ |"
193 echo "                                             ngIRCd compiles (\"make\") --+ | |"
194 echo "                                                  ./configure works --+ | | |"
195 echo "                                                                      | | | |"
196 echo "Platform                    Compiler     ngIRCd     Date     Tester   C M T R *"
197 echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
198 type printf >/dev/null 2>&1
199 if [ $? -eq 0 ]; then
200         printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s\n" \
201          "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
202          "$C" "$M" "$T" "$R" "$COMMENT"
203 else
204         echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
205          "$C" "$M" "$T" "$R" "$COMMENT"
206 fi
207 echo
208 if [ "$R_CHECK_Y" = "y" ]; then
209         echo "$NAME: Warning: Some tests have been skipped!"
210         echo
211 fi