The wildcard function returns sorted results in version 3.81, but it does do that in version 4.2. Is there any compile/runtime switch to control this fucntion?
Below shows the results from two version of GNU make.
$ ls
a.mk a0.svp a1.svp a2.svp a3.svp a4.svp a5.svp a6.svp a7.svp a8.svp a9.svp
$ cat a.mk
SVP_FILES := $(wildcard *.svp)
all:
@echo $(SVP_FILES)
$ make -f a.mk all
a0.svp a1.svp **a2.svp a3.svp a4.svp a5.svp a6.svp a7.svp a8.svp a9.svp**
$ ~/sandbox/bin/make -f a.mk all
a0.svp a1.svp **a6.svp a5.svp a9.svp a4.svp a3.svp a2.svp a7.svp a8.svp**
$make –v | head -n 1
GNU Make 3.81
$ ~/sandbox/bin/make -v | head -n 1
GNU Make 4.2
The wildcard characters in make are ‘*’, ‘?’ and ‘[…]’, the same as in the Bourne shell. For example, *.c specifies a list of all the files (in the working directory) whose names end in ‘.c’. The character ‘~’ at the beginning of a file name also has special significance.
One use of the wildcard function is to get a list of all the C source files in a directory, like this: We can change the list of C source files into a list of object files by replacing the ‘ .c ’ suffix with ‘ .o ’ in the result, like this: (Here we have used another function, patsubst .
The special significance of a wildcard character can be turned off by preceding it with a backslash. Thus, foo*bar would refer to a specific file whose name consists of ‘ foo ’, an asterisk, and ‘ bar ’.
$ (wildcard pattern …) This string, used anywhere in a makefile, is replaced by a space-separated list of names of existing files that match one of the given file name patterns. If no existing file name matches a pattern, then that pattern is omitted from the output of the wildcard function.
GNU make 4.3 has sorted globs again.
In https://savannah.gnu.org/bugs/index.php?52076
It turned out, that nobody knew why the sorting was dropped.
As mentioned in the NEWS file
Version 3.82 (28 Jul 2010)
[...]
- WARNING: Backward-incompatibility! Wildcards were not documented as returning sorted values, but the results have been sorted up until this release.. If your makefiles require sorted results from wildcard expansions, use the
$(sort ...)
function to request it explicitly.
I.e. SVP_FILES := $(sort $(wildcard *.svp))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With