Mercurial > hg > toybox
comparison scripts/make.sh @ 233:d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
toys/*.c. Move relevant info into comment at the top of each toys/*.c. Also
convert more of Makefile into a thin wrapper around shell scripts that actually
do the work. (Makefile is only still there for the user interface.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 19 Jan 2008 17:08:39 -0600 |
parents | |
children | 163498bf547b |
comparison
equal
deleted
inserted
replaced
232:cd4d5630c978 | 233:d4176f3f3835 |
---|---|
1 #!/bin/bash | |
2 | |
3 # Grab default values for $CFLAGS and such. | |
4 | |
5 source ./configure | |
6 | |
7 echo "Extract configuration information from toys/*.c files." | |
8 scripts/genconfig.sh | |
9 | |
10 # Only recreate generated/help.h if python is installed | |
11 if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ] | |
12 then | |
13 echo "Extract help text from Config.in." | |
14 scripts/config2help.py Config.in > generated/help.h || exit 1 | |
15 fi | |
16 | |
17 echo "Make generated/config.h from .config." | |
18 | |
19 # This long and roundabout sed invocation is to make old versions of sed happy. | |
20 # New ones have '\n' so can replace one line with two without all the branches | |
21 # and tedious mucking about with hold space. | |
22 | |
23 sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ | |
24 -e 't notset' -e 'b tryisset' -e ':notset' \ | |
25 -e 'h' -e 's/.*/#define CFG_& 0/p' \ | |
26 -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \ | |
27 -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \ | |
28 -e 'h' -e 's/.*/#define CFG_& 1/p' \ | |
29 -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' .config > \ | |
30 generated/config.h || exit 1 | |
31 | |
32 #for i in $(echo toys/*.c | sort) | |
33 #do | |
34 # Grab the function command names | |
35 # NAME=$(echo $i | sed -e 's@toys/@@' -e 's@\.c@@') | |
36 #sed -n '/struct '$NAME'_command {/,/};/p' $i \ | |
37 # >> generated/globals_big.h | |
38 # echo "struct ${NAME}_command;" >> generated/globals.h | |
39 #done | |
40 | |
41 # Extract a list of toys/*.c files to compile from the data in ".config" with | |
42 # sed, sort, and tr: | |
43 | |
44 # 1) Grab the XXX part of all CONFIG_XXX entries, removing everything after the | |
45 # second underline | |
46 # 2) Sort the list, keeping only one of each entry. | |
47 # 3) Convert to lower case. | |
48 # 4) Remove toybox itself from the list (as that indicates global symbols). | |
49 # 5) Add "toys/" prefix and ".c" suffix. | |
50 | |
51 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@' ) | |
52 | |
53 echo "Compile toybox..." | |
54 | |
55 $DEBUG $CC $CFLAGS -I . -o toybox_unstripped $OPTIMIZE main.c lib/*.c $TOYFILES | |
56 $DEBUG $STRIP toybox_unstripped -o toybox |