misc/sys/cdefs.h: Add _Noreturn macro for pre-C11 compilers
[glibc.git] / scripts / sysd-rules.awk
blobcc143345c6662536f01a1f60cfe50859fda80a9f
1 # This is a GAWK script to generate the sysd-rules file.
2 # It does not read any input, but it requires that several variables
3 # be set on its command line (using -v) to their makefile counterparts:
4 # all_object_suffixes $(all-object-suffixes)
5 # inhibit_sysdep_asm $(inhibit-sysdep-asm)
6 # config_sysdirs $(config_sysdirs)
7 # sysd_rules_patterns $(sysd-rules-patterns)
9 BEGIN {
10 print "sysd-rules-sysdirs :=", config_sysdirs;
12 nsuffixes = split(all_object_suffixes, suffixes);
13 ninhibit_asm = split(inhibit_sysdep_asm, inhibit_asm);
14 nsysdirs = split(config_sysdirs, sysdirs);
15 npatterns = split(sysd_rules_patterns, patterns);
17 # Each element of $(sysd-rules-patterns) is a pair TARGET:DEP.
18 # They are no in particular order. We need to sort them so that
19 # the longest TARGET is first, and, among elements with the same
20 # TARGET, the longest DEP is first.
21 for (i = 1; i <= npatterns; ++i) {
22 if (split(patterns[i], td, ":") != 2) {
23 msg = "bad sysd-rules-patterns element '" patterns[i] "'";
24 print msg > "/dev/stderr";
25 exit 2;
27 target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
28 dep_order = sprintf("%09d", npatterns - length(td[2]));
29 sort_patterns[target_order SUBSEP dep_order] = patterns[i];
31 asorti(sort_patterns, map_patterns);
32 for (i in map_patterns) {
33 patterns[i] = sort_patterns[map_patterns[i]];
36 for (sysdir_idx = 1; sysdir_idx <= nsysdirs; ++sysdir_idx) {
37 dir = sysdirs[sysdir_idx];
38 if (dir !~ /^\//) dir = "$(..)" dir;
39 asm_rules = 1;
40 for (i = 1; i <= ninhibit_asm; ++i) {
41 if (dir ~ ("^.*sysdeps/" inhibit_asm[i] "$")) {
42 asm_rules = 0;
43 break;
46 for (suffix_idx = 1; suffix_idx <= nsuffixes; ++suffix_idx) {
47 o = suffixes[suffix_idx];
48 for (pattern_idx = 1; pattern_idx <= npatterns; ++pattern_idx) {
49 pattern = patterns[pattern_idx];
50 split(pattern, td, ":");
51 target_pattern = td[1];
52 dep_pattern = td[2];
53 if (target_pattern == "%") {
54 command_suffix = "";
55 } else {
56 prefix = gensub(/%/, "", "", target_pattern);
57 command_suffix = " $(" prefix "CPPFLAGS)";
59 target = "$(objpfx)" target_pattern o ":";
60 if (asm_rules) {
61 dep = dir "/" dep_pattern ".S";
62 print target, dep, "$(before-compile)";
63 print "\t$(compile-command.S)" command_suffix;
65 dep = dir "/" dep_pattern ".c";
66 print target, dep, "$(before-compile)";
67 print "\t$(compile-command.c)" command_suffix;
70 print "$(inst_includedir)/%.h:", dir "/%.h", "$(+force)";
71 print "\t$(do-install)";
74 print "sysd-rules-done := t";
75 exit 0;