Syntax for conditionally installing files in package Makefile

I am adding a CONFIG to a package that results in additional files that need to be installed. Is there a means to examine that CONFIG (in the Package//install section) and only copy over the files if the CONFIG is set?

I'm guessing the package build will fail if the CONFIG is not set, the files aren't there, and I have a fixed copy statement.

Thanks in advance!

After some grepping and a bit of trial and error, all I can come up with is to test the existence of the config-dependent files and transfer them if present (one by one, replacement syntax doesn't work since the if statement is comma-delimited). Kind of hacky but it works. In this case, test if directory exists.

-$(if -d $(PKG_INSTALL_DIR)/<directory to test>,$(CP) $(PKG_INSTALL_DIR)/<file(s) to copy> $(1)/<install location>)

I'm open to something more elegant.

I thought that there would be examples about that, but after a quick search I could not find anything.

Then I started to think and came to conclusion that as the install section is more or less straightforward file/dir structure creation for the final .ipk package, there can't be complex CONFIG logic in it.

I think that a typical elegant approach is to define a separate variant for the more extended package. So that you will have a normal version of the package and the larger version. (like dnsmasq, dnsmasq-full etc.)

@hnyman I came to that conclusion (sort of) as well, but then there was just this commit the other day:

https://git.lede-project.org/?p=source.git;a=commit;h=01337ba472d0661af1e3b397be3c40573e46ea69

I initially thought the CONFIG variables weren't usable here for some reason, but that was due to the copy syntax I was using: {option1,option2,option3} doesn't work since the if statement syntax interprets the first comma as the delimiter between true and false.

I'm going to generate a pull request and creating a separate package seems like overkill -- the difference between dnsmasq and dnsmasq-full are large whereas this is allowing the enabling of features already supported by the init script. I'm thinking the conditional logic is still the right way to go based on the linked precedent -- thoughts?

I don't see how that commit is really relevant. That just adjusts a global setting to store diffconfig output to the built firmware.

Well after looking at it again, it really uses config item for file copy decision at a package install function. I forgot that the commit applied to basefiles install step.