2 # Copyright 2006 Rob Landley <rob@landley.net>
4 CFLAGS := $(CFLAGS) -Wall -Wundef -Wno-char-subscripts
5 CCFLAGS = $(CFLAGS) -funsigned-char
6 OPTIMIZE = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections
7 CC = $(CROSS_COMPILE)gcc
8 STRIP = $(CROSS_COMPILE)strip
12 CROSS_COMPILE = $(CROSS)
18 include kconfig/Makefile
20 # defconfig is the "maximum sane config"; allyesconfig minus debugging and such.
21 #defconfig: allyesconfig
22 # @sed -i -r -e "s/^(CONFIG_TOYBOX_(DEBUG|FREE))=.*/# \1 is not set/" .config
24 .config: Config.in toys/Config.in
26 # The long and roundabout sed is to make old versions of sed happy. New ones
27 # have '\n' so can replace one line with two without all the branches and
28 # mucking about with hold space.
30 sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \
31 -e 't notset' -e 'b tryisset' -e ':notset' \
32 -e 'h' -e 's/.*/#define CFG_& 0/p' \
33 -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \
34 -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \
35 -e 'h' -e 's/.*/#define CFG_& 1/p' \
36 -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@
39 baseline: toybox_unstripped
40 @cp toybox_unstripped toybox_old
42 bloatcheck: toybox_old toybox_unstripped
43 @scripts/bloat-o-meter toybox_old toybox_unstripped
45 # Get list of .c files to compile, including toys/*.c files from .config
46 toyfiles = main.c lib/*.c \
47 $(shell scripts/cfg2files.sh < .config | sed 's@\(.*\)@toys/\1.c@')
49 # The following still depends on toys/help.h even when it's not there, so *.h
50 # isn't sufficient by itself.
52 toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h toys/help.h toys/*.h lib/*.h toys.h
53 $(CC) $(CCFLAGS) -I . $(toyfiles) -o toybox_unstripped $(OPTIMIZE)
55 toybox: toybox_unstripped
56 $(STRIP) toybox_unstripped -o toybox
58 toys/help.c: toys/help.h
60 toys/help.h: Config.in toys/Config.in scripts/config2help.py
61 scripts/config2help.py Config.in > toys/help.h
64 $(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist
66 install_flat: instlist
69 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done
72 rm -f toybox toybox_unstripped gen_config.h instlist
75 rm -f toybox_old .config* toys/help.h
83 @echo ' baseline - Create busybox_old for use by bloatcheck.'
84 @echo ' bloatcheck - Report size differences between old and current versions'