Wildcard Sort Order

1 minute read

A number of differences exist between GNU Make and eMake regarding the use of $(wildcard) and prerequisite wildcard sort order functions. When using the $(wildcard) function or using a wildcard in the rule prerequisite list, the resultant wildcard sort order might be different for GNU Make and eMake.

Different GNU Make versions are not consistent and exhibit permuted file lists. Even a GNU Make version using different system libraries versions will exhibit inconsistencies in the wildcard sort order.

No difference exists in the file list returned, other than the order. If the sort order is important, you might wrap $(wildcard) with $(sort).

For example:

$(sort $(wildcard *.foo))

Do not rely on the order of rule prerequisites generated with a wildcard. For example, using target: *.foo.

Relying on the order of *.foo can be dangerous for both GNU Make and eMake. Neither GNU Make nor eMake guarantees the order in which those prerequisites are executed.