platformtest.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #!/bin/sh
  2. #
  3. # ngIRCd -- The Next Generation IRC Daemon
  4. # Copyright (c)2001-2014 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. echo "$NAME: Checking ngIRCd base source directory ..."
  51. grep "ngIRCd" "$SRC_D/ChangeLog" >/dev/null 2>&1
  52. if [ $? -ne 0 ]; then
  53. grep "ngIRCd" "$SRC_D/../ChangeLog" >/dev/null 2>&1
  54. if [ $? -ne 0 ]; then
  55. echo "$NAME: ngIRCd base source directory not found!?"
  56. exit 1
  57. fi
  58. SRC_D="$SRC_D/.."
  59. fi
  60. echo "$NAME: - source directory: $SRC_D"
  61. echo "$NAME: - working directory: $MY_D"
  62. echo "$NAME: Checking for GIT tree ..."
  63. if [ -d "$SRC_D/.git" ]; then
  64. echo "$NAME: Checking for \"git\" command ..."
  65. git version >/dev/null 2>&1
  66. if [ $? -eq 0 -a -n "$CLEAN" ]; then
  67. echo "$NAME: Running \"git clean\" ..."
  68. cd "$SRC_D" || exit 1
  69. [ -n "$VERBOSE" ] && git clean -dxf || git clean -dxf >/dev/null
  70. cd "$MY_D" || exit 1
  71. fi
  72. fi
  73. echo "$NAME: Checking for \"$SRC_D/configure\" script ..."
  74. if [ ! -r "$SRC_D/configure" ]; then
  75. echo "$NAME: Running \"$SRC_D/autogen.sh\" ..."
  76. cd "$SRC_D" || exit 1
  77. [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
  78. cd "$MY_D" || exit 1
  79. fi
  80. if [ -r "$SRC_D/configure" ]; then
  81. echo "$NAME: Running \"$SRC_D/configure\" script ..."
  82. [ -n "$VERBOSE" ] && "$SRC_D/configure" -C || "$SRC_D/configure" -C >/dev/null
  83. if [ $? -eq 0 -a -r ./Makefile ]; then
  84. R_CONFIGURE=1
  85. echo "$NAME: Running \"$MAKE\" ..."
  86. [ -n "$VERBOSE" ] && "$MAKE" || "$MAKE" >/dev/null
  87. if [ $? -eq 0 -a -x src/ngircd/ngircd ]; then
  88. R_MAKE=1
  89. echo "$NAME: Running \"$MAKE check\" ..."
  90. [ -n "$VERBOSE" ] && "$MAKE" check || "$MAKE" check >/dev/null
  91. if [ $? -eq 0 ]; then
  92. R_CHECK=1
  93. R_RUN=$R_CHECK
  94. [ -r ./src/testsuite/tests-skipped.lst ] \
  95. && R_CHECK_Y="y" || R_CHECK_Y="Y"
  96. else
  97. ./src/ngircd/ngircd --help 2>/dev/null \
  98. | grep "^ngIRCd" >/dev/null
  99. [ $? -eq 0 ] && R_RUN=1
  100. fi
  101. fi
  102. fi
  103. fi
  104. # Get target platform information
  105. if [ -r "src/config.h" ]; then
  106. CPU=`grep "HOST_CPU" "src/config.h" | cut -d'"' -f2`
  107. OS=`grep "HOST_OS" "src/config.h" | cut -d'"' -f2`
  108. VENDOR=`grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2`
  109. PLATFORM="$CPU/$VENDOR/$OS"
  110. fi
  111. if [ -z "$PLATFORM" ]; then
  112. PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
  113. fi
  114. # Get compiler information
  115. if [ -r "Makefile" ]; then
  116. CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
  117. $CC --version 2>&1 | grep -i "GCC" >/dev/null
  118. if [ $? -eq 0 ]; then
  119. # GCC, or compiler that mimics GCC
  120. $CC --version 2>&1 | grep -i "Open64" >/dev/null
  121. if [ $? -eq 0 ]; then
  122. COMPILER="Open64"
  123. else
  124. COMPILER=$($CC --version | head -1 \
  125. | cut -d')' -f2 | cut -d' ' -f2)
  126. COMPILER="gcc $COMPILER"
  127. fi
  128. else
  129. # Non-GCC compiler
  130. $CC --version 2>&1 | grep -i "clang" >/dev/null
  131. if [ $? -eq 0 ]; then
  132. COMPILER=$($CC --version 2>/dev/null | head -1 \
  133. | cut -d'(' -f1 | cut -d'-' -f1 \
  134. | sed -e 's/version //g' | sed -e 's/Apple /A-/g' \
  135. | sed -e 's/Debian //g' | sed -e 's/LLVM /clang /g')
  136. fi
  137. $CC -version 2>&1 | grep -i "tcc" >/dev/null
  138. if [ $? -eq 0 ]; then
  139. COMPILER=$($CC -version 2>/dev/null | head -1 \
  140. | cut -d'(' -f1 | sed -e 's/version //g')
  141. fi
  142. if [ "$COMPILER" = "unknown" ]; then
  143. v="`$CC --version 2>/dev/null | head -1`"
  144. [ -z "$v" ] && v="`$CC -version 2>/dev/null | head -1`"
  145. [ -n "$v" ] && COMPILER="$v"
  146. fi
  147. fi
  148. fi
  149. # Get ngIRCd version information
  150. eval "$(grep "^VERSION = " Makefile | sed -e 's/ //g')"
  151. case "$VERSION" in
  152. *~*-*)
  153. VERSION=`echo "$VERSION" | cut -b1-10`
  154. ;;
  155. esac
  156. [ -n "$VERSION" ] || VERSION="unknown"
  157. # Get IO interface information
  158. if [ "$OS" = "linux-gnu" ]; then
  159. COMMENT="1"
  160. else
  161. grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
  162. [ $? -eq 0 ] && COMMENT="4"
  163. grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
  164. [ $? -eq 0 ] && COMMENT="5"
  165. grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
  166. [ $? -eq 0 ] && COMMENT="3"
  167. fi
  168. [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
  169. [ -n "$R_MAKE" ] && M="Y" || M="N"
  170. [ -n "$R_CHECK" ] && T="$R_CHECK_Y" || T="N"
  171. [ -n "$R_RUN" ] && R="Y" || R="N"
  172. [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
  173. echo
  174. echo " the executable works (\"runs\") as expected --+"
  175. echo " tests run successfully (\"make check\") --+ |"
  176. echo " ngIRCd compiles (\"make\") --+ | |"
  177. echo " ./configure works --+ | | |"
  178. echo " | | | |"
  179. echo "Platform Compiler ngIRCd Date Tester C M T R *"
  180. echo "--------------------------- ------------ ---------- -------- -------- - - - - -"
  181. type printf >/dev/null 2>&1
  182. if [ $? -eq 0 ]; then
  183. printf "%-27s %-12s %-10s %s %-8s %s %s %s %s%s\n" \
  184. "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
  185. "$C" "$M" "$T" "$R" "$COMMENT"
  186. else
  187. echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
  188. "$C" "$M" "$T" "$R" "$COMMENT"
  189. fi
  190. echo
  191. if [ "$R_CHECK_Y" = "y" ]; then
  192. echo "$NAME: Warning: Some tests have been skipped!"
  193. echo
  194. fi