]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/platformtest.sh
ngIRCd release 16
[ngircd-alex.git] / contrib / platformtest.sh
1 #!/bin/sh
2 #
3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2009 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 ./configure script ..."
55 if [ ! -e ./configure ]; then
56         echo "$NAME: Not found. Running ./autogen.sh ..."
57         [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
58 fi
59
60 if [ -e ./configure ]; then
61         echo "$NAME: Running \"./configure\" script ..."
62         [ -n "$VERBOSE" ] && ./configure || ./configure >/dev/null
63         if [ $? -eq 0 -a -e ./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         eval $(grep "^CC = " Makefile | sed -e 's/ //g')
97         $CC --version 2>&1 | grep -i "GCC" >/dev/null
98         if [ $? -eq 0 ]; then
99                 COMPILER=$($CC --version | head -n 1 | awk "{ print \$3 }" \
100                  | cut -d'-' -f1)
101                 COMPILER="gcc $COMPILER"
102         fi
103 fi
104
105 # Get ngIRCd version information
106 if [ -d ".git" ]; then
107         VERSION=`git log --abbrev-commit --pretty=oneline HEAD~1.. \
108          | head -1 | cut -d' ' -f1 | tr -d '.'`
109 elif [ -r "Makefile" ]; then
110         eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
111 fi
112 [ -n "$VERSION" ] || VERSION="unknown"
113
114 # Get IO interface information
115 if [ "$OS" = "linux-gnu" ]; then
116         COMMENT="(1)"
117 else
118         grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
119         [ $? -eq 0 ] && COMMENT="(4)"
120         grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
121         [ $? -eq 0 ] && COMMENT="(5)"
122         grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
123         [ $? -eq 0 ] && COMMENT="(3)"
124 fi
125
126 [ -n "$CONFIGURE" ] && C="Y" || C="N"
127 [ -n "$MAKE" ] && M="Y" || M="N"
128 [ -n "$CHECK" ] && T="Y" || T="N"
129 [ -n "$RUN" ] && R="Y" || R="N"
130 [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
131
132 echo
133 echo "                              the executable works (\"runs\") as expected --+"
134 echo "                                tests run successfully (\"make check\") --+ |"
135 echo "                                           ngIRCd compiles (\"make\") --+ | |"
136 echo "                                                ./configure works --+ | | |"
137 echo "                                                                    | | | |"
138 echo "Platform                    Compiler     ngIRCd     Date     Tester C M T R See"
139 echo "--------------------------- ------------ ---------- -------- ------ - - - - ---"
140 printf "%-27s %-12s %-10s %s %-6s %s %s %s %s%s" \
141  "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
142  "$C" "$M" "$T" "$R" "$COMMENT"
143 echo; echo