platformtest.sh 4.3 KB

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