How to generate list of make targets automatically by globbing subdirectories?

前端 未结 1 513
感情败类
感情败类 2021-01-11 16:31

I would like to use a single Makefile to generate targets in hundreds of subdirectories. Each subdirectory is a date/time stamp like this: 20120119_153957, whic

相关标签:
1条回答
  • 2021-01-11 16:42

    In your example glob matching is performed by the shell.

    GNU Make has the built-in wildcard function, which you can use as follows:

    SUBDIRS := $(wildcard ????????_??????)
    

    Now you can use this variable to construct a list of targets:

    .PHONY : all
    all : $(SUBDIRS:%=%/graph.pdf)
    
    %/graph.pdf : # list prerequisites here.
        # recipe to make '$@' in directory '$(@D)' from '$^'.
    

    See also: pattern rules, automatic variables.

    0 讨论(0)
提交回复
热议问题