1
0

platformtest.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #!/bin/sh
  2. #
  3. # ngIRCd -- The Next Generation IRC Daemon
  4. # Copyright (c)2001-2016 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. CLEAN=1
  18. PLATFORM=
  19. COMPILER="unknown"
  20. VERSION="unknown"
  21. DATE=$(date "+%y-%m-%d")
  22. COMMENT=
  23. R_CONFIGURE=
  24. R_MAKE=
  25. R_CHECK=
  26. R_CHECK_Y="?"
  27. R_RUN=
  28. SRC_D=$(dirname "$0")
  29. MY_D="$PWD"
  30. [ -n "$MAKE" ] || MAKE="make"
  31. export MAKE CC
  32. while [ $# -gt 0 ]; do
  33. case "$1" in
  34. "-v")
  35. VERBOSE=1
  36. ;;
  37. "-x")
  38. CLEAN=
  39. ;;
  40. *)
  41. echo "Usage: $NAME [-v] [-x]"
  42. echo
  43. echo " -v Verbose output"
  44. echo " -x Don't regenerate build system, even when possible"
  45. echo
  46. exit 2
  47. esac
  48. shift
  49. done
  50. for cmd in telnet expect; do
  51. command -v "$cmd" >/dev/null 2>&1 \
  52. || echo "$NAME: WARNING: $cmd(1) not found, \"make check\" won't run all tests!"
  53. done
  54. echo "$NAME: Checking ngIRCd base source directory ..."
  55. grep "ngIRCd" "$SRC_D/ChangeLog" >/dev/null 2>&1
  56. if [ $? -ne 0 ]; then
  57. grep "ngIRCd" "$SRC_D/../ChangeLog" >/dev/null 2>&1
  58. if [ $? -ne 0 ]; then
  59. echo "$NAME: ngIRCd base source directory not found!?"
  60. exit 1
  61. fi
  62. SRC_D="$SRC_D/.."
  63. fi
  64. echo "$NAME: - source directory: $SRC_D"
  65. echo "$NAME: - working directory: $MY_D"
  66. echo "$NAME: Checking for GIT tree ..."
  67. if [ -d "$SRC_D/.git" ]; then
  68. echo "$NAME: Checking for \"git\" command ..."
  69. git version >/dev/null 2>&1
  70. if [ $? -eq 0 ] && [ -n "$CLEAN" ]; then
  71. echo "$NAME: Running \"git clean\" ..."
  72. cd "$SRC_D" || exit 1
  73. if [ -n "$VERBOSE" ]; then
  74. git clean -dxf
  75. else
  76. git clean -dxf >/dev/null
  77. fi
  78. cd "$MY_D" || exit 1
  79. fi
  80. fi
  81. echo "$NAME: Checking for \"$SRC_D/configure\" script ..."
  82. if [ ! -r "$SRC_D/configure" ]; then
  83. echo "$NAME: Running \"$SRC_D/autogen.sh\" ..."
  84. cd "$SRC_D" || exit 1
  85. if [ -n "$VERBOSE" ]; then
  86. ./autogen.sh
  87. else
  88. ./autogen.sh >/dev/null
  89. fi
  90. if [ $? -ne 0 ]; then
  91. echo "$NAME: \"$SRC_D/autogen.sh\" script failed, aborting!"
  92. exit 1
  93. fi
  94. cd "$MY_D" || exit 1
  95. fi
  96. if [ -r "$SRC_D/configure" ]; then
  97. echo "$NAME: Running \"$SRC_D/configure\" script ..."
  98. if [ -n "$VERBOSE" ]; then
  99. "$SRC_D/configure" -C
  100. else
  101. "$SRC_D/configure" -C >/dev/null
  102. fi
  103. if [ $? -eq 0 ] && [ -r ./Makefile ]; then
  104. R_CONFIGURE=1
  105. rm -f "src/ngircd/ngircd"
  106. echo "$NAME: Running \"$MAKE\" ..."
  107. if [ -n "$VERBOSE" ]; then
  108. "$MAKE"
  109. else
  110. "$MAKE" >/dev/null
  111. fi
  112. if [ $? -eq 0 ] && [ -x src/ngircd/ngircd ]; then
  113. R_MAKE=1
  114. echo "$NAME: Running \"$MAKE check\" ..."
  115. if [ -n "$VERBOSE" ]; then
  116. "$MAKE" check
  117. else
  118. "$MAKE" check >/dev/null
  119. fi
  120. if [ $? -eq 0 ]; then
  121. R_CHECK=1
  122. R_RUN=$R_CHECK
  123. [ -r ./src/testsuite/tests-skipped.lst ] \
  124. && R_CHECK_Y="y" || R_CHECK_Y="Y"
  125. else
  126. ./src/ngircd/ngircd --help 2>/dev/null \
  127. | grep "^ngIRCd" >/dev/null
  128. [ $? -eq 0 ] && R_RUN=1
  129. fi
  130. fi
  131. fi
  132. fi
  133. # Get target platform information
  134. if [ -r "src/config.h" ]; then
  135. CPU=$(grep "HOST_CPU" "src/config.h" | cut -d'"' -f2)
  136. OS=$(grep "HOST_OS" "src/config.h" | cut -d'"' -f2)
  137. VENDOR=$(grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2)
  138. PLATFORM="$CPU/$VENDOR/$OS"
  139. fi
  140. if [ -z "$PLATFORM" ]; then
  141. PLATFORM="$(uname 2>/dev/null) $(uname -r 2>/dev/null), $(uname -m 2>/dev/null)"
  142. fi
  143. # Get compiler information
  144. if [ -r "Makefile" ]; then
  145. CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
  146. $CC --version 2>&1 | grep -i "GCC" >/dev/null
  147. if [ $? -eq 0 ]; then
  148. # GCC, or compiler that mimics GCC
  149. $CC --version 2>&1 | grep -i "Open64" >/dev/null
  150. if [ $? -eq 0 ]; then
  151. COMPILER="Open64"
  152. else
  153. COMPILER=$($CC --version | head -1 \
  154. | cut -d')' -f2 | cut -d' ' -f2)
  155. COMPILER="gcc $COMPILER"
  156. fi
  157. else
  158. # Non-GCC compiler
  159. $CC --version 2>&1 | grep -i "clang" >/dev/null
  160. if [ $? -eq 0 ]; then
  161. COMPILER=$($CC --version 2>/dev/null | head -1 \
  162. | cut -d'(' -f1 | cut -d'-' -f1 \
  163. | sed -e 's/version //g; s/^\([A-Z]\)[A-Za-z]* clang/\1-clang/g; s/LLVM /clang /g')
  164. fi
  165. $CC -version 2>&1 | grep -i "tcc" >/dev/null
  166. if [ $? -eq 0 ]; then
  167. COMPILER=$($CC -version 2>/dev/null | head -1 \
  168. | cut -d'(' -f1 | sed -e 's/version //g')
  169. fi
  170. if [ "$COMPILER" = "unknown" ]; then
  171. v="$($CC --version 2>/dev/null | head -1)"
  172. [ -z "$v" ] && v="$($CC -version 2>/dev/null | head -1)"
  173. [ -n "$v" ] && COMPILER="$v"
  174. fi
  175. fi
  176. fi
  177. # Get ngIRCd version information
  178. eval "$(grep "^VERSION = " Makefile | sed -e 's/ //g')"
  179. case "$VERSION" in
  180. *~*-*)
  181. VERSION=$(echo "$VERSION" | cut -b1-10)
  182. ;;
  183. esac
  184. [ -n "$VERSION" ] || VERSION="unknown"
  185. # Get IO interface information
  186. if [ "$OS" = "linux-gnu" ]; then
  187. COMMENT="1"
  188. else
  189. grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
  190. [ $? -eq 0 ] && COMMENT="4"
  191. grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
  192. [ $? -eq 0 ] && COMMENT="5"
  193. grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
  194. [ $? -eq 0 ] && COMMENT="3"
  195. fi
  196. [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
  197. [ -n "$R_MAKE" ] && M="Y" || M="N"
  198. [ -n "$R_CHECK" ] && T="$R_CHECK_Y" || T="N"
  199. if [ -n "$R_RUN" ]; then
  200. # Mark "runs" with "Y" only when the test suite succeeded:
  201. [ "$T" = "N" ] && R="?" || R="Y"
  202. else
  203. R="N"
  204. fi
  205. [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
  206. echo
  207. echo " the executable works (\"runs\") as expected --+"
  208. echo " tests run successfully (\"make check\") --+ |"
  209. echo " ngIRCd compiles (\"make\") --+ | |"
  210. echo " ./configure works --+ | | |"
  211. echo " | | | |"
  212. echo "Platform Compiler ngIRCd Date Tester C M T R *"
  213. echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
  214. command -v printf >/dev/null 2>&1
  215. if [ $? -eq 0 ]; then
  216. printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s\n" \
  217. "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$LOGNAME" \
  218. "$C" "$M" "$T" "$R" "$COMMENT"
  219. else
  220. echo "$PLATFORM $COMPILER $VERSION $DATE $LOGNAME" \
  221. "$C" "$M" "$T" "$R" "$COMMENT"
  222. fi
  223. echo
  224. double_check() {
  225. echo "Please double check that the ngIRCd daemon starts up, runs and handles IRC"
  226. echo "connections successfully!"
  227. }
  228. if [ "$R_CHECK_Y" = "y" ]; then
  229. echo "WARNING: Some tests have been skipped!"
  230. double_check
  231. echo
  232. fi
  233. if [ "$R" = "?" ]; then
  234. echo "WARNING: The resulting binary passed simple tests, but the test suite failed!"
  235. double_check
  236. echo
  237. fi