2 # Generate sorted list of directories. The sorting is stable but with
3 # dependencies between directories resolved by moving dependees in front.
4 # Copyright (C) 1998-2018 Free Software Foundation, Inc.
5 # Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
8 cnt =
split(subdirs
, all
) + 1
12 # Let input files have comments.
13 { sub(/[ ]*#.*$/, "") }
17 subdir = type =
FILENAME;
18 sub(/^.
*\
//, "", type
);
19 sub(/\
/[^
/]+$
/, "", subdir
);
20 sub(/^.
*\
//, "", subdir
);
24 type ==
"Depend" && NF ==
1 {
31 type ==
"Subdirs" && NF ==
1 { thisdir = $
1 }
33 type ==
"Subdirs" && NF ==
2 && $
1 ==
"first" {
35 # Make the first dir in the list depend on this one.
41 type ==
"Subdirs" && NF ==
2 && $
1 ==
"inhibit" {
46 type ==
"Subdirs" && thisdir
{
49 this_srcdir = srcpfx thisdir
50 if (system("test -d " this_srcdir
) != 0) {
51 print FILENAME ":" FNR ":", "cannot find", this_srcdir
> "/dev/stderr";
54 file = this_srcdir
"/Depend";
55 if (system("test -f " file
) ==
0) {
57 # Emit a dependency on the implicitly-read file.
59 sub(/^\.\.\
//, "", file
);
62 print "$(common-objpfx)sysd-sorted:", "$(wildcard", file
")";
68 print FILENAME ":" FNR ":", "what type of file is this?" > "/dev/stderr";
75 for (i =
0; i
< dnt
; ++i
) {
76 for (j =
1; j
< cnt
; ++j
) {
77 if (all
[j
] == from
[i
]) {
78 for (k = j
+ 1; k
< cnt
; ++k
) {
79 if (all
[k
] == to
[i
]) {
84 for (l = k
- 1; l
>= j
; --l
) {
99 # Make sure we list "elf" last.
101 printf "sorted-subdirs :=";
102 for (i =
1; i
< cnt
; ++i
) {
103 if (all
[i
] in inhibit
)
108 printf " %s", all
[i
];
110 printf "%s\n", saw_elf ?
" elf" : "";
112 print "sysd-sorted-done := t"