| @@ -1,123 +1,123 @@ | | | @@ -1,123 +1,123 @@ |
1 | $NetBSD: patch-imake.c,v 1.7 2016/09/04 21:33:53 dholland Exp $ | | 1 | $NetBSD: patch-imake.c,v 1.8 2022/10/21 08:51:19 wiz Exp $ |
2 | | | 2 | |
3 | Beat some sense in. | | 3 | Beat some sense in. |
4 | | | 4 | |
5 | - Generate all files into the current (build) directory, not /tmp. | | 5 | - Generate all files into the current (build) directory, not /tmp. |
6 | (hunks 1-2) | | 6 | (hunks 1-2) |
7 | | | 7 | |
8 | - Do not delete any of the temporary files, to allow analysis after | | 8 | - Do not delete any of the temporary files, to allow analysis after |
9 | build failure. (hunks 3-4, first part of 9) | | 9 | build failure. (hunks 3-4, first part of 9) |
10 | | | 10 | |
11 | - Log the command lines executed. (hunk 6) | | 11 | - Log the command lines executed. (hunk 6) |
12 | | | 12 | |
13 | - Warn if scrubbing the Imakefile to alert the user to check if that | | 13 | - Warn if scrubbing the Imakefile to alert the user to check if that |
14 | broke it (second part of hunk 9) | | 14 | broke it (second part of hunk 9) |
15 | | | 15 | |
16 | Also, | | 16 | Also, |
17 | | | 17 | |
18 | - Use tradcpp's -debuglog feature to trace what happens in the | | 18 | - Use tradcpp's -debuglog feature to trace what happens in the |
19 | templates (hunk 5) | | 19 | templates (hunk 5) |
20 | | | 20 | |
21 | - Force ELF for freebsd versions >= 6 (hunk 7) | | 21 | - Force ELF for freebsd versions >= 6 (hunk 7) |
22 | | | 22 | |
23 | - Force use of just "gcc" for pkgsrc, so as to not bypass the | | 23 | - Force use of just "gcc" for pkgsrc, so as to not bypass the |
24 | wrappers (hunk 8) | | 24 | wrappers (hunk 8) |
25 | | | 25 | |
26 | --- imake.c.orig 2013-08-17 10:11:50.000000000 +0000 | | 26 | --- imake.c.orig 2022-10-19 17:33:50.000000000 +0000 |
27 | +++ imake.c | | 27 | +++ imake.c |
28 | @@ -303,9 +303,9 @@ void KludgeOutputLine(char **), KludgeRe | | 28 | @@ -303,9 +303,9 @@ void KludgeOutputLine(char **), KludgeRe |
29 | const char *cpp = NULL; | | 29 | const char *cpp = NULL; |
30 | | | 30 | |
31 | const char *tmpMakefile; | | 31 | const char *tmpMakefile; |
32 | -const char *tmpMakefileTemplate = "/tmp/Imf.XXXXXX"; | | 32 | -const char *tmpMakefileTemplate = "/tmp/Imf.XXXXXX"; |
33 | +const char *tmpMakefileTemplate = ".imake.Makefile.XXXXXX"; | | 33 | +const char *tmpMakefileTemplate = ".imake.Makefile.XXXXXX"; |
34 | const char *tmpImakefile; | | 34 | const char *tmpImakefile; |
35 | -const char *tmpImakefileTemplate = "/tmp/IIf.XXXXXX"; | | 35 | -const char *tmpImakefileTemplate = "/tmp/IIf.XXXXXX"; |
36 | +const char *tmpImakefileTemplate = ".imake.Imakefile.XXXXXX"; | | 36 | +const char *tmpImakefileTemplate = ".imake.Imakefile.XXXXXX"; |
37 | const char *make_argv[ ARGUMENTS ] = { | | 37 | const char *make_argv[ ARGUMENTS ] = { |
38 | #ifdef WIN32 | | 38 | #ifdef WIN32 |
39 | "nmake" | | 39 | "nmake" |
40 | @@ -319,7 +319,7 @@ int cpp_argindex; | | 40 | @@ -319,7 +319,7 @@ int cpp_argindex; |
41 | const char *Imakefile = NULL; | | 41 | const char *Imakefile = NULL; |
42 | const char *Makefile = "Makefile"; | | 42 | const char *Makefile = "Makefile"; |
43 | const char *Template = "Imake.tmpl"; | | 43 | const char *Template = "Imake.tmpl"; |
44 | -const char *ImakefileC = "Imakefile.c"; | | 44 | -const char *ImakefileC = "Imakefile.c"; |
45 | +const char *ImakefileC = ".imake.start.c"; | | 45 | +const char *ImakefileC = ".imake.start.c"; |
46 | boolean haveImakefileC = FALSE; | | 46 | boolean haveImakefileC = FALSE; |
47 | const char *cleanedImakefile = NULL; | | 47 | const char *cleanedImakefile = NULL; |
48 | const char *program; | | 48 | const char *program; |
49 | @@ -412,7 +412,8 @@ main(int argc, char *argv[]) | | 49 | @@ -407,7 +407,8 @@ main(int argc, char *argv[]) |
50 | fd = mkstemp(tmpMakefileName); | | 50 | |
51 | if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) { | | 51 | if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) { |
52 | if (fd != -1) { | | 52 | if (fd != -1) { |
53 | - unlink(tmpMakefileName); close(fd); | | 53 | - unlink(tmpMakefileName); close(fd); |
54 | + /*unlink(tmpMakefileName);*/ | | 54 | + /*unlink(tmpMakefileName);*/ |
55 | + close(fd); | | 55 | + close(fd); |
56 | } | | 56 | } |
57 | LogFatal("Cannot create temporary file %s.", tmpMakefileName); | | 57 | LogFatal("Cannot create temporary file %s.", tmpMakefileName); |
58 | } | | 58 | } |
59 | @@ -454,12 +455,14 @@ showit(FILE *fd) | | 59 | @@ -449,12 +450,14 @@ showit(FILE *fd) |
60 | void | | 60 | void |
61 | wrapup(void) | | 61 | wrapup(void) |
62 | { | | 62 | { |
63 | +#if 0 | | 63 | +#if 0 |
64 | if (tmpMakefile != Makefile) | | 64 | if (tmpMakefile != Makefile) |
65 | unlink(tmpMakefile); | | 65 | unlink(tmpMakefile); |
66 | if (cleanedImakefile && cleanedImakefile != Imakefile) | | 66 | if (cleanedImakefile && cleanedImakefile != Imakefile) |
67 | unlink(cleanedImakefile); | | 67 | unlink(cleanedImakefile); |
68 | if (haveImakefileC) | | 68 | if (haveImakefileC) |
69 | unlink(ImakefileC); | | 69 | unlink(ImakefileC); |
70 | +#endif | | 70 | +#endif |
71 | } | | 71 | } |
72 | | | 72 | |
73 | #ifdef SIGNALRETURNSINT | | 73 | void |
74 | @@ -488,6 +491,10 @@ init(void) | | 74 | @@ -479,6 +482,10 @@ init(void) |
75 | while (cpp_argv[ cpp_argindex ] != NULL) | | 75 | while (cpp_argv[ cpp_argindex ] != NULL) |
76 | cpp_argindex++; | | 76 | cpp_argindex++; |
77 | | | 77 | |
78 | + /* pkgsrc: generate a debug trace of reading the templates */ | | 78 | + /* pkgsrc: generate a debug trace of reading the templates */ |
79 | + AddCppArg("-debuglog"); | | 79 | + AddCppArg("-debuglog"); |
80 | + AddCppArg(".imake.cpplog"); | | 80 | + AddCppArg(".imake.cpplog"); |
81 | + | | 81 | + |
82 | #if defined CROSSCOMPILE | | 82 | #if defined CROSSCOMPILE |
83 | if (sys == netBSD) | | 83 | if (sys == netBSD) |
84 | if (CrossCompiling) { | | 84 | if (CrossCompiling) { |
85 | @@ -773,6 +780,13 @@ doit(FILE *outfd, const char *cmd, const | | 85 | @@ -764,6 +771,13 @@ doit(FILE *outfd, const char *cmd, const |
86 | { | | 86 | { |
87 | int pid; | | 87 | int pid; |
88 | waitType status; | | 88 | waitType status; |
89 | + unsigned i; | | 89 | + unsigned i; |
90 | + | | 90 | + |
91 | + fprintf(stderr, "imake: executing:"); | | 91 | + fprintf(stderr, "imake: executing:"); |
92 | + for (i=0; argv[i]; i++) { | | 92 | + for (i=0; argv[i]; i++) { |
93 | + fprintf(stderr, " %s", argv[i]); | | 93 | + fprintf(stderr, " %s", argv[i]); |
94 | + } | | 94 | + } |
95 | + fprintf(stderr, "\n"); | | 95 | + fprintf(stderr, "\n"); |
96 | | | 96 | |
97 | /* | | 97 | /* |
98 | * Fork and exec the command. | | 98 | * Fork and exec the command. |
99 | @@ -1158,7 +1172,9 @@ get_binary_format(FILE *inFile) | | 99 | @@ -1149,7 +1163,9 @@ get_binary_format(FILE *inFile) |
100 | } else | | 100 | } else |
101 | strcpy (cmd, "objformat"); | | 101 | strcpy (cmd, "objformat"); |
102 | | | 102 | |
103 | - if (osrel >= 300004 && | | 103 | - if (osrel >= 300004 && |
104 | + if (osrel >= 600000) | | 104 | + if (osrel >= 600000) |
105 | + iself = 1; | | 105 | + iself = 1; |
106 | + else if (osrel >= 300004 && | | 106 | + else if (osrel >= 300004 && |
107 | (objprog = popen(cmd, "r")) != NULL && | | 107 | (objprog = popen(cmd, "r")) != NULL && |
108 | fgets(buf, sizeof(buf), objprog) != NULL && | | 108 | fgets(buf, sizeof(buf), objprog) != NULL && |
109 | strncmp(buf, "elf", 3) == 0) | | 109 | strncmp(buf, "elf", 3) == 0) |
110 | @@ -1337,54 +1353,8 @@ get_gcc_version(FILE *inFile, char *name | | 110 | @@ -1328,54 +1344,8 @@ get_gcc_version(FILE *inFile, char *name |
111 | static boolean | | 111 | static boolean |
112 | get_gcc(char *cmd) | | 112 | get_gcc(char *cmd) |
113 | { | | 113 | { |
114 | - struct stat sb; | | 114 | - struct stat sb; |
115 | - static const char* gcc_path[] = { | | 115 | - static const char* gcc_path[] = { |
116 | -#if defined(linux) || \ | | 116 | -#if defined(linux) || \ |
117 | - defined(__NetBSD__) || \ | | 117 | - defined(__NetBSD__) || \ |
118 | - defined(__OpenBSD__) || \ | | 118 | - defined(__OpenBSD__) || \ |
119 | - defined(__FreeBSD__) || \ | | 119 | - defined(__FreeBSD__) || \ |
120 | - defined(__DragonFly__) || \ | | 120 | - defined(__DragonFly__) || \ |
121 | - defined(__APPLE__) || \ | | 121 | - defined(__APPLE__) || \ |
122 | - defined(__CYGWIN__) || \ | | 122 | - defined(__CYGWIN__) || \ |
123 | - defined(__MINGW32__) || \ | | 123 | - defined(__MINGW32__) || \ |
| @@ -127,54 +127,54 @@ Also, | | | @@ -127,54 +127,54 @@ Also, |
127 | -#endif | | 127 | -#endif |
128 | - "/usr/local/bin/gcc", | | 128 | - "/usr/local/bin/gcc", |
129 | - "/opt/gnu/bin/gcc", | | 129 | - "/opt/gnu/bin/gcc", |
130 | - "/usr/pkg/bin/gcc" | | 130 | - "/usr/pkg/bin/gcc" |
131 | - }; | | 131 | - }; |
132 | - | | 132 | - |
133 | -#ifdef CROSSCOMPILE | | 133 | -#ifdef CROSSCOMPILE |
134 | - static const char* cross_cc_name[] = { | | 134 | - static const char* cross_cc_name[] = { |
135 | - "cc", | | 135 | - "cc", |
136 | - "gcc" | | 136 | - "gcc" |
137 | - }; | | 137 | - }; |
138 | - | | 138 | - |
139 | - if (CrossCompiling) { | | 139 | - if (CrossCompiling) { |
140 | - int i; | | 140 | - unsigned int i; |
141 | - for (i = 0; i < sizeof (cross_cc_name) / sizeof cross_cc_name[0]; i++){ | | 141 | - for (i = 0; i < sizeof (cross_cc_name) / sizeof cross_cc_name[0]; i++){ |
142 | - strcpy (cmd, CrossCompileDir); | | 142 | - strcpy (cmd, CrossCompileDir); |
143 | - strcat (cmd, "/"); | | 143 | - strcat (cmd, "/"); |
144 | - strcat (cmd, cross_cc_name[i]); | | 144 | - strcat (cmd, cross_cc_name[i]); |
145 | - if (lstat (cmd, &sb) == 0) { | | 145 | - if (lstat (cmd, &sb) == 0) { |
146 | - return TRUE; | | 146 | - return TRUE; |
147 | - break; | | 147 | - break; |
148 | - } | | 148 | - } |
149 | - } | | 149 | - } |
150 | - } else | | 150 | - } else |
151 | -#endif | | 151 | -#endif |
152 | - { | | 152 | - { |
153 | - int i; | | 153 | - unsigned int i; |
154 | - for (i = 0; i < sizeof (gcc_path) / sizeof gcc_path[0]; i++) { | | 154 | - for (i = 0; i < sizeof (gcc_path) / sizeof gcc_path[0]; i++) { |
155 | - if (lstat (gcc_path[i], &sb) == 0) { | | 155 | - if (lstat (gcc_path[i], &sb) == 0) { |
156 | - strcpy (cmd, gcc_path[i]); | | 156 | - strcpy (cmd, gcc_path[i]); |
157 | - return TRUE; | | 157 | - return TRUE; |
158 | - } | | 158 | - } |
159 | - } | | 159 | - } |
160 | - } | | 160 | - } |
161 | - return FALSE; | | 161 | - return FALSE; |
162 | + strcpy(cmd, "gcc"); | | 162 | + strcpy(cmd, "gcc"); |
163 | + return TRUE; | | 163 | + return TRUE; |
164 | } | | 164 | } |
165 | | | 165 | |
166 | #ifdef CROSSCOMPILE | | 166 | #ifdef CROSSCOMPILE |
167 | @@ -1795,12 +1765,15 @@ CleanCppInput(const char *imakefile) | | 167 | @@ -1786,12 +1756,15 @@ CleanCppInput(const char *imakefile) |
168 | outFile = fdopen(fd, "w"); | | 168 | outFile = fdopen(fd, "w"); |
169 | if (outFile == NULL) { | | 169 | if (outFile == NULL) { |
170 | if (fd != -1) { | | 170 | if (fd != -1) { |
171 | - unlink(tmpImakefileName); close(fd); | | 171 | - unlink(tmpImakefileName); close(fd); |
172 | + /*unlink(tmpImakefileName);*/ | | 172 | + /*unlink(tmpImakefileName);*/ |
173 | + close(fd); | | 173 | + close(fd); |
174 | } | | 174 | } |
175 | LogFatal("Cannot open %s for write.", | | 175 | LogFatal("Cannot open %s for write.", |
176 | tmpImakefileName); | | 176 | tmpImakefileName); |
177 | } | | 177 | } |
178 | #endif | | 178 | #endif |
179 | + fprintf(stderr, "%s: Warning: cleaning Imakefile\n", | | 179 | + fprintf(stderr, "%s: Warning: cleaning Imakefile\n", |
180 | + program); | | 180 | + program); |