]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/platformtest.sh
Correctly use cloaked IRC masks on "INVITE nickname"
[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_RUN=
31
32 SRC_D=`dirname "$0"`
33 MY_D="$PWD"
34
35 [ -n "$MAKE" ] || MAKE="make"
36 export MAKE CC
37
38 while [ $# -gt 0 ]; do
39         case "$1" in
40                 "-v")
41                         VERBOSE=1
42                         ;;
43                 "-x")
44                         CLEAN=
45                         ;;
46                 *)
47                         echo "Usage: $NAME [-v] [-x]"
48                         echo
49                         echo "  -v   Verbose output"
50                         echo "  -x   Don't regenerate build system, even when possible"
51                         echo
52                         exit 2
53         esac
54         shift
55 done
56
57 echo "$NAME: Checking ngIRCd base source directory ..."
58 grep "ngIRCd" "$SRC_D/ChangeLog" >/dev/null 2>&1
59 if [ $? -ne 0 ]; then
60         grep "ngIRCd" "$SRC_D/../ChangeLog" >/dev/null 2>&1
61         if [ $? -ne 0 ]; then
62                 echo "$NAME: ngIRCd base source directory not found!?"
63                 exit 1
64         fi
65         SRC_D="$SRC_D/.."
66 fi
67 echo "$NAME:  - source directory: $SRC_D"
68 echo "$NAME:  - working directory: $MY_D"
69
70 echo "$NAME: Checking for GIT tree ..."
71 if [ -d "$SRC_D/.git" ]; then
72         echo "$NAME: Checking for \"git\" command ..."
73         git version >/dev/null 2>&1
74         if [ $? -eq 0 -a -n "$CLEAN" ]; then
75                 echo "$NAME: Running \"git clean\" ..."
76                 cd "$SRC_D" || exit 1
77                 [ -n "$VERBOSE" ] && git clean -dxf || git clean -dxf >/dev/null
78                 cd "$MY_D" || exit 1
79         fi
80 fi
81
82 echo "$NAME: Checking for \"$SRC_D/configure\" script ..."
83 if [ ! -r "$SRC_D/configure" ]; then
84         echo "$NAME: Running \"$SRC_D/autogen.sh\" ..."
85         cd "$SRC_D" || exit 1
86         [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
87         cd "$MY_D" || exit 1
88 fi
89
90 if [ -r "$SRC_D/configure" ]; then
91         echo "$NAME: Running \"$SRC_D/configure\" script ..."
92         [ -n "$VERBOSE" ] && "$SRC_D/configure" -C || "$SRC_D/configure" -C >/dev/null
93         if [ $? -eq 0 -a -r ./Makefile ]; then
94                 R_CONFIGURE=1
95                 echo "$NAME: Running \"$MAKE\" ..."
96                 [ -n "$VERBOSE" ] && "$MAKE" || "$MAKE" >/dev/null
97                 if [ $? -eq 0 -a -x src/ngircd/ngircd ]; then
98                         R_MAKE=1
99                         echo "$NAME: Running \"$MAKE check\" ..."
100                         [ -n "$VERBOSE" ] && "$MAKE" check || "$MAKE" check >/dev/null
101                         if [ $? -eq 0 ]; then
102                                 R_CHECK=1
103                                 R_RUN=$R_CHECK
104                         else
105                                 ./src/ngircd/ngircd --help 2>/dev/null \
106                                  | grep "^ngIRCd" >/dev/null
107                                 [ $? -eq 0 ] && R_RUN=1
108                         fi
109                 fi
110         fi
111 fi
112
113 # Get target platform information
114 if [ -r "src/config.h" ]; then
115         CPU=`grep "HOST_CPU" "src/config.h" | cut -d'"' -f2`
116         OS=`grep "HOST_OS" "src/config.h" | cut -d'"' -f2`
117         VENDOR=`grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2`
118         PLATFORM="$CPU/$VENDOR/$OS"
119 fi
120 if [ -z "$PLATFORM" ]; then
121         PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
122 fi
123
124 # Get compiler information
125 if [ -r "Makefile" ]; then
126         CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
127         $CC --version 2>&1 | grep -i "GCC" >/dev/null
128         if [ $? -eq 0 ]; then
129                 # GCC, or compiler that mimics GCC
130                 $CC --version 2>&1 | grep -i "Open64" >/dev/null
131                 if [ $? -eq 0 ]; then
132                         COMPILER="Open64"
133                 else
134                         COMPILER=$($CC --version | head -1 \
135                           | cut -d')' -f2 | cut -d' ' -f2)
136                         COMPILER="gcc $COMPILER"
137                 fi
138         else
139                 # Non-GCC compiler
140                 $CC --version 2>&1 | grep -i "clang" >/dev/null
141                 if [ $? -eq 0 ]; then
142                         COMPILER=$($CC --version 2>/dev/null | head -1 \
143                           | cut -d'(' -f1 | cut -d'-' -f1 \
144                           | sed -e 's/version //g' | sed -e 's/Apple /A-/g' \
145                           | sed -e 's/Debian //g' | sed -e 's/LLVM /clang /g')
146                 fi
147                 $CC -version 2>&1 | grep -i "tcc" >/dev/null
148                 if [ $? -eq 0 ]; then
149                         COMPILER=$($CC -version 2>/dev/null | head -1 \
150                           | cut -d'(' -f1 | sed -e 's/version //g')
151                 fi
152                 if [ "$COMPILER" = "unknown" ]; then
153                         v="`$CC --version 2>/dev/null | head -1`"
154                         [ -z "$v" ] && v="`$CC -version 2>/dev/null | head -1`"
155                         [ -n "$v" ] && COMPILER="$v"
156                 fi
157         fi
158 fi
159
160 # Get ngIRCd version information
161 eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
162 case "$VERSION" in
163         *~*-*)
164                 VERSION=`echo "$VERSION" | cut -b1-10`
165                 ;;
166 esac
167 [ -n "$VERSION" ] || VERSION="unknown"
168
169 # Get IO interface information
170 if [ "$OS" = "linux-gnu" ]; then
171         COMMENT="1"
172 else
173         grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
174         [ $? -eq 0 ] && COMMENT="4"
175         grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
176         [ $? -eq 0 ] && COMMENT="5"
177         grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
178         [ $? -eq 0 ] && COMMENT="3"
179 fi
180
181 [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
182 [ -n "$R_MAKE" ] && M="Y" || M="N"
183 [ -n "$R_CHECK" ] && T="Y" || T="N"
184 [ -n "$R_RUN" ] && R="Y" || R="N"
185 [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
186
187 echo
188 echo "                                the executable works (\"runs\") as expected --+"
189 echo "                                  tests run successfully (\"make check\") --+ |"
190 echo "                                             ngIRCd compiles (\"make\") --+ | |"
191 echo "                                                  ./configure works --+ | | |"
192 echo "                                                                      | | | |"
193 echo "Platform                    Compiler     ngIRCd     Date     Tester   C M T R *"
194 echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
195 type printf >/dev/null 2>&1
196 if [ $? -eq 0 ]; then
197         printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s" \
198          "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
199          "$C" "$M" "$T" "$R" "$COMMENT"
200 else
201         echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
202          "$C" "$M" "$T" "$R" "$COMMENT"
203 fi
204 echo; echo