randomtest 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. # If not specified in environment...
  3. if ! test "$LIBC"; then
  4. # Select which libc to build against
  5. LIBC="glibc"
  6. LIBC="uclibc"
  7. fi
  8. # x86 32-bit:
  9. #CROSS_COMPILER_PREFIX="i486-linux-uclibc-"
  10. # My system has strange prefix for x86 64-bit uclibc:
  11. #CROSS_COMPILER_PREFIX="x86_64-pc-linux-gnu-"
  12. if test $# -lt 2 || ! test -d "$1" || test -e "$2"; then
  13. echo "Usage: $0 SRC_DIR TMP_DIR"
  14. echo
  15. echo "SRC_DIR will be copied to TMP_DIR directory."
  16. echo "Then a random build will be performed."
  17. echo
  18. echo "Useful variables:"
  19. echo "\$LIBC, \$CROSS_COMPILER_PREFIX, \$MAKEOPTS"
  20. exit 1
  21. fi
  22. cp -dpr -- "$1" "$2" || { echo "copy error"; exit 1; }
  23. cd -- "$2" || { echo "cd $dir error"; exit 1; }
  24. # Generate random config
  25. make randconfig >/dev/null || { echo "randconfig error"; exit 1; }
  26. # Tweak resulting config
  27. cat .config \
  28. | grep -v CONFIG_DEBUG_PESSIMIZE \
  29. | grep -v CONFIG_WERROR \
  30. | grep -v CONFIG_CROSS_COMPILER_PREFIX \
  31. | grep -v CONFIG_SELINUX \
  32. | grep -v CONFIG_EFENCE \
  33. | grep -v CONFIG_DMALLOC \
  34. \
  35. | grep -v CONFIG_RFKILL \
  36. >.config.new
  37. mv .config.new .config
  38. echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config
  39. echo '# CONFIG_WERROR is not set' >>.config
  40. echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config
  41. # If glibc, don't build static
  42. if test x"$LIBC" = x"glibc"; then
  43. cat .config \
  44. | grep -v CONFIG_STATIC \
  45. >.config.new
  46. mv .config.new .config
  47. echo '# CONFIG_STATIC is not set' >>.config
  48. fi
  49. # If glibc, build static, and remove some things
  50. # likely to not work on uclibc.
  51. if test x"$LIBC" = x"uclibc"; then
  52. cat .config \
  53. | grep -v CONFIG_STATIC \
  54. | grep -v CONFIG_BUILD_LIBBUSYBOX \
  55. | grep -v CONFIG_TASKSET \
  56. | grep -v CONFIG_UNICODE_SUPPORT \
  57. | grep -v CONFIG_PIE \
  58. >.config.new
  59. mv .config.new .config
  60. echo 'CONFIG_STATIC=y' >>.config
  61. fi
  62. # If STATIC, remove some things.
  63. # PAM with static linking is probably pointless
  64. # (but I need to try - now I don't have libpam.a on my system, only libpam.so)
  65. if grep -q "^CONFIG_STATIC=y" .config; then
  66. cat .config \
  67. | grep -v CONFIG_PAM \
  68. >.config.new
  69. mv .config.new .config
  70. fi
  71. # Regenerate .config with default answers for yanked-off options
  72. # (most of default answers are "no").
  73. { yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; }
  74. # Build!
  75. nice -n 10 make $MAKEOPTS 2>&1 | tee make.log
  76. # Return exitcode 1 if busybox executable does not exist
  77. test -x busybox