Move "ClientHost" and "ClientUserNick" to end of [Global] section
[ngircd-alex.git] / contrib / platformtest.sh
1 #!/bin/sh
2 #
3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2010 Alexander Barton <alex@barton.de>
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
20 PLATFORM=
21 COMPILER="unknown"
22 VERSION="unknown"
23 DATE=`date "+%y-%m-%d"`
24
25 CONFIGURE=
26 MAKE=
27 CHECK=
28 RUN=
29 COMMENT=
30
31 while [ $# -gt 0 ]; do
32         case "$1" in
33                 "-v")
34                         VERBOSE=1
35                         ;;
36                 *)
37                         echo "Usage: $NAME [-v]"
38                         exit 2
39         esac
40         shift
41 done
42
43 echo "$NAME: Checking ngIRCd base source directory ..."
44 grep "ngIRCd" ./ChangeLog >/dev/null 2>&1
45 if [ $? -ne 0 ]; then
46         grep "ngIRCd" ../ChangeLog >/dev/null 2>&1
47         if [ $? -ne 0 ]; then
48                 echo "$NAME: ngIRCd base source directory not found!?"
49                 exit 1
50         fi
51         cd ..
52 fi
53
54 echo "$NAME: Checking for \"./autogen.sh\" script ..."
55 if [ -r ./autogen.sh ]; then
56         echo "$NAME: Running \"./autogen.sh\" ..."
57         [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
58 fi
59
60 if [ -r ./configure ]; then
61         echo "$NAME: Running \"./configure\" script ..."
62         [ -n "$VERBOSE" ] && ./configure || ./configure >/dev/null
63         if [ $? -eq 0 -a -r ./Makefile ]; then
64                 CONFIGURE=1
65                 echo "$NAME: Running \"make\" ..."
66                 [ -n "$VERBOSE" ] && make || make >/dev/null
67                 if [ $? -eq 0 -a -x src/ngircd/ngircd ]; then
68                         MAKE=1
69                         echo "$NAME: Running \"make check\" ..."
70                         [ -n "$VERBOSE" ] && make check || make check >/dev/null
71                         if [ $? -eq 0 ]; then
72                                 CHECK=1
73                                 RUN=$CHECK
74                         else
75                                 ./src/ngircd/ngircd --help 2>/dev/null \
76                                  | grep "^ngircd" >/dev/null
77                                 [ $? -eq 0 ] && RUN=1
78                         fi
79                 fi
80         fi
81 fi
82
83 # Get target platform information
84 if [ -r "src/config.h" ]; then
85         CPU=`grep "TARGET_CPU" "src/config.h" | cut -d'"' -f2`
86         OS=`grep "TARGET_OS" "src/config.h" | cut -d'"' -f2`
87         VENDOR=`grep "TARGET_VENDOR" "src/config.h" | cut -d'"' -f2`
88         PLATFORM="$CPU/$VENDOR/$OS"
89 fi
90 if [ -z "$PLATFORM" ]; then
91         PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
92 fi
93
94 # Get compiler information
95 if [ -r "Makefile" ]; then
96         CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
97         $CC --version 2>&1 | grep -i "GCC" >/dev/null
98         if [ $? -eq 0 ]; then
99                 COMPILER=$($CC --version | head -1 | awk "{ print \$3 }" \
100                  | cut -d'-' -f1)
101                 COMPILER="gcc $COMPILER"
102         else
103                 case "$CC" in
104                   gcc*)
105                         v="`$CC --version 2>/dev/null | head -1`"
106                         [ -n "$v" ] && COMPILER="gcc $v"
107                         ;;
108                 esac
109         fi
110 fi
111
112 # Get ngIRCd version information
113 eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
114 case "$VERSION" in
115         *-*-*)
116                 VERSION=`echo "$VERSION" | cut -d'-' -f3 | cut -b2-`
117                 ;;
118 esac
119 [ -n "$VERSION" ] || VERSION="unknown"
120
121 # Get IO interface information
122 if [ "$OS" = "linux-gnu" ]; then
123         COMMENT="(1)"
124 else
125         grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
126         [ $? -eq 0 ] && COMMENT="(4)"
127         grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
128         [ $? -eq 0 ] && COMMENT="(5)"
129         grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
130         [ $? -eq 0 ] && COMMENT="(3)"
131 fi
132
133 [ -n "$CONFIGURE" ] && C="Y" || C="N"
134 [ -n "$MAKE" ] && M="Y" || M="N"
135 [ -n "$CHECK" ] && T="Y" || T="N"
136 [ -n "$RUN" ] && R="Y" || R="N"
137 [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
138
139 echo
140 echo "                              the executable works (\"runs\") as expected --+"
141 echo "                                tests run successfully (\"make check\") --+ |"
142 echo "                                           ngIRCd compiles (\"make\") --+ | |"
143 echo "                                                ./configure works --+ | | |"
144 echo "                                                                    | | | |"
145 echo "Platform                    Compiler     ngIRCd     Date     Tester C M T R See"
146 echo "--------------------------- ------------ ---------- -------- ------ - - - - ---"
147 type printf >/dev/null 2>&1
148 if [ $? -eq 0 ]; then
149         printf "%-27s %-12s %-10s %s %-6s %s %s %s %s%s" \
150          "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
151          "$C" "$M" "$T" "$R" "$COMMENT"
152 else
153         echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
154          "$C" "$M" "$T" "$R" "$COMMENT"
155 fi
156 echo; echo