target_config.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bash
  2. set -e
  3. [ "$LEDE_TARGET" ] || exit 1
  4. output=
  5. profile=
  6. default_packages=
  7. profile_packages=
  8. LEDE_CONFIG_TARGET="${LEDE_TARGET//-/_}"
  9. site_packages() {
  10. MAKEFLAGS= make PROFILE="$1" --no-print-directory -s -f - <<'END_MAKE'
  11. include $(GLUON_SITEDIR)/site.mk
  12. all:
  13. echo '$(GLUON_$(PROFILE)_SITE_PACKAGES)'
  14. END_MAKE
  15. }
  16. emit() {
  17. [ "${output}" ] || return 0
  18. want_device "${output}" || return 0
  19. profile_packages="${profile_packages} $(site_packages "$output")"
  20. for package in $profile_packages; do
  21. [ "${package:0:1}" = '-' ] || echo "CONFIG_PACKAGE_${package}=m"
  22. done
  23. echo "CONFIG_TARGET_DEVICE_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=y"
  24. echo "CONFIG_TARGET_DEVICE_PACKAGES_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=\"${profile_packages}\""
  25. }
  26. . scripts/common.inc.sh
  27. config() {
  28. echo "$1"
  29. }
  30. device() {
  31. emit
  32. output="$1"
  33. profile="$3"
  34. if [ -z "$profile" ]; then
  35. profile="$2"
  36. fi
  37. profile_packages="${default_packages}"
  38. }
  39. packages() {
  40. if [ "${output}" ]; then
  41. profile_packages="${profile_packages} $@"
  42. else
  43. default_packages="${default_packages} $@"
  44. for package in "$@"; do
  45. if [ "${package:0:1}" = '-' ]; then
  46. echo "CONFIG_PACKAGE_${package:1}=m"
  47. else
  48. echo "CONFIG_PACKAGE_${package}=y"
  49. fi
  50. done
  51. fi
  52. }
  53. # The sort will not only remove duplicate entries,
  54. # but also magically make =y entries override =m ones
  55. (. targets/"$1"; emit) | sort -u