diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-02-01 22:07:58 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-14 15:14:30 +0100 |
commit | c56f1e06c4c470a023b02c7019112eb852f08d44 (patch) | |
tree | 96139e253d0ce2e2fb95bdd42af7b31f737fe393 | |
parent | b41c851312876dbf146fb674265b86c72ed611ab (diff) | |
download | busybox-w32-c56f1e06c4c470a023b02c7019112eb852f08d44.tar.gz busybox-w32-c56f1e06c4c470a023b02c7019112eb852f08d44.tar.bz2 busybox-w32-c56f1e06c4c470a023b02c7019112eb852f08d44.zip |
kbuild: support at least non-interactive mode on Windows
without POSIX, kbuild has some trouble compiling its support
executables. Luckily, the parts that really lean on POSIX functionality
are pretty much all only needed when configuring the build
interactively.
When compiling BusyBox for Win32, we do not actually need interactive
configuration at all: we simply choose the default. Therefore, a lot of
the stuff that is typically built for the Kconfig system is totally
unnecessary (such as: compiling documentation via fork()&exec(), changing
the window size, etc).
Liberally put all of the problematic code behind #ifndef __MINGW32__
guards, just to get `make mingw64_defconfig` going in Git for Windows'
SDK (which is a special-purpose version of MSYS2).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
-rw-r--r-- | scripts/basic/docproc.c | 15 | ||||
-rw-r--r-- | scripts/basic/split-include.c | 13 | ||||
-rw-r--r-- | scripts/kconfig/conf.c | 15 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 21 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 15 |
5 files changed, 76 insertions, 3 deletions
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index 720098a23..bfc1a9844 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c | |||
@@ -38,7 +38,9 @@ | |||
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <limits.h> | 39 | #include <limits.h> |
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
41 | #ifndef __MINGW32__ | ||
41 | #include <sys/wait.h> | 42 | #include <sys/wait.h> |
43 | #endif | ||
42 | //bbox disabled: #include <alloca.h> | 44 | //bbox disabled: #include <alloca.h> |
43 | 45 | ||
44 | /* exitstatus is used to keep track of any failing calls to kernel-doc, | 46 | /* exitstatus is used to keep track of any failing calls to kernel-doc, |
@@ -78,12 +80,24 @@ void usage (void) | |||
78 | */ | 80 | */ |
79 | void exec_kernel_doc(char **svec) | 81 | void exec_kernel_doc(char **svec) |
80 | { | 82 | { |
83 | #ifndef __MINGW32__ | ||
81 | pid_t pid; | 84 | pid_t pid; |
82 | int ret; | 85 | int ret; |
86 | #endif | ||
83 | char *real_filename; | 87 | char *real_filename; |
84 | int rflen; | 88 | int rflen; |
85 | 89 | ||
86 | /* Make sure output generated so far are flushed */ | 90 | /* Make sure output generated so far are flushed */ |
91 | #ifdef __MINGW32__ | ||
92 | fflush(stdout); | ||
93 | rflen = strlen(getenv("SRCTREE")); | ||
94 | rflen += strlen(KERNELDOCPATH KERNELDOC); | ||
95 | real_filename = alloca(rflen + 1); | ||
96 | strcpy(real_filename, getenv("SRCTREE")); | ||
97 | strcat(real_filename, KERNELDOCPATH KERNELDOC); | ||
98 | fprintf(stderr, "NOTIMPL: exec %s\n", real_filename); | ||
99 | exit(1); | ||
100 | #else | ||
87 | fflush(stdout); | 101 | fflush(stdout); |
88 | switch(pid=fork()) { | 102 | switch(pid=fork()) { |
89 | case -1: | 103 | case -1: |
@@ -106,6 +120,7 @@ void exec_kernel_doc(char **svec) | |||
106 | exitstatus |= WEXITSTATUS(ret); | 120 | exitstatus |= WEXITSTATUS(ret); |
107 | else | 121 | else |
108 | exitstatus = 0xff; | 122 | exitstatus = 0xff; |
123 | #endif | ||
109 | } | 124 | } |
110 | 125 | ||
111 | /* Types used to create list of all exported symbols in a number of files */ | 126 | /* Types used to create list of all exported symbols in a number of files */ |
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c index e328788e2..8127fe261 100644 --- a/scripts/basic/split-include.c +++ b/scripts/basic/split-include.c | |||
@@ -39,8 +39,6 @@ | |||
39 | exit(1); \ | 39 | exit(1); \ |
40 | } | 40 | } |
41 | 41 | ||
42 | |||
43 | |||
44 | int main(int argc, const char * argv []) | 42 | int main(int argc, const char * argv []) |
45 | { | 43 | { |
46 | const char * str_my_name; | 44 | const char * str_my_name; |
@@ -89,7 +87,11 @@ int main(int argc, const char * argv []) | |||
89 | /* Make output directory if needed. */ | 87 | /* Make output directory if needed. */ |
90 | if (stat(str_dir_config, &stat_buf) != 0) | 88 | if (stat(str_dir_config, &stat_buf) != 0) |
91 | { | 89 | { |
90 | #ifdef __MINGW32__ | ||
91 | if (mkdir(str_dir_config) != 0) | ||
92 | #else | ||
92 | if (mkdir(str_dir_config, 0755) != 0) | 93 | if (mkdir(str_dir_config, 0755) != 0) |
94 | #endif | ||
93 | ERROR_EXIT(str_dir_config); | 95 | ERROR_EXIT(str_dir_config); |
94 | } | 96 | } |
95 | 97 | ||
@@ -148,7 +150,12 @@ int main(int argc, const char * argv []) | |||
148 | { | 150 | { |
149 | ptarget[islash] = '\0'; | 151 | ptarget[islash] = '\0'; |
150 | if (stat(ptarget, &stat_buf) != 0 | 152 | if (stat(ptarget, &stat_buf) != 0 |
151 | && mkdir(ptarget, 0755) != 0) | 153 | #ifdef __MINGW32__ |
154 | && mkdir(ptarget) != 0 | ||
155 | #else | ||
156 | && mkdir(ptarget, 0755) != 0 | ||
157 | #endif | ||
158 | ) | ||
152 | ERROR_EXIT( ptarget ); | 159 | ERROR_EXIT( ptarget ); |
153 | ptarget[islash] = '/'; | 160 | ptarget[islash] = '/'; |
154 | } | 161 | } |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index ea2446a89..41ac23936 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -153,9 +153,14 @@ static void conf_askvalue(struct symbol *sym, const char *def) | |||
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | case set_random: | 155 | case set_random: |
156 | #ifdef __MINGW32__ | ||
157 | fprintf(stderr, "set_random not supported\n"); | ||
158 | exit(1); | ||
159 | #else | ||
156 | do { | 160 | do { |
157 | val = (tristate)(random() % 3); | 161 | val = (tristate)(random() % 3); |
158 | } while (!sym_tristate_within_range(sym, val)); | 162 | } while (!sym_tristate_within_range(sym, val)); |
163 | #endif | ||
159 | switch (val) { | 164 | switch (val) { |
160 | case no: line[0] = 'n'; break; | 165 | case no: line[0] = 'n'; break; |
161 | case mod: line[0] = 'm'; break; | 166 | case mod: line[0] = 'm'; break; |
@@ -366,7 +371,12 @@ static int conf_choice(struct menu *menu) | |||
366 | continue; | 371 | continue; |
367 | break; | 372 | break; |
368 | case set_random: | 373 | case set_random: |
374 | #ifdef __MINGW32__ | ||
375 | fprintf(stderr, "set_random not supported\n"); | ||
376 | exit(1); | ||
377 | #else | ||
369 | def = (random() % cnt) + 1; | 378 | def = (random() % cnt) + 1; |
379 | #endif | ||
370 | case set_default: | 380 | case set_default: |
371 | case set_yes: | 381 | case set_yes: |
372 | case set_mod: | 382 | case set_mod: |
@@ -522,8 +532,13 @@ int main(int ac, char **av) | |||
522 | input_mode = set_yes; | 532 | input_mode = set_yes; |
523 | break; | 533 | break; |
524 | case 'r': | 534 | case 'r': |
535 | #ifdef __MINGW32__ | ||
536 | fprintf(stderr, "set_random not supported\n"); | ||
537 | exit(1); | ||
538 | #else | ||
525 | input_mode = set_random; | 539 | input_mode = set_random; |
526 | srandom(time(NULL)); | 540 | srandom(time(NULL)); |
541 | #endif | ||
527 | break; | 542 | break; |
528 | case 'h': | 543 | case 'h': |
529 | case '?': | 544 | case '?': |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index e2e6ca8c7..d3ad12d90 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -12,8 +12,10 @@ | |||
12 | /* On Darwin, this may be needed to get SIGWINCH: */ | 12 | /* On Darwin, this may be needed to get SIGWINCH: */ |
13 | #define _DARWIN_C_SOURCE 1 | 13 | #define _DARWIN_C_SOURCE 1 |
14 | 14 | ||
15 | #ifndef __MINGW32__ | ||
15 | #include <sys/ioctl.h> | 16 | #include <sys/ioctl.h> |
16 | #include <sys/wait.h> | 17 | #include <sys/wait.h> |
18 | #endif | ||
17 | #include <ctype.h> | 19 | #include <ctype.h> |
18 | #include <errno.h> | 20 | #include <errno.h> |
19 | #include <fcntl.h> | 21 | #include <fcntl.h> |
@@ -23,7 +25,9 @@ | |||
23 | #include <stdlib.h> | 25 | #include <stdlib.h> |
24 | #include <string.h> | 26 | #include <string.h> |
25 | #include <strings.h> /* for strcasecmp */ | 27 | #include <strings.h> /* for strcasecmp */ |
28 | #ifndef __MINGW32__ | ||
26 | #include <termios.h> | 29 | #include <termios.h> |
30 | #endif | ||
27 | #include <unistd.h> | 31 | #include <unistd.h> |
28 | #include <locale.h> | 32 | #include <locale.h> |
29 | 33 | ||
@@ -266,11 +270,15 @@ static char input_buf[4096]; | |||
266 | static const char filename[] = ".config"; | 270 | static const char filename[] = ".config"; |
267 | static char *args[1024], **argptr = args; | 271 | static char *args[1024], **argptr = args; |
268 | static int indent; | 272 | static int indent; |
273 | #ifndef __MINGW32__ | ||
269 | static struct termios ios_org; | 274 | static struct termios ios_org; |
275 | #endif | ||
270 | static int rows = 0, cols = 0; | 276 | static int rows = 0, cols = 0; |
271 | static struct menu *current_menu; | 277 | static struct menu *current_menu; |
272 | static int child_count; | 278 | static int child_count; |
279 | #ifndef __MINGW32__ | ||
273 | static int do_resize; | 280 | static int do_resize; |
281 | #endif | ||
274 | static int single_menu_mode; | 282 | static int single_menu_mode; |
275 | 283 | ||
276 | static void conf(struct menu *menu); | 284 | static void conf(struct menu *menu); |
@@ -290,6 +298,9 @@ static int cprint(const char *fmt, ...); | |||
290 | 298 | ||
291 | static void init_wsize(void) | 299 | static void init_wsize(void) |
292 | { | 300 | { |
301 | #ifdef __MINGW32__ | ||
302 | fprintf(stderr, "Skipping attempt to change window size\n"); | ||
303 | #else | ||
293 | struct winsize ws; | 304 | struct winsize ws; |
294 | char *env; | 305 | char *env; |
295 | 306 | ||
@@ -321,6 +332,7 @@ static void init_wsize(void) | |||
321 | 332 | ||
322 | rows -= 4; | 333 | rows -= 4; |
323 | cols -= 5; | 334 | cols -= 5; |
335 | #endif | ||
324 | } | 336 | } |
325 | 337 | ||
326 | static void cprint_init(void) | 338 | static void cprint_init(void) |
@@ -457,6 +469,10 @@ static void winch_handler(int sig) | |||
457 | 469 | ||
458 | static int exec_conf(void) | 470 | static int exec_conf(void) |
459 | { | 471 | { |
472 | #ifdef __MINGW32__ | ||
473 | fprintf(stderr, "exec_conf not implemented\n"); | ||
474 | exit(1); | ||
475 | #else | ||
460 | int pipefd[2], stat, size; | 476 | int pipefd[2], stat, size; |
461 | sigset_t sset, osset; | 477 | sigset_t sset, osset; |
462 | 478 | ||
@@ -530,6 +546,7 @@ static int exec_conf(void) | |||
530 | sigprocmask(SIG_SETMASK, &osset, NULL); | 546 | sigprocmask(SIG_SETMASK, &osset, NULL); |
531 | 547 | ||
532 | return WEXITSTATUS(stat); | 548 | return WEXITSTATUS(stat); |
549 | #endif | ||
533 | } | 550 | } |
534 | 551 | ||
535 | static void search_conf(void) | 552 | static void search_conf(void) |
@@ -1044,7 +1061,9 @@ static void conf_save(void) | |||
1044 | 1061 | ||
1045 | static void conf_cleanup(void) | 1062 | static void conf_cleanup(void) |
1046 | { | 1063 | { |
1064 | #ifndef __MINGW32__ | ||
1047 | tcsetattr(1, TCSAFLUSH, &ios_org); | 1065 | tcsetattr(1, TCSAFLUSH, &ios_org); |
1066 | #endif | ||
1048 | unlink(".help.tmp"); | 1067 | unlink(".help.tmp"); |
1049 | unlink("lxdialog.scrltmp"); | 1068 | unlink("lxdialog.scrltmp"); |
1050 | } | 1069 | } |
@@ -1073,7 +1092,9 @@ int main(int ac, char **av) | |||
1073 | single_menu_mode = 1; | 1092 | single_menu_mode = 1; |
1074 | } | 1093 | } |
1075 | 1094 | ||
1095 | #ifndef __MINGW32__ | ||
1076 | tcgetattr(1, &ios_org); | 1096 | tcgetattr(1, &ios_org); |
1097 | #endif | ||
1077 | atexit(conf_cleanup); | 1098 | atexit(conf_cleanup); |
1078 | init_wsize(); | 1099 | init_wsize(); |
1079 | conf(&rootmenu); | 1100 | conf(&rootmenu); |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 3d7877afc..63199cd93 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -6,8 +6,10 @@ | |||
6 | #include <ctype.h> | 6 | #include <ctype.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | #ifndef __MINGW32__ | ||
9 | #include <regex.h> | 10 | #include <regex.h> |
10 | #include <sys/utsname.h> | 11 | #include <sys/utsname.h> |
12 | #endif | ||
11 | 13 | ||
12 | #define LKC_DIRECT_LINK | 14 | #define LKC_DIRECT_LINK |
13 | #include "lkc.h" | 15 | #include "lkc.h" |
@@ -44,7 +46,9 @@ void sym_add_default(struct symbol *sym, const char *def) | |||
44 | void sym_init(void) | 46 | void sym_init(void) |
45 | { | 47 | { |
46 | struct symbol *sym; | 48 | struct symbol *sym; |
49 | #ifndef __MINGW32__ | ||
47 | struct utsname uts; | 50 | struct utsname uts; |
51 | #endif | ||
48 | char *p; | 52 | char *p; |
49 | static bool inited = false; | 53 | static bool inited = false; |
50 | 54 | ||
@@ -52,7 +56,9 @@ void sym_init(void) | |||
52 | return; | 56 | return; |
53 | inited = true; | 57 | inited = true; |
54 | 58 | ||
59 | #ifndef __MINGW32__ | ||
55 | uname(&uts); | 60 | uname(&uts); |
61 | #endif | ||
56 | 62 | ||
57 | sym = sym_lookup("ARCH", 0); | 63 | sym = sym_lookup("ARCH", 0); |
58 | sym->type = S_STRING; | 64 | sym->type = S_STRING; |
@@ -71,7 +77,11 @@ void sym_init(void) | |||
71 | sym = sym_lookup("UNAME_RELEASE", 0); | 77 | sym = sym_lookup("UNAME_RELEASE", 0); |
72 | sym->type = S_STRING; | 78 | sym->type = S_STRING; |
73 | sym->flags |= SYMBOL_AUTO; | 79 | sym->flags |= SYMBOL_AUTO; |
80 | #ifdef __MINGW32__ | ||
81 | sym_add_default(sym, "UNKNOWN"); | ||
82 | #else | ||
74 | sym_add_default(sym, uts.release); | 83 | sym_add_default(sym, uts.release); |
84 | #endif | ||
75 | } | 85 | } |
76 | 86 | ||
77 | enum symbol_type sym_get_type(struct symbol *sym) | 87 | enum symbol_type sym_get_type(struct symbol *sym) |
@@ -720,6 +730,10 @@ struct symbol *sym_find(const char *name) | |||
720 | 730 | ||
721 | struct symbol **sym_re_search(const char *pattern) | 731 | struct symbol **sym_re_search(const char *pattern) |
722 | { | 732 | { |
733 | #ifdef __MINGW32__ | ||
734 | fprintf(stderr, "NOTIMPL: sym_re_search\n"); | ||
735 | exit(1); | ||
736 | #else | ||
723 | struct symbol *sym, **sym_arr = NULL; | 737 | struct symbol *sym, **sym_arr = NULL; |
724 | int i, cnt, size; | 738 | int i, cnt, size; |
725 | regex_t re; | 739 | regex_t re; |
@@ -752,6 +766,7 @@ struct symbol **sym_re_search(const char *pattern) | |||
752 | regfree(&re); | 766 | regfree(&re); |
753 | 767 | ||
754 | return sym_arr; | 768 | return sym_arr; |
769 | #endif | ||
755 | } | 770 | } |
756 | 771 | ||
757 | 772 | ||