platformtest.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/bin/sh
  2. #
  3. # ngIRCd -- The Next Generation IRC Daemon
  4. # Copyright (c)2001-2011 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 \"./autogen.sh\" script ..."
  50. if [ -r ./autogen.sh ]; then
  51. echo "$NAME: Running \"./autogen.sh\" ..."
  52. [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
  53. fi
  54. if [ -r ./configure ]; then
  55. echo "$NAME: Running \"./configure\" script ..."
  56. [ -n "$VERBOSE" ] && ./configure || ./configure >/dev/null
  57. if [ $? -eq 0 -a -r ./Makefile ]; then
  58. R_CONFIGURE=1
  59. echo "$NAME: Running \"$MAKE\" ..."
  60. [ -n "$VERBOSE" ] && "$MAKE" || "$MAKE" >/dev/null
  61. if [ $? -eq 0 -a -x src/ngircd/ngircd ]; then
  62. R_MAKE=1
  63. echo "$NAME: Running \"$MAKE check\" ..."
  64. [ -n "$VERBOSE" ] && "$MAKE" check || "$MAKE" check >/dev/null
  65. if [ $? -eq 0 ]; then
  66. R_CHECK=1
  67. R_RUN=$R_CHECK
  68. else
  69. ./src/ngircd/ngircd --help 2>/dev/null \
  70. | grep "^ngircd" >/dev/null
  71. [ $? -eq 0 ] && R_RUN=1
  72. fi
  73. fi
  74. fi
  75. fi
  76. # Get target platform information
  77. if [ -r "src/config.h" ]; then
  78. CPU=`grep "TARGET_CPU" "src/config.h" | cut -d'"' -f2`
  79. OS=`grep "TARGET_OS" "src/config.h" | cut -d'"' -f2`
  80. VENDOR=`grep "TARGET_VENDOR" "src/config.h" | cut -d'"' -f2`
  81. PLATFORM="$CPU/$VENDOR/$OS"
  82. fi
  83. if [ -z "$PLATFORM" ]; then
  84. PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
  85. fi
  86. # Get compiler information
  87. if [ -r "Makefile" ]; then
  88. CC=$(grep "^CC = " Makefile | cut -d' ' -f3)
  89. $CC --version 2>&1 | grep -i "GCC" >/dev/null
  90. if [ $? -eq 0 ]; then
  91. $CC --version 2>&1 | grep -i "Open64" >/dev/null
  92. if [ $? -eq 0 ]; then
  93. COMPILER="Open64"
  94. else
  95. COMPILER=$($CC --version | head -1 \
  96. | cut -d')' -f2 | cut -d' ' -f2)
  97. COMPILER="gcc $COMPILER"
  98. fi
  99. else
  100. case "$CC" in
  101. gcc*)
  102. v="`$CC --version 2>/dev/null | head -1`"
  103. [ -n "$v" ] && COMPILER="gcc $v"
  104. ;;
  105. esac
  106. fi
  107. fi
  108. # Get ngIRCd version information
  109. eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
  110. case "$VERSION" in
  111. *-*-*)
  112. VERSION=`echo "$VERSION" | cut -d'-' -f3 | cut -b2-`
  113. ;;
  114. esac
  115. [ -n "$VERSION" ] || VERSION="unknown"
  116. # Get IO interface information
  117. if [ "$OS" = "linux-gnu" ]; then
  118. COMMENT="(1)"
  119. else
  120. grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
  121. [ $? -eq 0 ] && COMMENT="(4)"
  122. grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
  123. [ $? -eq 0 ] && COMMENT="(5)"
  124. grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
  125. [ $? -eq 0 ] && COMMENT="(3)"
  126. fi
  127. [ -n "$R_CONFIGURE" ] && C="Y" || C="N"
  128. [ -n "$R_MAKE" ] && M="Y" || M="N"
  129. [ -n "$R_CHECK" ] && T="Y" || T="N"
  130. [ -n "$R_RUN" ] && R="Y" || R="N"
  131. [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
  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. type printf >/dev/null 2>&1
  141. if [ $? -eq 0 ]; then
  142. printf "%-27s %-12s %-10s %s %-6s %s %s %s %s%s" \
  143. "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
  144. "$C" "$M" "$T" "$R" "$COMMENT"
  145. else
  146. echo "$PLATFORM $COMPILER $VERSION $DATE $USER" \
  147. "$C" "$M" "$T" "$R" "$COMMENT"
  148. fi
  149. echo; echo