Can you do $ (wildcard% / ** / *. C) in the makefile?

Following this question , there is another case that I was unable to figure out for a few hours after fiddling around.

This is what the makefile looks like:

output = $(shell find lib -type f -name '*build.js' -or -name '*build.css')
myth = ./node_modules/.bin/myth
duo = ./node_modules/.bin/duo

build: $(output)

%/build/build.js: %/index.js %/lib/*.js node_modules component.json
  @mkdir -p '$(@D)'
  @$(duo) '$*'/index.js > '$@'

%/build/build.css: %/index.css %/lib/*.css node_modules component.json
  @mkdir -p '$(@D)'
  @$(duo) '$*'/index.css | $(myth) > '$@'

node_modules: package.json
  @n 0.11.13
  @npm install
  @touch node_modules # make sure folder is updated later than package.json

      

A piece that I've added in addition to the more answers in that other question, it is %/lib/*.js

, and %/lib/*.css

right here:

%/build/build.js: %/index.js %/lib/*.js node_modules component.json

      

This works fine if you have all the files you need, which means the directory structure looks like this:

component.json
lib/
lib/page/
lib/page/build/
lib/page/build/build.js
lib/page/index.js
lib/page/lib/
lib/page/lib/a.js
lib/page/lib/b.js
lib/popup/
lib/popup/build/
lib/popup/build/build.js
lib/popup/index.js
lib/popup/lib/
lib/popup/lib/a.js
lib/popup/lib/b.js
node_modules/
package.json

      

With this current make task it will restore the corresponding subproject / folder (page / popup / etc.) If you change a file inside that folder. However, it does not recover if you are missing one of the dependencies.

For example, in the following folder structure, the "popup" subproject will build fine (since it still has all the required target dependencies). However, the page subproject will never be created because it is missing files %/lib/*.js

:

component.json
lib/
lib/page/
lib/page/build/
lib/page/build/build.js
lib/page/index.js
lib/popup/
lib/popup/build/
lib/popup/build/build.js
lib/popup/index.js
lib/popup/lib/
lib/popup/lib/a.js
lib/popup/lib/b.js
node_modules/
package.json

      

So in this situation the only way it will build is to have %/index.js

and some file that matches %/lib/*.js

.

My question is, how do you make it work in both cases?

Basically all I want is to rebuild the subproject if any of the files other than those contained in the build / build.js file. That is, if any file has changed that does not match the target name, run the task.

How do you do it?

I've tried this:

%/build/build.js: %/**/*.js node_modules component.json

      

But these are errors with this:

make: Circular lib/page/build/build.js <- lib/page/build/build.js dependency dropped.

      

As it matches the target name.

It also seems that one can use $(filter pattern, text)

or $(filter-out, pattern, text)

, but I have not been successful with them.

%/build/build.js: $(filter-out %/build/build.js, %/**/*.js) node_modules component.json

      

It seemed like it could include all the files that matched %/**/*.js

(so lib/page/index.js

and lib/page/lib/a.js

if they were present) and just exclude lib/page/build/build.js

. But I have no luck with this, maybe I am just using it wrong.

How do you get it?

+1
unix wildcard makefile


source to share


No one has answered this question yet

See similar questions:

3
How to remove duplicate Makefile?
0
Can you use% inside $ (shell find) in Make?

or similar:

2858
How can I print JSON in a shell script?
1709
How can I profile C ++ code running on Linux?
1124
What is the purpose of .PHONY in a makefile?
731
What are the dark corners of Wim that your mom never talked about?
631
wildcard * in CSS for classes
540
What is the difference between the variable assignments of the GNU Makefile = ,? = ,: = AND + =?
361
What do the makefile symbols $ @ and $ <mean mean?
293
makefile: 4: *** missing separator. Stop
285
gcc makefile error: "There is no rule to create a target ..."
282
How to make a SIMPLE C ++ Makefile



All Articles
Loading...
X
Show
Funny
Dev
Pics