make_single_applets.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. # This script expects that the tree was built with the desired .config:
  3. # in particular, it expects that include/applets.h is generated already.
  4. #
  5. # The script will try to rebuild each enabled applet in isolation.
  6. # All other options which chose general bbox config, applet features, etc,
  7. # are not modified for the builds.
  8. makeopts="-j9"
  9. # The list of all applet config symbols
  10. test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
  11. apps="`
  12. grep ^IF_ include/applets.h \
  13. | grep -v ^IF_FEATURE_ \
  14. | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
  15. | sort | uniq
  16. `"
  17. # Take existing config
  18. test -f .config || { echo "No .config file"; exit 1; }
  19. cfg="`cat .config`"
  20. # Make a config with all applet symbols off
  21. allno="$cfg"
  22. for app in $apps; do
  23. allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
  24. done
  25. #echo "$allno" >.config_allno
  26. # Turn on each applet individually and build single-applet executable
  27. fail=0
  28. for app in $apps; do
  29. # Only if it was indeed originally enabled...
  30. { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue
  31. echo "Making ${app}..."
  32. mv .config .config.SV
  33. echo "CONFIG_${app}=y" >.config
  34. echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
  35. if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then
  36. # $allno has all choices for "sh" aliasing set to off.
  37. # "sh" aliasing defaults to "ash", not none.
  38. # without this fix, "make oldconfig" sets it wrong,
  39. # resulting in NUM_APPLETS = 2 (the second applet is "sh")
  40. sed '/CONFIG_SH_IS_NONE/d' -i .config
  41. echo "CONFIG_SH_IS_NONE=y" >>.config
  42. fi
  43. if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
  44. : $((fail++))
  45. echo "Config error for ${app}"
  46. mv .config busybox_config_${app}
  47. elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then
  48. : $((fail++))
  49. echo "Build error for ${app}"
  50. mv .config busybox_config_${app}
  51. elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
  52. mv busybox busybox_${app}
  53. : $((fail++))
  54. echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
  55. mv .config busybox_config_${app}
  56. else
  57. mv busybox busybox_${app}
  58. rm busybox_make_${app}.log
  59. fi
  60. mv .config.SV .config
  61. #exit
  62. done
  63. touch .config # or else next "make" can be confused
  64. echo "Failures: $fail"
  65. test $fail = 0 # set exitcode