Mercurial > hg > toybox
annotate scripts/make.sh @ 1451:5f9fbf75ad34 draft
Old compilers complain about linker options passed with -c, so split out $LDOPTIMIZE.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 30 Aug 2014 17:44:07 -0500 |
parents | 0089cd84afea |
children | ab91ee85afbd |
rev | line source |
---|---|
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/bin/bash |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 # Grab default values for $CFLAGS and such. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 |
890
c7e7b159568d
The host sort on many distros behaves stupidly, and sorts stuff in non-ascii order by default. Make it stop.
Rob Landley <rob@landley.net>
parents:
720
diff
changeset
|
5 export LANG=c |
1450
0089cd84afea
Another fix from Johan Bergstr?m, using the gnu/dammit version of sort on the host can be screwed up by more than one environment variable.
Rob Landley <rob@landley.net>
parents:
1446
diff
changeset
|
6 export LC_ALL=C |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 source ./configure |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 |
1032
40d0c96a8e89
Add scripts/single.sh to build individual non-multiplexed standalone commands.
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
9 [ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=".config" |
40d0c96a8e89
Add scripts/single.sh to build individual non-multiplexed standalone commands.
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
10 |
1446
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
11 [ -z "$CPUS" ] && CPUS=$(($(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+1)) |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
12 |
1179
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
13 # Respond to V= by echoing command lines as well as running them |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
14 do_loudly() |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
15 { |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
16 [ ! -z "$V" ] && echo "$@" |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
17 "$@" |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
18 } |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
19 |
1032
40d0c96a8e89
Add scripts/single.sh to build individual non-multiplexed standalone commands.
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
20 echo "Make generated/config.h from $KCONFIG_CONFIG." |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 # This long and roundabout sed invocation is to make old versions of sed happy. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 # New ones have '\n' so can replace one line with two without all the branches |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 # and tedious mucking about with hold space. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 |
346
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
26 sed -n \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
27 -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
28 -e 't notset' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
29 -e 's/^CONFIG_\(.*\)=y.*/\1/' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
30 -e 't isset' \ |
347
52e980b216d3
Convert non-bool config values (such as int) into config.h entries.
Rob Landley <rob@landley.net>
parents:
346
diff
changeset
|
31 -e 's/^CONFIG_\([^=]*\)=\(.*\)/#define CFG_\1 \2/p' \ |
346
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
32 -e 'd' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
33 -e ':notset' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
34 -e 'h' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
35 -e 's/.*/#define CFG_& 0/p' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
36 -e 'g' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
37 -e 's/.*/#define USE_&(...)/p' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
38 -e 'd' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
39 -e ':isset' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
40 -e 'h' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
41 -e 's/.*/#define CFG_& 1/p' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
42 -e 'g' \ |
d0bf1df83c04
Re-wordwrap and reorder the .config->config.h sed script. (No real changes, just one command/line in a clearer order.)
Rob Landley <rob@landley.net>
parents:
321
diff
changeset
|
43 -e 's/.*/#define USE_&(...) __VA_ARGS__/p' \ |
1032
40d0c96a8e89
Add scripts/single.sh to build individual non-multiplexed standalone commands.
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
44 $KCONFIG_CONFIG > generated/config.h || exit 1 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
46 |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
47 echo "Extract configuration information from toys/*.c files..." |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
48 scripts/genconfig.sh |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
49 |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
50 echo "Generate headers from toys/*/*.c..." |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
51 |
930
39ac9e0ad6ad
Generate FLAG_longopt macros for --longopts with no corresponding short option.
Rob Landley <rob@landley.net>
parents:
892
diff
changeset
|
52 # Create a list of all the commands toybox can provide. Note that the first |
39ac9e0ad6ad
Generate FLAG_longopt macros for --longopts with no corresponding short option.
Rob Landley <rob@landley.net>
parents:
892
diff
changeset
|
53 # entry is out of order on purpose (the toybox multiplexer command must be the |
39ac9e0ad6ad
Generate FLAG_longopt macros for --longopts with no corresponding short option.
Rob Landley <rob@landley.net>
parents:
892
diff
changeset
|
54 # first element of the array). The rest must be sorted in alphabetical order |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
55 # for fast binary search. |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
56 |
1172 | 57 echo -n "generated/newtoys.h " |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
58 |
1032
40d0c96a8e89
Add scripts/single.sh to build individual non-multiplexed standalone commands.
Rob Landley <rob@landley.net>
parents:
999
diff
changeset
|
59 echo "USE_TOYBOX(NEWTOY(toybox, NULL, TOYFLAG_STAYROOT))" > generated/newtoys.h |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
60 sed -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \ |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
61 | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \ |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
62 | sed 's/[^ ]* //' >> generated/newtoys.h |
1074
82c5eb459a91
Fix generated/oldtoys.h to contain option strings with USE() macros in them.
Rob Landley <rob@landley.net>
parents:
1051
diff
changeset
|
63 sed -n -e 's/.*(NEWTOY(\([^,]*\), *\(\("[^"]*"[^,]*\)*\),.*/#define OPTSTR_\1\t\2/p' \ |
999
0af2375a8ef8
More grep cleanup, and make OPTSTR_command macros for use with OLDTOY()
Rob Landley <rob@landley.net>
parents:
965
diff
changeset
|
64 generated/newtoys.h > generated/oldtoys.h |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
65 |
1179
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
66 do_loudly $HOSTCC scripts/mkflags.c -o generated/mkflags || exit 1 |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
67 |
1172 | 68 echo -n "generated/flags.h " |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
69 |
1208
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
70 # Process config.h and newtoys.h to generate FLAG_x macros. Note we must |
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
71 # always #define the relevant macro, even when it's disabled, because we |
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
72 # allow multiple NEWTOY() in the same C file. (When disabled the FLAG is 0, |
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
73 # so flags&0 becomes a constant 0 allowing dead code elimination.) |
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
74 |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
75 # Parse files through C preprocessor twice, once to get flags for current |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
76 # .config and once to get flags for allyesconfig |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
77 for I in A B |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
78 do |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
79 ( |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
80 # define macros and select header files with option string data |
712
a950dd960593
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Rob Landley <rob@landley.net>
parents:
705
diff
changeset
|
81 |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
82 echo "#define NEWTOY(aa,bb,cc) aa $I bb" |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
83 echo '#define OLDTOY(...)' |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
84 if [ "$I" == A ] |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
85 then |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
86 cat generated/config.h |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
87 else |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
88 sed '/USE_.*([^)]*)$/s/$/ __VA_ARGS__/' generated/config.h |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
89 fi |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
90 cat generated/newtoys.h |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
91 |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
92 # Run result through preprocessor, glue together " " gaps leftover from USE |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
93 # macros, delete comment lines, print any line with a quoted optstring, |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
94 # turn any non-quoted opstring (NULL or 0) into " " (because fscanf can't |
1210
1c4c893d4e72
Fix header file generation to not be confused by empty (but non-NULL) option string.
Rob Landley <rob@landley.net>
parents:
1208
diff
changeset
|
95 # handle "" with nothing in it, and mkflags uses that). |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
96 |
1094
370f15d1ece1
Don't use $CC without $CROSS_COMPILE because $HOSTCC could be something else entirely.
Rob Landley <rob@landley.net>
parents:
1076
diff
changeset
|
97 ) | ${CROSS_COMPILE}${CC} -E - | \ |
1210
1c4c893d4e72
Fix header file generation to not be confused by empty (but non-NULL) option string.
Rob Landley <rob@landley.net>
parents:
1208
diff
changeset
|
98 sed -n -e 's/" *"//g;/^#/d;t clear;:clear;s/"/"/p;t;s/\( [AB] \).*/\1 " "/p' |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
99 |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
100 # Sort resulting line pairs and glue them together into triplets of |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
101 # command "flags" "allflags" |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
102 # to feed into mkflags C program that outputs actual flag macros |
1208
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
103 # If no pair (because command's disabled in config), use " " for flags |
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
104 # so allflags can define the appropriate zero macros. |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
105 |
1208
c86b1579c383
CLEANUP transitions require all the generated/flags.h stanzas always be present (even for commands disabled in the config) to avoid undefined symbol errors referencing FLAG_ macros.
Rob Landley <rob@landley.net>
parents:
1194
diff
changeset
|
106 done | sort | sed -n 's/ A / /;t pair;h;s/\([^ ]*\).*/\1 " "/;x;b single;:pair;h;n;:single;s/[^ ]* B //;H;g;s/\n/ /;p' |\ |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
107 generated/mkflags > generated/flags.h || exit 1 |
712
a950dd960593
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Rob Landley <rob@landley.net>
parents:
705
diff
changeset
|
108 |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
109 # Extract global structure definitions and flag definitions from toys/*/*.c |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
110 |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
111 function getglobals() |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
112 { |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
113 for i in toys/*/*.c |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
114 do |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
115 NAME="$(echo $i | sed 's@.*/\(.*\)\.c@\1@')" |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
116 DATA="$(sed -n -e '/^GLOBALS(/,/^)/b got;b;:got' \ |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
117 -e 's/^GLOBALS(/struct '"$NAME"'_data {/' \ |
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
118 -e 's/^)/};/' -e 'p' $i)" |
712
a950dd960593
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Rob Landley <rob@landley.net>
parents:
705
diff
changeset
|
119 |
1076
1c15ba60aa64
Switch flag generation from shell to C.
Rob Landley <rob@landley.net>
parents:
1074
diff
changeset
|
120 [ ! -z "$DATA" ] && echo -e "// $i\n\n$DATA\n" |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
121 done |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
122 } |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
123 |
1172 | 124 echo -n "generated/globals.h " |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
125 |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
126 GLOBSTRUCT="$(getglobals)" |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
127 ( |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
128 echo "$GLOBSTRUCT" |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
129 echo |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
130 echo "extern union global_union {" |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
131 echo "$GLOBSTRUCT" | sed -n 's/struct \(.*\)_data {/ struct \1_data \1;/p' |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
132 echo "} this;" |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
133 ) > generated/globals.h |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
134 |
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
135 echo "generated/help.h" |
1179
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
136 do_loudly $HOSTCC scripts/config2help.c -I . lib/xwrap.c lib/llist.c lib/lib.c \ |
260cce6c3e35
Replace python help converter with C implementation.
Rob Landley <rob@landley.net>
parents:
1172
diff
changeset
|
137 -o generated/config2help && \ |
1194
855b706d10dc
Use right config for single builds.
Rob Landley <rob@landley.net>
parents:
1179
diff
changeset
|
138 generated/config2help Config.in $KCONFIG_CONFIG > generated/help.h || exit 1 |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
664
diff
changeset
|
139 |
581
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
140 echo "Library probe..." |
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
141 |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
142 # We trust --as-needed to remove each library if we don't use any symbols |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
143 # out of it, this loop is because the compiler has no way to ignore a library |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
144 # that doesn't exist, so we have to detect and skip nonexistent libraries |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
145 # for it. |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
146 |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
147 > generated/optlibs.dat |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
148 for i in util crypt m resolv |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
149 do |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
150 echo "int main(int argc, char *argv[]) {return 0;}" | \ |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
151 ${CROSS_COMPILE}${CC} $CFLAGS -xc - -o /dev/null -Wl,--as-needed -l$i > /dev/null 2>/dev/null && |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
152 echo -l$i >> generated/optlibs.dat |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
153 done |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
154 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
155 echo -n "Compile toybox" |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
156 [ ! -z "$V" ] && echo |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
157 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
158 # Extract a list of toys/*/*.c files to compile from the data in $KCONFIG_CONFIG |
581
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
159 |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
160 # Get a list of C files in toys/* and wash it through sed to chop out the |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
161 # filename, convert - to _, and glue the result together into a new regex |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
162 # we we can feed to grep to match any one of them (whole word, not substring). |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
163 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
164 TOYFILES="^$(ls toys/*/*.c | sed -n 's@^.*/\(.*\)\.c$@\1@;s/-/_/g;H;${g;s/\n//;s/\n/$|^/gp}')\$" |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
165 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
166 # 1) Grab the XXX part of all CONFIG_XXX entries from KCONFIG |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
167 # 2) Sort the list, keeping only one of each entry. |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
168 # 3) Convert to lower case. |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
169 # 4) Remove any config symbol not recognized as a filename from step 1. |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
170 # 5) Add "toys/*/" prefix and ".c" suffix. |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
171 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
172 TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/p' < "$KCONFIG_CONFIG" \ |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
173 | sort -u | tr A-Z a-z | grep -E "$TOYFILES" | sed 's@\(.*\)@toys/\*/\1.c@') |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
174 |
472 | 175 do_loudly() |
176 { | |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
177 [ ! -z "$V" ] && echo "$@" || echo -n . |
472 | 178 "$@" |
179 } | |
180 | |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
181 BUILD="${CROSS_COMPILE}${CC} $CFLAGS -I . $OPTIMIZE" |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
182 FILES="$(ls lib/*.c) main.c $TOYFILES" |
1451
5f9fbf75ad34
Old compilers complain about linker options passed with -c, so split out $LDOPTIMIZE.
Rob Landley <rob@landley.net>
parents:
1450
diff
changeset
|
183 LINK="$LDOPTIMIZE -o toybox_unstripped -Wl,--as-needed $(cat generated/optlibs.dat)" |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
184 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
185 # This is a parallel version of: do_loudly $BUILD $FILES $LINK || exit 1 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
186 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
187 rm -f generated/*.o |
1446
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
188 PENDING= |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
189 for i in $FILES |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
190 do |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
191 # build each generated/*.o file in parallel |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
192 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
193 X=${i/lib\//lib_} |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
194 X=${X##*/} |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
195 do_loudly $BUILD -c $i -o generated/${X%%.c}.o & |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
196 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
197 # ratelimit to $CPUS many parallel jobs, detecting errors |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
198 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
199 while true |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
200 do |
1446
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
201 PENDING="$(echo $PENDING $(jobs -rp) | tr ' ' '\n' | sort -u)" |
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
202 [ $(echo $PENDING | wc -l) -lt "$CPUS" ] && break; |
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
203 |
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
204 wait $(echo $PENDING | head -n 1) || exit 1 |
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
205 PENDING="$(echo "$PENDING" | tail -n +2)" |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
206 done |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
207 done |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
208 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
209 # wait for all background jobs, detecting errors |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
210 |
1446
f46ccbcf3f13
Fix parallel make not always catching errors before link time.
Rob Landley <rob@landley.net>
parents:
1428
diff
changeset
|
211 for i in $PENDING |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
212 do |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
213 wait $i || exit 1 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
214 done |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
215 |
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
216 do_loudly $BUILD generated/*.o $LINK || exit 1 |
512
9bcc288a1c54
Fix from Georgi Chorbadzhiyski to make cross compiling more robust.
Rob Landley <rob@landley.net>
parents:
472
diff
changeset
|
217 do_loudly ${CROSS_COMPILE}${STRIP} toybox_unstripped -o toybox || exit 1 |
364
6df3ac5165fa
The "strip" in gcc 4.4 doesn't set the executable bit on its output, despite what SUSv4 says it should do, so cope with buggy FSF tools.
Rob Landley <rob@landley.net>
parents:
347
diff
changeset
|
218 # gcc 4.4's strip command is buggy, and doesn't set the executable bit on |
6df3ac5165fa
The "strip" in gcc 4.4 doesn't set the executable bit on its output, despite what SUSv4 says it should do, so cope with buggy FSF tools.
Rob Landley <rob@landley.net>
parents:
347
diff
changeset
|
219 # its output the way SUSv4 suggests it do so. |
472 | 220 do_loudly chmod +x toybox || exit 1 |
1428
e66fb422b78a
Parallelize the build. (set CPUS=1 to force single processor build, or another number to override processor count autodetect.)
Rob Landley <rob@landley.net>
parents:
1343
diff
changeset
|
221 echo |