从目录中获取所有文件时如何对 makefile 中的先决条件进行排序?

How to sort prerequisites in makefile when getting all files from directory?

我刚开始使用 makefile。当 运行 "example" 我想将每个文件从 INSTANCEDIR 目录发送到函数 "func",所以我使用 $^。像这样:

example: $(INSTANCEDIR)/*
    $(call func, $^, main)

但是,文件未按排序顺序排列。我想按字母顺序处理文件。我该怎么做?

使用$(sort):

example: $(INSTANCEDIR)/*
    $(call func, $(sort $^), main)