diff options
| author | Ron Yorston <rmy@pobox.com> | 2024-06-16 11:29:21 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2024-06-16 11:29:21 +0100 |
| commit | 80b1e4e59d0c36ef0988570d6f32f560c1b7e0ff (patch) | |
| tree | 7a028055e0c58b3fdf28266201922cf7a2b1a41e /miscutils | |
| parent | 51a4aaa27d280bae24c8fbdeb056fb01a6d5e940 (diff) | |
| download | busybox-w32-80b1e4e59d0c36ef0988570d6f32f560c1b7e0ff.tar.gz busybox-w32-80b1e4e59d0c36ef0988570d6f32f560c1b7e0ff.tar.bz2 busybox-w32-80b1e4e59d0c36ef0988570d6f32f560c1b7e0ff.zip | |
make: update default rules
The default rules were changed in the 2024 standard:
- Fortran is no longer supported
- The CC macro is set to 'c17' instead of 'c99'
In addition to these changes, CC is set to 'cc' as a non-POSIX
extension: on my system, at least, there isn't a 'c17' compiler.
Adds 208-224 bytes.
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/make.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 02f90f805..07e83166b 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
| @@ -271,6 +271,7 @@ struct globals { | |||
| 271 | int lineno; // Physical line number in file | 271 | int lineno; // Physical line number in file |
| 272 | int dispno; // Line number for display purposes | 272 | int dispno; // Line number for display purposes |
| 273 | const char *rulepos; | 273 | const char *rulepos; |
| 274 | int rule_idx; | ||
| 274 | #define IF_MAX 10 | 275 | #define IF_MAX 10 |
| 275 | uint8_t clevel; | 276 | uint8_t clevel; |
| 276 | uint8_t cstate[IF_MAX + 1]; | 277 | uint8_t cstate[IF_MAX + 1]; |
| @@ -301,6 +302,7 @@ struct globals { | |||
| 301 | #define lineno (G.lineno) | 302 | #define lineno (G.lineno) |
| 302 | #define dispno (G.dispno) | 303 | #define dispno (G.dispno) |
| 303 | #define rulepos (G.rulepos) | 304 | #define rulepos (G.rulepos) |
| 305 | #define rule_idx (G.rule_idx) | ||
| 304 | #define clevel (G.clevel) | 306 | #define clevel (G.clevel) |
| 305 | #define cstate (G.cstate) | 307 | #define cstate (G.cstate) |
| 306 | #define numjobs (G.numjobs) | 308 | #define numjobs (G.numjobs) |
| @@ -1020,11 +1022,8 @@ dyndep(struct name *np, struct rule *imprule) | |||
| 1020 | } | 1022 | } |
| 1021 | 1023 | ||
| 1022 | #define RULES \ | 1024 | #define RULES \ |
| 1023 | ".SUFFIXES:.o .c .y .l .a .sh .f\n" \ | ||
| 1024 | ".c.o:\n" \ | 1025 | ".c.o:\n" \ |
| 1025 | " $(CC) $(CFLAGS) -c $<\n" \ | 1026 | " $(CC) $(CFLAGS) -c $<\n" \ |
| 1026 | ".f.o:\n" \ | ||
| 1027 | " $(FC) $(FFLAGS) -c $<\n" \ | ||
| 1028 | ".y.o:\n" \ | 1027 | ".y.o:\n" \ |
| 1029 | " $(YACC) $(YFLAGS) $<\n" \ | 1028 | " $(YACC) $(YFLAGS) $<\n" \ |
| 1030 | " $(CC) $(CFLAGS) -c y.tab.c\n" \ | 1029 | " $(CC) $(CFLAGS) -c y.tab.c\n" \ |
| @@ -1045,23 +1044,28 @@ dyndep(struct name *np, struct rule *imprule) | |||
| 1045 | " $(CC) -c $(CFLAGS) $<\n" \ | 1044 | " $(CC) -c $(CFLAGS) $<\n" \ |
| 1046 | " $(AR) $(ARFLAGS) $@ $*.o\n" \ | 1045 | " $(AR) $(ARFLAGS) $@ $*.o\n" \ |
| 1047 | " rm -f $*.o\n" \ | 1046 | " rm -f $*.o\n" \ |
| 1048 | ".f.a:\n" \ | ||
| 1049 | " $(FC) -c $(FFLAGS) $<\n" \ | ||
| 1050 | " $(AR) $(ARFLAGS) $@ $*.o\n" \ | ||
| 1051 | " rm -f $*.o\n" \ | ||
| 1052 | ".c:\n" \ | 1047 | ".c:\n" \ |
| 1053 | " $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<\n" \ | 1048 | " $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<\n" \ |
| 1054 | ".f:\n" \ | ||
| 1055 | " $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $<\n" \ | ||
| 1056 | ".sh:\n" \ | 1049 | ".sh:\n" \ |
| 1057 | " cp $< $@\n" \ | 1050 | " cp $< $@\n" \ |
| 1058 | " chmod a+x $@\n" | 1051 | " chmod a+x $@\n" |
| 1059 | 1052 | ||
| 1053 | #define RULES_2017 \ | ||
| 1054 | ".SUFFIXES:.o .c .y .l .a .sh .f\n" \ | ||
| 1055 | ".f.o:\n" \ | ||
| 1056 | " $(FC) $(FFLAGS) -c $<\n" \ | ||
| 1057 | ".f.a:\n" \ | ||
| 1058 | " $(FC) -c $(FFLAGS) $<\n" \ | ||
| 1059 | " $(AR) $(ARFLAGS) $@ $*.o\n" \ | ||
| 1060 | " rm -f $*.o\n" \ | ||
| 1061 | ".f:\n" \ | ||
| 1062 | " $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $<\n" | ||
| 1063 | |||
| 1064 | #define RULES_2024 \ | ||
| 1065 | ".SUFFIXES:.o .c .y .l .a .sh\n" | ||
| 1066 | |||
| 1060 | #define MACROS \ | 1067 | #define MACROS \ |
| 1061 | "CC=c99\n" \ | ||
| 1062 | "CFLAGS=-O1\n" \ | 1068 | "CFLAGS=-O1\n" \ |
| 1063 | "FC=fort77\n" \ | ||
| 1064 | "FFLAGS=-O1\n" \ | ||
| 1065 | "YACC=yacc\n" \ | 1069 | "YACC=yacc\n" \ |
| 1066 | "YFLAGS=\n" \ | 1070 | "YFLAGS=\n" \ |
| 1067 | "LEX=lex\n" \ | 1071 | "LEX=lex\n" \ |
| @@ -1070,6 +1074,17 @@ dyndep(struct name *np, struct rule *imprule) | |||
| 1070 | "ARFLAGS=-rv\n" \ | 1074 | "ARFLAGS=-rv\n" \ |
| 1071 | "LDFLAGS=\n" | 1075 | "LDFLAGS=\n" |
| 1072 | 1076 | ||
| 1077 | #define MACROS_2017 \ | ||
| 1078 | "CC=c99\n" \ | ||
| 1079 | "FC=fort77\n" \ | ||
| 1080 | "FFLAGS=-O1\n" \ | ||
| 1081 | |||
| 1082 | #define MACROS_2024 \ | ||
| 1083 | "CC=c17\n" | ||
| 1084 | |||
| 1085 | #define MACROS_EXT \ | ||
| 1086 | "CC=cc\n" | ||
| 1087 | |||
| 1073 | /* | 1088 | /* |
| 1074 | * Read the built-in rules using a fake fgets-like interface. | 1089 | * Read the built-in rules using a fake fgets-like interface. |
| 1075 | */ | 1090 | */ |
| @@ -1078,8 +1093,28 @@ getrules(char *s, int size) | |||
| 1078 | { | 1093 | { |
| 1079 | char *r = s; | 1094 | char *r = s; |
| 1080 | 1095 | ||
| 1081 | if (rulepos == NULL) | 1096 | if (rulepos == NULL || *rulepos == '\0') { |
| 1082 | rulepos = (RULES MACROS) + (norules ? sizeof(RULES) - 1 : 0); | 1097 | if (rule_idx == 0) { |
| 1098 | rulepos = MACROS; | ||
| 1099 | rule_idx++; | ||
| 1100 | } else if (rule_idx == 1) { | ||
| 1101 | if (POSIX_2017) | ||
| 1102 | rulepos = MACROS_2017; | ||
| 1103 | else if (posix) | ||
| 1104 | rulepos = MACROS_2024; | ||
| 1105 | else | ||
| 1106 | rulepos = MACROS_EXT; | ||
| 1107 | rule_idx++; | ||
| 1108 | } else if (!norules) { | ||
| 1109 | if (rule_idx == 2) { | ||
| 1110 | rulepos = POSIX_2017 ? RULES_2017 : RULES_2024; | ||
| 1111 | rule_idx++; | ||
| 1112 | } else if (rule_idx == 3) { | ||
| 1113 | rulepos = RULES; | ||
| 1114 | rule_idx++; | ||
| 1115 | } | ||
| 1116 | } | ||
| 1117 | } | ||
| 1083 | 1118 | ||
| 1084 | if (*rulepos == '\0') | 1119 | if (*rulepos == '\0') |
| 1085 | return NULL; | 1120 | return NULL; |
