]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/platformtest.sh
Merge branch 'capabilities'
[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                 $CC --version 2>&1 | grep -i "Open64" >/dev/null
100                 if [ $? -eq 0 ]; then
101                         COMPILER="Open64"
102                 else
103                         COMPILER=$($CC --version | head -1 \
104                           | cut -d')' -f2 | cut -d' ' -f2)
105                         COMPILER="gcc $COMPILER"
106                 fi
107         else
108                 case "$CC" in
109                   gcc*)
110                         v="`$CC --version 2>/dev/null | head -1`"
111                         [ -n "$v" ] && COMPILER="gcc $v"
112                         ;;
113                 esac
114         fi
115 fi
116
117 # Get ngIRCd version information
118 eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
119 case "$VERSION" in
120         *-*-*)
121                 VERSION=`echo "$VERSION" | cut -d'-' -f3 | cut -b2-`
122                 ;;
123 esac
124 [ -n "$VERSION" ] || VERSION="unknown"
125
126 # Get IO interface information
127 if [ "$OS" = "linux-gnu" ]; then
128         COMMENT="(1)"
129 else
130         grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
131         [ $? -eq 0 ] && COMMENT="(4)"
132         grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
133         [ $? -eq 0 ] && COMMENT="(5)"
134         grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
135         [ $? -eq 0 ] && COMMENT="(3)"
136 fi
137
138 [ -n "$CONFIGURE" ] && C="Y" || C="N"
139 [ -n "$MAKE" ] && M="Y" || M="N"
140 [ -n "$CHECK" ] && T="Y" || T="N"
141 [ -n "$RUN" ] && R="Y" || R="N"
142 [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
143
144 echo
145 echo "                              the executable works (\"runs\") as expected --+"
146 echo "                                tests run successfully (\"make check\") --+ |"
147 echo "                                           ngIRCd compiles (\"make\") --+ | |"
148 echo "                                                ./configure works --+ | | |"
149 echo "                                                                    | | | |"
150 echo "Platform                    Compiler     ngIRCd     Date     Tester C M T R See"
151 echo "--------------------------- ------------ ---------- -------- ------ - - - - ---"
152 type printf >/dev/null 2>&1
153 if [ $? -eq 0 ]; then
154         printf "%-27s %-12s %-10s %s %-6s %s %s %s %s%s" \
155          "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
156          "$C" "$M" "$T" "$R" "$COMMENT"
157 else
158         echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
159          "$C" "$M" "$T" "$R" "$COMMENT"
160 fi
161 echo; echo