summaryrefslogtreecommitdiff
path: root/pkg/nginx/modules.awk
blob: 7978f4f32786d7bf3b794cee3d83fb09465145d4 (plain)
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
BEGIN {
	while (getline < sources) {
		if ($0 ~ /^(#|$)/)
			continue
		all_modules[++n] = $1
	}

	enabled["core"] = 1
	enabled["errlog"] = 1
	enabled["conf"] = 1

	enabled["events"] = 1
	enabled["event_core"] = 1
	enabled["epoll"] = 1
}

/^(#|$)/ { next }
{
	enabled[$0] = 1
}

END {
	for (i = 1; i <= n; ++i) {
		module = all_modules[i]
		if (enabled[module])
			modules[++m] = module
	}

	print "#include <ngx_config.h>"
	print "#include <ngx_core.h>"

	for (i = 1; i <= m; ++i)
		print "extern ngx_module_t ngx_" modules[i] "_module;"

	print "ngx_module_t *ngx_modules[] = {"
	for (i = 1; i <= m; ++i)
			print "\t&ngx_" modules[i] "_module,"
	print "\tNULL"
	print "};"

	print "char *ngx_module_names[] = {"
	for (i = 1; i <= m; ++i)
		print "\t\"ngx_" modules[i] "_module\","
	print "\tNULL"
	print "};"
}