diff options
author | Ron Yorston <rmy@pobox.com> | 2022-10-30 08:25:45 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-10-30 08:25:45 +0000 |
commit | 7390f29cfc9a3cc0636e20f84f24fbd05f821720 (patch) | |
tree | ee040facd1f276cb5daf733092f137527c75630f | |
parent | d71cb67ff91762ae78e87440b87d7c9a160b2937 (diff) | |
download | busybox-w32-7390f29cfc9a3cc0636e20f84f24fbd05f821720.tar.gz busybox-w32-7390f29cfc9a3cc0636e20f84f24fbd05f821720.tar.bz2 busybox-w32-7390f29cfc9a3cc0636e20f84f24fbd05f821720.zip |
build system: allow building with w64devkit
Make some adjustments to the build system to allow busybox-w32
to be built with w64devkit:
- Strip drive prefix from CURDIR in Makefile to avoid confusing
make with colons.
- Limit file redirection to a subshell in the usage_compressed and
embedded_scripts scripts. Otherwise it isn't possible to move
the open generated file on Windows.
- Change the option tests in Kbuild.include to allow for /dev/null
not existing on Windows.
- Create host binaries without a '.exe' extension. Otherwise they're
rebuilt more often than necessary.
- Modify split-include.c to allow for Windows' popen() not expanding
wildcards.
(GitHub issue #239)
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | applets/usage_compressed | 2 | ||||
-rw-r--r-- | scripts/Kbuild.include | 10 | ||||
-rw-r--r-- | scripts/Makefile.host | 21 | ||||
-rw-r--r-- | scripts/basic/split-include.c | 11 | ||||
-rwxr-xr-x | scripts/embedded_scripts | 2 |
6 files changed, 43 insertions, 7 deletions
@@ -4,6 +4,10 @@ SUBLEVEL = 0 | |||
4 | EXTRAVERSION = .git | 4 | EXTRAVERSION = .git |
5 | NAME = Unnamed | 5 | NAME = Unnamed |
6 | 6 | ||
7 | # Colon is used as a separator in makefiles. Strip any drive prefix | ||
8 | # from the current directory to avoid confusion. | ||
9 | CURDIR := $(lastword $(subst :, ,$(CURDIR))) | ||
10 | |||
7 | # *DOCUMENTATION* | 11 | # *DOCUMENTATION* |
8 | # To see a list of typical targets execute "make help" | 12 | # To see a list of typical targets execute "make help" |
9 | # More info can be located in ./README | 13 | # More info can be located in ./README |
diff --git a/applets/usage_compressed b/applets/usage_compressed index 36fc2a007..94d70f33b 100755 --- a/applets/usage_compressed +++ b/applets/usage_compressed | |||
@@ -16,6 +16,7 @@ if test $? != 0; then | |||
16 | exit 1 | 16 | exit 1 |
17 | fi | 17 | fi |
18 | 18 | ||
19 | ( | ||
19 | exec >"$target.$$" | 20 | exec >"$target.$$" |
20 | 21 | ||
21 | echo '#define UNPACKED_USAGE "" \' | 22 | echo '#define UNPACKED_USAGE "" \' |
@@ -58,5 +59,6 @@ echo '#define PACKED_USAGE \' | |||
58 | -e 's/\(...\)/0\1,/g' \ | 59 | -e 's/\(...\)/0\1,/g' \ |
59 | -e 's/$/ \\/' | 60 | -e 's/$/ \\/' |
60 | echo '' | 61 | echo '' |
62 | ) | ||
61 | 63 | ||
62 | mv -- "$target.$$" "$target" | 64 | mv -- "$target.$$" "$target" |
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 5b4db5c2c..b61ff8b42 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -52,25 +52,25 @@ endef | |||
52 | # as-option | 52 | # as-option |
53 | # Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,) | 53 | # Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,) |
54 | 54 | ||
55 | as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ | 55 | as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o - \ |
56 | -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ | 56 | -xassembler - </dev/null > /dev/null 2>&1; then echo "$(1)"; \ |
57 | else echo "$(2)"; fi ;) | 57 | else echo "$(2)"; fi ;) |
58 | 58 | ||
59 | # cc-option | 59 | # cc-option |
60 | # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) | 60 | # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) |
61 | 61 | ||
62 | cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ | 62 | cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o - -xc - </dev/null \ |
63 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) | 63 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) |
64 | 64 | ||
65 | # hostcc-option | 65 | # hostcc-option |
66 | # Usage: hostcflags-y += $(call hostcc-option, -march=winchip-c6, -march=i586) | 66 | # Usage: hostcflags-y += $(call hostcc-option, -march=winchip-c6, -march=i586) |
67 | 67 | ||
68 | hostcc-option = $(shell if $(HOSTCC) $(HOSTCFLAGS) $(1) -S -o /dev/null -xc /dev/null \ | 68 | hostcc-option = $(shell if $(HOSTCC) $(HOSTCFLAGS) $(1) -S -o - -xc - </dev/null \ |
69 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) | 69 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) |
70 | 70 | ||
71 | # cc-option-yn | 71 | # cc-option-yn |
72 | # Usage: flag := $(call cc-option-yn, -march=winchip-c6) | 72 | # Usage: flag := $(call cc-option-yn, -march=winchip-c6) |
73 | cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ | 73 | cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o - -xc - </dev/null \ |
74 | > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) | 74 | > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) |
75 | 75 | ||
76 | # cc-option-align | 76 | # cc-option-align |
diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 2e628508d..0deec32e6 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host | |||
@@ -92,13 +92,30 @@ endif | |||
92 | hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) | 92 | hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) |
93 | hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) | 93 | hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) |
94 | 94 | ||
95 | # Programs built for use on the host are defined without a suffix | ||
96 | # (usually '.exe' on Windows). Rather than adjust all the makefiles | ||
97 | # force a suffix of '.' if the host platform is mingw32. This will | ||
98 | # result in binaries with no suffix. | ||
99 | # | ||
100 | # It's not a big deal if this doesn't work. MSYS2 doesn't need it | ||
101 | # and the downside is just that the programs will be rebuilt more | ||
102 | # often than really needed. | ||
103 | # | ||
104 | host_target := $(shell $(HOSTCC) -v 2>&1 | grep ^Target:) | ||
105 | host_platform := $(lastword $(subst -, ,$(host_target))) | ||
106 | ifeq ($(host_platform),mingw32) | ||
107 | dot := . | ||
108 | else | ||
109 | dot := | ||
110 | endif | ||
111 | |||
95 | ##### | 112 | ##### |
96 | # Compile programs on the host | 113 | # Compile programs on the host |
97 | 114 | ||
98 | # Create executable from a single .c file | 115 | # Create executable from a single .c file |
99 | # host-csingle -> Executable | 116 | # host-csingle -> Executable |
100 | quiet_cmd_host-csingle = HOSTCC $@ | 117 | quiet_cmd_host-csingle = HOSTCC $@ |
101 | cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ | 118 | cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@$(dot) $< \ |
102 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | 119 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) |
103 | $(host-csingle): %: %.c FORCE | 120 | $(host-csingle): %: %.c FORCE |
104 | $(call if_changed_dep,host-csingle) | 121 | $(call if_changed_dep,host-csingle) |
@@ -106,7 +123,7 @@ $(host-csingle): %: %.c FORCE | |||
106 | # Link an executable based on list of .o files, all plain c | 123 | # Link an executable based on list of .o files, all plain c |
107 | # host-cmulti -> executable | 124 | # host-cmulti -> executable |
108 | quiet_cmd_host-cmulti = HOSTLD $@ | 125 | quiet_cmd_host-cmulti = HOSTLD $@ |
109 | cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ | 126 | cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@$(dot) \ |
110 | $(addprefix $(obj)/,$($(@F)-objs)) \ | 127 | $(addprefix $(obj)/,$($(@F)-objs)) \ |
111 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | 128 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) |
112 | $(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE | 129 | $(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE |
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c index 290bea2fb..a85ede8ef 100644 --- a/scripts/basic/split-include.c +++ b/scripts/basic/split-include.c | |||
@@ -197,13 +197,21 @@ int main(int argc, const char * argv []) | |||
197 | * So by having an initial \n, strstr will find exact matches. | 197 | * So by having an initial \n, strstr will find exact matches. |
198 | */ | 198 | */ |
199 | 199 | ||
200 | #ifdef __MINGW32__ | ||
201 | fp_find = popen("find . -type f -name \"*.h\" -print", "r"); | ||
202 | #else | ||
200 | fp_find = popen("find * -type f -name \"*.h\" -print", "r"); | 203 | fp_find = popen("find * -type f -name \"*.h\" -print", "r"); |
204 | #endif | ||
201 | if (fp_find == 0) | 205 | if (fp_find == 0) |
202 | ERROR_EXIT( "find" ); | 206 | ERROR_EXIT( "find" ); |
203 | 207 | ||
204 | line[0] = '\n'; | 208 | line[0] = '\n'; |
205 | while (fgets(line+1, buffer_size, fp_find)) | 209 | while (fgets(line+1, buffer_size, fp_find)) |
206 | { | 210 | { |
211 | #ifdef __MINGW32__ | ||
212 | line[2] = '\n'; | ||
213 | # define line (line + 2) | ||
214 | #endif | ||
207 | if (strstr(list_target, line) == NULL) | 215 | if (strstr(list_target, line) == NULL) |
208 | { | 216 | { |
209 | /* | 217 | /* |
@@ -226,6 +234,9 @@ int main(int argc, const char * argv []) | |||
226 | ERROR_EXIT(line); | 234 | ERROR_EXIT(line); |
227 | } | 235 | } |
228 | } | 236 | } |
237 | #ifdef __MINGW32__ | ||
238 | # undef line | ||
239 | #endif | ||
229 | } | 240 | } |
230 | 241 | ||
231 | if (pclose(fp_find) != 0) | 242 | if (pclose(fp_find) != 0) |
diff --git a/scripts/embedded_scripts b/scripts/embedded_scripts index 205ac591a..8407c1f78 100755 --- a/scripts/embedded_scripts +++ b/scripts/embedded_scripts | |||
@@ -90,6 +90,7 @@ concatenate_scripts() { | |||
90 | done | 90 | done |
91 | } | 91 | } |
92 | 92 | ||
93 | ( | ||
93 | exec >"$target.$$" | 94 | exec >"$target.$$" |
94 | 95 | ||
95 | if [ $n -ne 0 ] | 96 | if [ $n -ne 0 ] |
@@ -127,5 +128,6 @@ then | |||
127 | -e 's/$/ \\/' | 128 | -e 's/$/ \\/' |
128 | printf '\n' | 129 | printf '\n' |
129 | fi | 130 | fi |
131 | ) | ||
130 | 132 | ||
131 | mv -- "$target.$$" "$target" | 133 | mv -- "$target.$$" "$target" |