platformtest.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/sh
  2. #
  3. # ngIRCd -- The Next Generation IRC Daemon
  4. # Copyright (c)2001-2009 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 ./configure script ..."
  48. if [ ! -e ./configure ]; then
  49. echo "$NAME: Not found. Running ./autogen.sh ..."
  50. [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
  51. fi
  52. if [ -e ./configure ]; then
  53. echo "$NAME: Running \"./configure\" script ..."
  54. [ -n "$VERBOSE" ] && ./configure || ./configure >/dev/null
  55. if [ $? -eq 0 -a -e ./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. eval $(grep "^CC = " Makefile | sed -e 's/ //g')
  87. $CC --version 2>&1 | grep -i "GCC" >/dev/null
  88. if [ $? -eq 0 ]; then
  89. COMPILER=$($CC --version | head -n 1 | awk "{ print \$3 }" \
  90. | cut -d'-' -f1)
  91. COMPILER="gcc $COMPILER"
  92. fi
  93. fi
  94. # Get ngIRCd version information
  95. if [ -d ".git" ]; then
  96. VERSION=`git log --abbrev-commit --pretty=oneline HEAD~1.. \
  97. | cut -d' ' -f1 | tr -d '.'`
  98. elif [ -r "Makefile" ]; then
  99. eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
  100. fi
  101. [ -n "$VERSION" ] || VERSION="unknown"
  102. # Get IO interface information
  103. if [ "$OS" = "linux-gnu" ]; then
  104. COMMENT="(1)"
  105. else
  106. grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
  107. [ $? -eq 0 ] && COMMENT="(4)"
  108. grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
  109. [ $? -eq 0 ] && COMMENT="(5)"
  110. grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
  111. [ $? -eq 0 ] && COMMENT="(3)"
  112. fi
  113. [ -n "$CONFIGURE" ] && C="Y" || C="N"
  114. [ -n "$MAKE" ] && M="Y" || M="N"
  115. [ -n "$CHECK" ] && T="Y" || T="N"
  116. [ -n "$RUN" ] && R="Y" || R="N"
  117. [ -n "$COMMENT" ] && COMMENT=" $COMMENT"
  118. echo
  119. echo " the executable works (\"runs\") as expected --+"
  120. echo " tests run successfully (\"make check\") --+ |"
  121. echo " ngIRCd compiles (\"make\") --+ | |"
  122. echo " ./configure works --+ | | |"
  123. echo " | | | |"
  124. echo "Platform Compiler ngIRCd Date Tester C M T R See"
  125. echo "--------------------------- ------------ ---------- -------- ------ - - - - ---"
  126. printf "%-27s %-12s %-10s %s %-6s %s %s %s %s%s" \
  127. "$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
  128. "$C" "$M" "$T" "$R" "$COMMENT"
  129. echo; echo