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