2 # Copyright 2006 Rob Landley <rob@landley.net>
4 CFLAGS := $(CFLAGS) -Wall -Wundef -Wno-char-subscripts -Os
5 CCFLAGS = $(CFLAGS) -funsigned-char
6 CC = $(CROSS_COMPILE)gcc
7 STRIP = $(CROSS_COMPILE)strip
11 CROSS_COMPILE = $(CROSS)
17 include kconfig/Makefile
19 # defconfig is the "maximum sane config"; allyesconfig minus debugging and such.
20 defconfig: allyesconfig
21 @sed -i -r -e "s/^(CONFIG_TOYBOX_(DEBUG|FREE))=.*/# \1 is not set/" .config
23 .config: Config.in toys/Config.in
25 # The long and roundabout sed is to make old versions of sed happy. New ones
26 # have '\n' so can replace one line with two without all the branches and
27 # mucking about with hold space.
29 sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \
30 -e 't notset' -e 'b tryisset' -e ':notset' \
31 -e 'h' -e 's/.*/#define CFG_& 0/p' \
32 -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \
33 -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \
34 -e 'h' -e 's/.*/#define CFG_& 1/p' \
35 -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@
38 baseline: toybox_unstripped
39 @cp toybox_unstripped toybox_old
41 bloatcheck: toybox_old toybox_unstripped
42 @scripts/bloat-o-meter toybox_old toybox_unstripped
44 # Get list of toys/*.c files from .config
46 toysfiles = $(shell sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' .config | sort -u | tr A-Z a-z | grep -v '^toybox$$' | sed 's@\(.*\)@toys/\1.c@')
48 # Compile toybox from source
50 toyfiles = main.c lib/*.c $(toysfiles)
51 toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/*.h toys.h
52 $(CC) $(CCFLAGS) -I . $(toyfiles) -o toybox_unstripped \
53 -ffunction-sections -fdata-sections -Wl,--gc-sections
55 toybox: toybox_unstripped
56 $(STRIP) toybox_unstripped -o toybox
59 $(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist
61 install_flat: instlist
64 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done
67 rm -f toybox toybox_old toybox_unstripped gen_config.h instlist
73 @echo ' baseline - Create busybox_old for use by bloatcheck.'
74 @echo ' bloatcheck - Report size differences between old and current versions'