target_config.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. for package in $profile_packages; do
  20. [ "${package:0:1}" = '-' ] || echo "CONFIG_PACKAGE_${package}=m"
  21. done
  22. echo "CONFIG_TARGET_DEVICE_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=y"
  23. echo "CONFIG_TARGET_DEVICE_PACKAGES_${LEDE_CONFIG_TARGET}_DEVICE_${profile}=\"${profile_packages}\""
  24. }
  25. . scripts/common.inc.sh
  26. config() {
  27. echo "$1"
  28. }
  29. device() {
  30. emit
  31. output="$1"
  32. profile="$3"
  33. if [ -z "$profile" ]; then
  34. profile="$2"
  35. fi
  36. profile_packages="${default_packages} $(site_packages "$output")"
  37. }
  38. packages() {
  39. if [ "${output}" ]; then
  40. profile_packages="${profile_packages} $@"
  41. else
  42. default_packages="${default_packages} $@"
  43. for package in "$@"; do
  44. if [ "${package:0:1}" = '-' ]; then
  45. echo "CONFIG_PACKAGE_${package:1}=m"
  46. else
  47. echo "CONFIG_PACKAGE_${package}=y"
  48. fi
  49. done
  50. fi
  51. }
  52. # The sort will not only remove duplicate entries,
  53. # but also magically make =y entries override =m ones
  54. (. targets/"$1"; emit) | sort -u