make_single_applets.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. | grep -v '^BUSYBOX$' \
  16. | sort | uniq
  17. `"
  18. # Take existing config
  19. test -f .config || { echo "No .config file"; exit 1; }
  20. cfg="`cat .config`"
  21. # Make a config with all applet symbols off
  22. allno="$cfg"
  23. for app in $apps; do
  24. allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
  25. done
  26. #echo "$allno" >.config_allno
  27. trap 'test -f .config.SV && mv .config.SV .config && touch .config' EXIT
  28. # Turn on each applet individually and build single-applet executable
  29. # (give config names on command line to build only those)
  30. test $# = 0 && set -- $apps
  31. fail=0
  32. for app; do
  33. # Only if it was indeed originally enabled...
  34. { echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue
  35. echo "Making ${app}..."
  36. mv .config .config.SV
  37. echo "CONFIG_${app}=y" >.config
  38. echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
  39. if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then
  40. # $allno has all choices for "sh" aliasing set to off.
  41. # "sh" aliasing defaults to "ash", not none.
  42. # without this fix, "make oldconfig" sets it wrong,
  43. # resulting in NUM_APPLETS = 2 (the second applet is "sh")
  44. sed '/CONFIG_SH_IS_NONE/d' -i .config
  45. echo "CONFIG_SH_IS_NONE=y" >>.config
  46. fi
  47. if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
  48. fail=$((fail+1))
  49. echo "Config error for ${app}"
  50. mv .config busybox_config_${app}
  51. elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then
  52. fail=$((fail+1))
  53. grep -i -e error: -e warning: busybox_make_${app}.log
  54. echo "Build error for ${app}"
  55. mv .config busybox_config_${app}
  56. elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
  57. grep -i -e error: -e warning: busybox_make_${app}.log
  58. mv busybox busybox_${app}
  59. fail=$((fail+1))
  60. echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
  61. mv .config busybox_config_${app}
  62. else
  63. grep -i -e error: -e warning: busybox_make_${app}.log \
  64. || rm busybox_make_${app}.log
  65. mv busybox busybox_${app}
  66. #mv .config busybox_config_${app}
  67. fi
  68. mv .config.SV .config
  69. #exit
  70. done
  71. touch .config # or else next "make" can be confused
  72. echo "Failures: $fail"
  73. test $fail = 0 # set exitcode