comparison scripts/make.sh @ 1032:40d0c96a8e89 draft

Add scripts/single.sh to build individual non-multiplexed standalone commands. Alas, you can't quite do this yet: make defconfig make for i in $(./toybox) do echo $i PREFIX=singles/ scripts/single.sh $i || break done Because the OLDTOY() aliases for commands won't build without the base command. And I can't just skip them because chown/chmod or mv/cp aren't the same thing.
author Rob Landley <rob@landley.net>
date Fri, 30 Aug 2013 01:53:31 -0500
parents 0af2375a8ef8
children af1780148f7c
comparison
equal deleted inserted replaced
1031:0d0c01ac5c63 1032:40d0c96a8e89
3 # Grab default values for $CFLAGS and such. 3 # Grab default values for $CFLAGS and such.
4 4
5 export LANG=c 5 export LANG=c
6 source ./configure 6 source ./configure
7 7
8 if [ -z ".config" ] 8 [ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=".config"
9
10 if [ -z "$KCONFIG_CONFIG" ]
9 then 11 then
10 echo "No .config (see "make help" for configuration options)." 12 echo "No $KCONFIG_CONFIG (see "make help" for configuration options)."
11 exit 1 13 exit 1
12 fi 14 fi
13 15
14 echo "Make generated/config.h from .config." 16 echo "Make generated/config.h from $KCONFIG_CONFIG."
15 17
16 # This long and roundabout sed invocation is to make old versions of sed happy. 18 # This long and roundabout sed invocation is to make old versions of sed happy.
17 # New ones have '\n' so can replace one line with two without all the branches 19 # New ones have '\n' so can replace one line with two without all the branches
18 # and tedious mucking about with hold space. 20 # and tedious mucking about with hold space.
19 21
33 -e ':isset' \ 35 -e ':isset' \
34 -e 'h' \ 36 -e 'h' \
35 -e 's/.*/#define CFG_& 1/p' \ 37 -e 's/.*/#define CFG_& 1/p' \
36 -e 'g' \ 38 -e 'g' \
37 -e 's/.*/#define USE_&(...) __VA_ARGS__/p' \ 39 -e 's/.*/#define USE_&(...) __VA_ARGS__/p' \
38 .config > generated/config.h || exit 1 40 $KCONFIG_CONFIG > generated/config.h || exit 1
39 41
40 42
41 echo "Extract configuration information from toys/*.c files..." 43 echo "Extract configuration information from toys/*.c files..."
42 scripts/genconfig.sh 44 scripts/genconfig.sh
43 45
48 # first element of the array). The rest must be sorted in alphabetical order 50 # first element of the array). The rest must be sorted in alphabetical order
49 # for fast binary search. 51 # for fast binary search.
50 52
51 echo "generated/newtoys.h" 53 echo "generated/newtoys.h"
52 54
53 echo "NEWTOY(toybox, NULL, TOYFLAG_STAYROOT)" > generated/newtoys.h 55 echo "USE_TOYBOX(NEWTOY(toybox, NULL, TOYFLAG_STAYROOT))" > generated/newtoys.h
54 sed -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \ 56 sed -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \
55 | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \ 57 | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \
56 | sed 's/[^ ]* //' >> generated/newtoys.h 58 | sed 's/[^ ]* //' >> generated/newtoys.h
57 sed -n 's/.*(NEWTOY(\([^,]*\), *\("[^,]*"\) *,.*/#define OPTSTR_\1\t\2/p' \ 59 sed -n 's/.*(NEWTOY(\([^,]*\), *\("[^,]*"\) *,.*/#define OPTSTR_\1\t\2/p' \
58 generated/newtoys.h > generated/oldtoys.h 60 generated/newtoys.h > generated/oldtoys.h
136 ) > generated/globals.h 138 ) > generated/globals.h
137 139
138 echo "generated/help.h" 140 echo "generated/help.h"
139 # Only recreate generated/help.h if python2 is installed. Does not work with 3. 141 # Only recreate generated/help.h if python2 is installed. Does not work with 3.
140 PYTHON="$(which python2)" 142 PYTHON="$(which python2)"
141 if [ ! -z "$PYTHON" ] && [ ! -z "$(grep 'CONFIG_TOYBOX_HELP=y' .config)" ] 143 if [ ! -z "$PYTHON" ] &&
144 [ ! -z "$(grep 'CONFIG_TOYBOX_HELP=y' $KCONFIG_CONFIG)" ]
142 then 145 then
143 echo "Extract help text from Config.in." 146 echo "Extract help text from Config.in."
144 "$PYTHON" scripts/config2help.py Config.in > generated/help.h || exit 1 147 "$PYTHON" scripts/config2help.py Config.in > generated/help.h || exit 1
145 fi 148 fi
146 149
147 # Extract a list of toys/*/*.c files to compile from the data in ".config": 150 # Extract a list of toys/*/*.c files to compile from the data in $KCONFIG_CONFIG
148 151
149 # 1) Get a list of C files in toys/* and glue them together into a regex we can 152 # 1) Get a list of C files in toys/* and glue them together into a regex we can
150 # feed to grep that will match any one of them (whole word, not substring). 153 # feed to grep that will match any one of them (whole word, not substring).
151 TOYFILES="^$(ls toys/*/*.c | sed -n 's@^.*/\(.*\)\.c$@\1@;s/-/_/g;H;${g;s/\n//;s/\n/$|^/gp}')\$" 154 TOYFILES="^$(ls toys/*/*.c | sed -n 's@^.*/\(.*\)\.c$@\1@;s/-/_/g;H;${g;s/\n//;s/\n/$|^/gp}')\$"
152 155
155 # 3) Sort the list, keeping only one of each entry. 158 # 3) Sort the list, keeping only one of each entry.
156 # 4) Convert to lower case. 159 # 4) Convert to lower case.
157 # 5) Remove any config symbol not recognized as a filename from step 1. 160 # 5) Remove any config symbol not recognized as a filename from step 1.
158 # 6) Add "toys/*/" prefix and ".c" suffix. 161 # 6) Add "toys/*/" prefix and ".c" suffix.
159 162
160 TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/p' < .config \ 163 TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/p' < "$KCONFIG_CONFIG" \
161 | sort -u | tr A-Z a-z | grep -E "$TOYFILES" | sed 's@\(.*\)@toys/\*/\1.c@') 164 | sort -u | tr A-Z a-z | grep -E "$TOYFILES" | sed 's@\(.*\)@toys/\*/\1.c@')
162 165
163 echo "Library probe..." 166 echo "Library probe..."
164 167
165 # We trust --as-needed to remove each library if we don't use any symbols 168 # We trust --as-needed to remove each library if we don't use any symbols