OpenWrt之package: Using Dependencies

OpenWrt之package: Using Dependencies


foreword

In this article, I translated from the OpenWrt document, and I will talk about the analysis of DEPENDS, @, &, there will inevitably be some problems. Welcome to point out that students with English foundation can go straight to the official|| ()

https://openwrt.org/docs/guide-developer/dependencies

https://openwrt.org/docs/guide-developer/packages


Overview/ Topic

A package Makefile includes the following sections:

define Package/tcpdump/default
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+libpcap
  TITLE:=Network monitoring and data acquisition tool
  URL:=http://www.tcpdump.org/
endef

This article will describe what DEPENDS:=+libpcapthe row should look like


Dependency types / Dependency types

  • Not selectable unless libpcapselectedtcpdump
DEPENDS:=libpcap
  • If tcpdumpselected, libpcapwill also be selected
DEPENDS:=+libpcap
  • If tcpdumpit is selected, arpd也会被选中. libpcapIt can be selected at this time, otherwise it cannot be selected.
DEPENDS:=+PACKAGE_arpd:libpcap
  • BUSYBOXHOSTNAMEselect if not innet-tools-hostname
DEPENDS:=+!BUSYBOX_CONFIG_HOSTNAME:net-tools-hostname
  • This option must exist USB_SUPPORT(defined), otherwise you will not see tcpdumpthis option
DEPENDS:=@USB_SUPPORT
  • If tcpdumpselected, KERNEL_DEBUG_FSrelated items (including selected) will be automatically configured.
DEPENDS:=+@KERNEL_DEBUG_FS

Note: opkg installIt will not check KERNEL_DEBUG_FSwhether it is installed when using

  • If net-tools-hostnameit is not selected, BUSYBOX_CONFIG_HOSTNAMErelated items will be automatically configured (including selected).
DEPENDS:=+@!PACKAGE_net-tools-hostname:BUSYBOX_CONFIG_HOSTNAME

Special Instructions / Special Notes

  • You can Makefiledefine one that OpenWrt does not have Package, and DEPENDScall it in
define Package/package-name/config
    ...config stuff
endef

Include the following commands:

Order meaning
select package If tcpdumpchecked, packageit will also be checked.
select package if packageb If packagebselected, packagewill also be selected
select package if SYMBOL Not optional unless CONFIG_SYMBOLdefinedpackage
depends packageb tcpdumpDepends on packageb, not packagebvisible unless selectedtcpdump
depends packageb if packagec If packagecselected, tcpdumpwill depend onpackageb
select SYMBOL If tcpdumpchecked, set to CONFIG_SYMBOL=y.
select SYMBOL if packageb If packagebselected, select SYMBOLthe action to perform
select SYMBOL if SYMBOL2 If SYMBOL2defined, select SYMBOLthe action to perform

It should be noted that when Package/foo/configusing select bar, compile will be selected bar, but when using opkg install foo, there is no need to ensure foowhether it is installed


Warnings/Caveats

Packages and package dependencies cannot depend on each other ( Package Adepend on Package B, Package Bdepend on Package A), this situation is not allowed, if this kind of circular dependency is caused, make menuconfigother problems will occur in time.


Using boolean operators

  • DEPENDS:@SYMBOLand DEPENDS:@SYMBOL:packagesyntactically support the bool operator operation of if, including: !, &&,||

  • DEPENDS:+SYMBOL:packageThe syntax has restrictions on the operation of the bool operator, which !can only be used for the entire condition. 括号It is only for readability, and it has no effect. &&The priority is higher than that ||. So +(YYY||FOO&&BAR):packageif when YYYis selected or FOOboth BARare selected, packageit can be selected.

  • +YYY||(FOO&&BAR):packageFor readability, it could be better

  • But +(YYY||FOO)&&BAR:packagethis parenthesis does not change the priority, 括号it is just for readability and has no effect.


Afterword

The translation is still relatively weak, I don’t know if I can understand it, at least I understand it myself.

Welcome to pay attention to the WeChat public account: NueXiniShare

Enjoy it ~

Guess you like

Origin blog.csdn.net/a924282761/article/details/126316882