|
From: | Sean Hammond |
Subject: | Get a target's prerequisites from an external script? |
Date: | Fri, 15 Jul 2022 20:25:37 +0100 |
User-agent: | Cyrus-JMAP/3.7.0-alpha0-755-g3e1da8b93f-fm-20220708.002-g3e1da8b9 |
Is it possible to generate the list of prerequisites for a class of targets from an external command? For example Python requirements.txt files (of the type compiled by pip-compile [1]) can import other requirements files with lines like "-r other.txt" or "-c other.txt". I'm no UNIX wizard but it seems easy to get a list of the other requirements files that a given requirements file (foo.txt in this example) depends on with a command like: grep --color=never '^[[:blank:]]*-r\|^[[:blank:]]*-c' foo.in | sed 's/^[[:blank:]]*\(-r\|-c\)[[:blank:]]*//' I want to get my Makefile to use this command to automatically figure out the prerequisites of any requirements/*.txt file. This is what I tried: requirements/%.txt: requirements/$(shell grep --color=never '^[[:blank:]]*-r\|^[[:blank:]]*-c' requirements/%.in | sed 's/^[[:blank:]]*\(-r\|-c\)[[:blank:]]*//') But it doesn't work: grep: %.in: No such file or directory It seems that make didn't expand the % within the $(shell ...) command. I couldn't find a way to get this to work. Is it possible? Thanks [1]: https://pip-tools.readthedocs.io/ <https://pip-tools.readthedocs.io/en/latest/>
[Prev in Thread] | Current Thread | [Next in Thread] |