Mercurial > hg > toybox
annotate scripts/make.sh @ 566:05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 14 Apr 2012 22:31:53 -0500 |
parents | 878b94b32866 |
children | 8a88a9e3c30b |
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 |
237
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
7 echo "Extract configuration information from toys/*.c files..." |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 scripts/genconfig.sh |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 |
528
878b94b32866
Comment and whitespace tweaks.
Rob Landley <rob@landley.net>
parents:
512
diff
changeset
|
10 echo "Generate headers from toys/*.c..." |
237
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
11 |
234
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
12 # Create a list of all the applets toybox can provide. Note that the first |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
13 # entry is out of order on purpose (the toybox multiplexer applet must be the |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
14 # first element of the array). The rest must be sorted in alphabetical order |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
15 # for fast binary search. |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
16 |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
17 function newtoys() |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
18 { |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
19 for i in toys/*.c |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
20 do |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
21 sed -n -e '1,/^config [A-Z]/s/^USE_/&/p' $i || exit 1 |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
22 done |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
23 } |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
24 echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h |
293
6baa13382880
Sort was including the trailing comma and getting the order wrong.
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
25 newtoys | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \ |
6baa13382880
Sort was including the trailing comma and getting the order wrong.
Rob Landley <rob@landley.net>
parents:
264
diff
changeset
|
26 | sed 's/[^ ]* //' >> generated/newtoys.h |
234
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
27 |
566
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
28 # Extract global structure definitions and flag definitions from toys/*.c |
237
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
29 |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
30 function getglobals() |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
31 { |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
32 for i in toys/*.c |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
33 do |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
34 NAME="$(echo $i | sed 's@toys/\(.*\)\.c@\1@')" |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
35 |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
36 echo -e "// $i\n" |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
37 sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \ |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
38 -e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \ |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
39 -e 's/^)/};/' -e 'p' $i |
566
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
40 |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
41 # And get flag definitions |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
42 FLAGS="$(sed -n \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
43 -e "s/.*TOY($NAME"',[ \t]*"\([^"]*\)"[ \t]*,.*)/\1/' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
44 -e 't keep;d;:keep' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
45 -e 's/[><=][0-9][0-9]*//g' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
46 -e 's/+.//g' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
47 -e 's/([^)]*)//g' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
48 -e 's/[-?^:&#|@*]//g' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
49 -e 'p' \ |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
50 generated/newtoys.h)" |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
51 X=0 |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
52 while [ $X -lt ${#FLAGS} ] |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
53 do |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
54 echo -ne "#define OPTFLAG_${NAME}_${FLAGS:$X:1}\t" |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
55 X=$(($X+1)) |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
56 echo "(1<<$((${#FLAGS}-$X)))" |
05617db1a337
Teach make.sh to create flag macros, but with the wrong names. Dunno how to make a translation macro or #ifdef guard to get the names right so they actually be _used_ yet...
Rob Landley <rob@landley.net>
parents:
528
diff
changeset
|
57 done |
237
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
58 done |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
59 } |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
60 |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
61 GLOBSTRUCT="$(getglobals)" |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
62 ( |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
63 echo "$GLOBSTRUCT" |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
64 echo |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
65 echo "extern union global_union {" |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
66 echo "$GLOBSTRUCT" | sed -n 's/struct \(.*\)_data {/ struct \1_data \1;/p' |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
67 echo "} this;" |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
68 ) > generated/globals.h |
7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
69 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
70 # Only recreate generated/help.h if python is installed |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
71 if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ] |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
72 then |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
73 echo "Extract help text from Config.in." |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
74 scripts/config2help.py Config.in > generated/help.h || exit 1 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
75 fi |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
76 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 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
|
78 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 # 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
|
80 # 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
|
81 # 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
|
82 |
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
|
83 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
|
84 -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
|
85 -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
|
86 -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
|
87 -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
|
88 -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
|
89 -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
|
90 -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
|
91 -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
|
92 -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
|
93 -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
|
94 -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
|
95 -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
|
96 -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
|
97 -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
|
98 -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
|
99 -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
|
100 -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
|
101 .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
|
102 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
103 # Extract a list of toys/*.c files to compile from the data in ".config" with |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
104 # sed, sort, and tr: |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
105 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
106 # 1) Grab the XXX part of all CONFIG_XXX entries, removing everything after the |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
107 # second underline |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
108 # 2) Sort the list, keeping only one of each entry. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
109 # 3) Convert to lower case. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
110 # 4) Remove toybox itself from the list (as that indicates global symbols). |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
111 # 5) Add "toys/" prefix and ".c" suffix. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
112 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
113 TOYFILES=$(cat .config | sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' | sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's@\(.*\)@toys/\1.c@' ) |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
114 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
115 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
|
116 |
472 | 117 do_loudly() |
118 { | |
119 [ ! -z "$V" ] && echo "$@" | |
120 "$@" | |
121 } | |
122 | |
512
9bcc288a1c54
Fix from Georgi Chorbadzhiyski to make cross compiling more robust.
Rob Landley <rob@landley.net>
parents:
472
diff
changeset
|
123 do_loudly ${CROSS_COMPILE}${CC} $CFLAGS -I . -o toybox_unstripped $OPTIMIZE \ |
9bcc288a1c54
Fix from Georgi Chorbadzhiyski to make cross compiling more robust.
Rob Landley <rob@landley.net>
parents:
472
diff
changeset
|
124 main.c lib/*.c $TOYFILES -Wl,--as-needed,-lutil,--no-as-needed || exit 1 |
9bcc288a1c54
Fix from Georgi Chorbadzhiyski to make cross compiling more robust.
Rob Landley <rob@landley.net>
parents:
472
diff
changeset
|
125 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
|
126 # 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
|
127 # its output the way SUSv4 suggests it do so. |
472 | 128 do_loudly chmod +x toybox || exit 1 |