1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package main
type Toplevel struct {
previousSubdir string
subdirs []string
}
func CheckdirToplevel() {
if G.opts.Debug {
defer tracecall1(G.CurrentDir)()
}
ctx := new(Toplevel)
fname := G.CurrentDir + "/Makefile"
lines := LoadNonemptyLines(fname, true)
if lines == nil {
return
}
for _, line := range lines {
if m, commentedOut, indentation, subdir, comment := match4(line.Text, `^(#?)SUBDIR\s*\+=(\s*)(\S+)\s*(?:#\s*(.*?)\s*|)$`); m {
ctx.checkSubdir(line, commentedOut == "#", indentation, subdir, comment)
}
}
NewMkLines(lines).Check()
if G.opts.Recursive {
if G.opts.CheckGlobal {
G.UsedLicenses = make(map[string]bool)
G.Hash = make(map[string]*Hash)
}
G.Todo = append(G.Todo, ctx.subdirs...)
}
}
func (ctx *Toplevel) checkSubdir(line *Line, commentedOut bool, indentation, subdir, comment string) {
if commentedOut && comment == "" {
line.Warn1("%q commented out without giving a reason.", subdir)
}
if indentation != "\t" {
line.Warn0("Indentation should be a single tab character.")
}
if contains(subdir, "$") || !fileExists(G.CurrentDir+"/"+subdir+"/Makefile") {
return
}
prev := ctx.previousSubdir
switch {
case subdir > prev:
// Correctly ordered
case subdir == prev:
line.Error0("Each subdir must only appear once.")
case subdir == "archivers" && prev == "x11":
// This exception is documented in the top-level Makefile.
default:
line.Warn2("%s should come before %s", subdir, prev)
}
ctx.previousSubdir = subdir
if !commentedOut {
ctx.subdirs = append(ctx.subdirs, G.CurrentDir+"/"+subdir)
}
}
|