platformtest.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. # This script analyzes the build process of ngIRCd and generates output
  13. # suitable for inclusion in doc/Platforms.txt -- please send reports
  14. # to the ngIRCd mailing list: <ngircd-ml@ngircd.barton.de>.
  15. NAME=`basename "$0"`
  16. VERBOSE=
  17. PLATFORM=
  18. COMPILER="unknown"
  19. VERSION="unknown"
  20. DATE=`date "+%y-%m-%d"`
  21. COMMENT=
  22. R_CONFIGURE=
  23. R_MAKE=
  24. R_CHECK=
  25. R_RUN=
  26. [ -n "$MAKE" ] || MAKE="make"
  27. export MAKE CC
  28. while [ $# -gt 0 ]; do
  29. case "$1" in
  30. "-v")
  31. VERBOSE=1
  32. ;;
  33. *)
  34. echo "Usage: $NAME [-v]"
  35. exit 2
  36. esac
  37. shift
  38. done
  39. echo "$NAME: Checking ngIRCd base source directory ..."
  40. grep "ngIRCd" ./ChangeLog >/dev/null 2>&1
  41. if [ $? -ne 0 ]; then
  42. grep "ngIRCd" ../ChangeLog >/dev/null 2>&1
  43. if [ $? -ne 0 ]; then
  44. echo "$NAME: ngIRCd base source directory not found!?"
  45. exit 1
  46. fi
  47. cd ..
  48. fi
  49. echo "$NAME: Checking for GIT tree ..."
  50. if [ -d .git ]; then
  51. echo "$NAME: Checking for \"git\" command ..."
  52. git version >/dev/null 2>&1
  53. if [ $? -eq 0 ]; then
  54. echo "$NAME: Running \"git clean\" ..."
  55. [ -n "$VERBOSE" ] && git clean -dxf || git clean -dxf >/dev/null
  56. fi
  57. fi
  58. echo "$NAME: Checking for \"./configure\" script ..."
  59. if [ ! -e ./configure ]; then
  60. echo "$NAME: Running \"./autogen.sh\" ..."
  61. [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
  62. fi
  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. # Get target platform information
  86. if [ -r "src/config.h" ]; then
  87. CPU=`grep "HOST_CPU" "src/config.h" | cut -d'"' -f2`
  88. OS=`grep "HOST_OS" "src/config.h" | cut -d'"' -f2`
  89. VENDOR=`grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2`
  90. PLATFORM="$CPU/$VENDOR/$OS"
  91. fi
  92. if [ -z "$PLATFORM" ]; then
  93. PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
  94. fi
  95. # Get compiler information
  96. if [ -r "Makefile" ]; then
  97. CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
  98. $CC --version 2>&1 | grep -i "GCC" >/dev/null
  99. if [ $? -eq 0 ]; then
  100. # GCC, or compiler that mimics GCC
  101. $CC --version 2>&1 | grep -i "Open64" >/dev/null
  102. if [ $? -eq 0 ]; then
  103. COMPILER="Open64"
  104. else
  105. COMPILER=$($CC --version | head -1 \
  106. | cut -d')' -f2 | cut -d' ' -f2)
  107. COMPILER="gcc $COMPILER"
  108. fi
  109. else
  110. # Non-GCC compiler
  111. $CC --version 2>&1 | grep -i "clang" >/dev/null
  112. if [ $? -eq 0 ]; then
  113. COMPILER=$($CC --version 2>/dev/null | head -1 \
  114. | cut -d'(' -f1 | cut -d'-' -f1 \
  115. | sed -e 's/version //g' | sed -e 's/Apple /A-/g' \
  116. | sed -e 's/Debian //g' | sed -e 's/LLVM /clang /g')
  117. fi
  118. $CC -version 2>&1 | grep -i "tcc" >/dev/null
  119. if [ $? -eq 0 ]; then
  120. COMPILER=$($CC -version 2>/dev/null | head -1 \
  121. | cut -d'(' -f1 | sed -e 's/version //g')
  122. fi
  123. if [ "$COMPILER" = "unknown" ]; then
  124. v="`$CC --version 2>/dev/null | head -1`"
  125. [ -z "$v" ] && v="`$CC -version 2>/dev/null | head -1`"
  126. [ -n "$v" ] && COMPILER="$v"
  127. fi
  128. fi
  129. fi
  130. # Get ngIRCd version information
  131. eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
  132. case "$VERSION" in
  133. *-*-*)
  134. VERSION=`echo "$VERSION" | cut -d'-' -f3 | cut -b2-`
  135. ;;
  136. esac
  137. [ -n "$VERSION" ] || VERSION="unknown"
  138. # Get IO interface information
  139. if [ "$OS" = "linux-gnu" ]; then
  140. COMMENT="1"
  141. else
  142. grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
  143. [ $? -eq 0 ] && COMMENT="4"
  144. grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
  145. [ $? -eq 0 ] && COMMENT="5"
  146. grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
  147. [ $? -eq 0 ] && COMMENT="3"
  148. fi
  149. [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
  150. [ -n "$R_MAKE" ] && M="Y" || M="N"
  151. [ -n "$R_CHECK" ] && T="Y" || T="N"
  152. [ -n "$R_RUN" ] && R="Y" || R="N"
  153. [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
  154. echo
  155. echo " the executable works (\"runs\") as expected --+"
  156. echo " tests run successfully (\"make check\") --+ |"
  157. echo " ngIRCd compiles (\"make\") --+ | |"
  158. echo " ./configure works --+ | | |"
  159. echo " | | | |"
  160. echo "Platform Compiler ngIRCd Date Tester C M T R *"
  161. echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
  162. type printf >/dev/null 2>&1
  163. if [ $? -eq 0 ]; then
  164. printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s" \
  165. "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
  166. "$C" "$M" "$T" "$R" "$COMMENT"
  167. else
  168. echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
  169. "$C" "$M" "$T" "$R" "$COMMENT"
  170. fi
  171. echo; echo