[LEDE-DEV] Conditional dependencies in Makefiles

Felix Fietkau nbd at nbd.name
Tue Aug 29 12:04:16 PDT 2017


On 2017-08-29 19:08, Ted Hess wrote:
> Hi all -
> 
> I have a package (ffmpeg) build problem which is trying to specify a different
> DEPENDS for soft-float systems and one for hard-float. The package definition is
> as follows:
> 
>> define Package/libffmpeg-full
>> $(call Package/libffmpeg/Default)
>>  TITLE+= (full)
>>  DEPENDS+= @BUILD_PATENTED +alsa-lib +PACKAGE_libopus:libopus
>>  ifeq ($(CONFIG_SOFT_FLOAT),y)
>>         DEPENDS+= +PACKAGE_shine:shine
>>  else
>>         DEPENDS+= +PACKAGE_lame-lib:lame-lib +PACKAGE_libx264:libx264
>>  endif
>>  VARIANT:=full
>> endef
> 
> Thinking the 'ifeq', etc is not proper within a function definition, I have also
> tried:
> 
>   DEPENDS+=$(if $(CONFIG_SOFT_FLOAT),+PACKAGE_shine:shine,+PACKAGE_lame-
> lib:lame-lib +PACKAGE_libx264:libx264)
Please don't introduce dependencies that magically get added based on
whether a different package is selected or not.
Either always use shine, or add a separate option to configure whether
or not it should be used.
Also make sure that anything that affects the build gets proper
treatment in CONFIGURE_ARGS and PKG_CONFIG_DEPENDS.

Aside from that, there is an easy way to deal with conditional
dependencies that depend on multiple options: Just create an
intermediate config symbol via Package/<foo>/config that is hidden and
depends on the relevant multiple config symbols.

- Felix



More information about the Lede-dev mailing list