Mercurial > hg > toybox
annotate scripts/make.sh @ 888:c5e80c74ec6c
Fix conflicting types for show_help().
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 29 Apr 2013 10:53:09 -0500 |
parents | e2eb80481afc |
children | c7e7b159568d |
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 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 source ./configure |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
7 if [ -z ".config" ] |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
8 then |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
9 echo "No .config (see "make help" for configuration options)." |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
10 exit 1 |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
11 fi |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
12 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 echo "Make generated/config.h from .config." |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 # 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
|
16 # 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
|
17 # 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
|
18 |
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
|
19 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
|
20 -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
|
21 -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
|
22 -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
|
23 -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
|
24 -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
|
25 -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
|
26 -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
|
27 -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
|
28 -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
|
29 -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
|
30 -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
|
31 -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
|
32 -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
|
33 -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
|
34 -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
|
35 -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
|
36 -e 's/.*/#define USE_&(...) __VA_ARGS__/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
|
37 .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
|
38 |
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
|
39 |
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
|
40 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
|
41 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
|
42 |
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
|
43 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
|
44 |
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
|
45 # Create a list of all the applets toybox can provide. Note that the first |
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 # entry is out of order on purpose (the toybox multiplexer applet must be the |
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 # first element of the array). The rest must be sorted in alphabetical order |
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 # 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
|
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 "generated/newtoys.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
|
51 |
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
|
52 echo "NEWTOY(toybox, NULL, TOYFLAG_STAYROOT)" > generated/newtoys.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
|
53 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
|
54 | 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
|
55 | sed 's/[^ ]* //' >> generated/newtoys.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
|
56 |
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
|
57 # Extract list of command letters from processed header file |
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
|
58 |
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
|
59 function getflags() |
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
|
60 { |
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
|
61 sed -n -e "s/.*TOY($1"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \ |
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
|
62 -e 't keep;d;:keep' -e 's/^[<>=][0-9]//' -e 's/[?&^]//' \ |
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
|
63 -e 't keep' -e 's/[><=][0-9][0-9]*//g' -e 's/+.//g' \ |
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
|
64 -e 's/([^)]*)//g' -e 's/\[[^]]*\]//g' -e 's/[-?^:&#|@*]//g' -e 'p' |
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
|
65 } |
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
|
66 |
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
|
67 # 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
|
68 |
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
|
69 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
|
70 { |
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
|
71 # Run newtoys.h through the compiler's preprocessor to resolve USE macros |
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
|
72 # against current config. |
720
e2eb80481afc
Use the specified compiler for preprocessing.
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
73 NEWTOYS="$(cat generated/config.h generated/newtoys.h | $CC -E - | sed 's/" *"//g')" |
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
|
74 |
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
|
75 # Grab allyesconfig for comparison |
720
e2eb80481afc
Use the specified compiler for preprocessing.
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
76 ALLTOYS="$((sed '/USE_.*([^)]*)$/s/$/ __VA_ARGS__/' generated/config.h && cat generated/newtoys.h) | $CC -E - | sed 's/" *"//g')" |
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
|
77 |
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
|
78 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
|
79 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
|
80 NAME="$(echo $i | sed 's@.*/\(.*\)\.c@\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
|
81 |
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
|
82 echo -e "// $i\n" |
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
|
83 sed -n -e '/^GLOBALS(/,/^)/b got;b;:got' \ |
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
|
84 -e 's/^GLOBALS(/struct '"$NAME"'_data {/' \ |
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
|
85 -e 's/^)/};/' -e 'p' $i |
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
|
86 |
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
|
87 FLAGS="$(echo "$NEWTOYS" | getflags "$NAME")" |
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
|
88 ZFLAGS="$(echo "$ALLTOYS" | getflags "$NAME" | sed 's/[-'"$FLAGS"']//g')" |
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
|
89 |
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
|
90 echo "#ifdef FOR_${NAME}" |
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
|
91 X=0 |
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
|
92 while [ $X -lt ${#FLAGS} ] |
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
|
93 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
|
94 echo -ne "#define FLAG_${FLAGS:$X:1}\t" |
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
|
95 X=$(($X+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
|
96 echo "(1<<$((${#FLAGS}-$X)))" |
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
|
97 done |
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
|
98 X=0 |
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
|
99 while [ $X -lt ${#ZFLAGS} ] |
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
|
100 do |
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
|
101 echo "#define FLAG_${ZFLAGS:$X:1} 0" |
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
|
102 X=$(($X+1)) |
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
|
103 done |
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
|
104 echo "#define TT this.${NAME}" |
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
|
105 echo "#endif" |
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
|
106 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
|
107 } |
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
|
108 |
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 echo "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
|
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 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
|
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 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 ) > 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
|
119 |
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
|
120 echo "generated/help.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
|
121 # Only recreate generated/help.h if python is installed |
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 if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ] |
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 then |
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
|
124 echo "Extract help text from Config.in." |
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 scripts/config2help.py Config.in > generated/help.h || exit 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
|
126 fi |
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 |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
128 # Extract a list of toys/*/*.c files to compile from the data in ".config": |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
129 |
654
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
130 # 1) Get a list of C files in toys/* and glue them together into a regex we can |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
131 # feed to grep that will match any one of them (whole word, not substring). |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
132 TOYFILES="^$(ls toys/*/*.c | sed -n 's@^.*/\(.*\)\.c$@\1@;s/-/_/g;H;${g;s/\n//;s/\n/$|^/gp}')\$" |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
133 |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
134 # 2) Grab the XXX part of all CONFIG_XXX entries, removing everything after the |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
135 # second underline |
654
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
136 # 3) Sort the list, keeping only one of each entry. |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
137 # 4) Convert to lower case. |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
138 # 5) Remove any config symbol not recognized as a filename from step 1. |
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
139 # 6) Add "toys/*/" prefix and ".c" suffix. |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
140 |
664
c60ac785784f
Add switch_root and fix infrastructure to understand name "switch_root".
Rob Landley <rob@landley.net>
parents:
654
diff
changeset
|
141 TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/p' < .config \ |
654
04feab07416c
Teach build to compare toys/*/*.c against .config symbol names instead of stopping at first _ when assembling list of files to build, and convert - to _. This lets us have commands like switch_root or nbd-client.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
142 | 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
|
143 |
581
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
144 echo "Library probe..." |
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
145 |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
146 # 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
|
147 # 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
|
148 # 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
|
149 # for it. |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
595
diff
changeset
|
150 |
581
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
151 OPTLIBS="$(for i in util crypt m; do echo "int main(int argc, char *argv[]) {return 0;}" | ${CROSS_COMPILE}${CC} -xc - -o /dev/null -Wl,--as-needed -l$i > /dev/null 2>/dev/null && echo -l$i; done)" |
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
152 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
153 echo "Compile toybox..." |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
154 |
472 | 155 do_loudly() |
156 { | |
157 [ ! -z "$V" ] && echo "$@" | |
158 "$@" | |
159 } | |
160 | |
512
9bcc288a1c54
Fix from Georgi Chorbadzhiyski to make cross compiling more robust.
Rob Landley <rob@landley.net>
parents:
472
diff
changeset
|
161 do_loudly ${CROSS_COMPILE}${CC} $CFLAGS -I . -o toybox_unstripped $OPTIMIZE \ |
581
1e07220fd3b6
Probe available libraries to link --as-needed, avoiding "unknown libarary" errors.
Rob Landley <rob@landley.net>
parents:
572
diff
changeset
|
162 main.c lib/*.c $TOYFILES -Wl,--as-needed $OPTLIBS || exit 1 |
512
9bcc288a1c54
Fix from Georgi Chorbadzhiyski to make cross compiling more robust.
Rob Landley <rob@landley.net>
parents:
472
diff
changeset
|
163 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
|
164 # 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
|
165 # its output the way SUSv4 suggests it do so. |
472 | 166 do_loudly chmod +x toybox || exit 1 |