OSDN Git Service

Add bloat-o-meter, make bloatcheck, and scripts/showasm.
[android-x86/external-toybox.git] / Makefile
1 # Makefile for toybox.
2 # Copyright 2006 Rob Landley <rob@landley.net>
3
4 CFLAGS  = -Wall -Wundef -Os
5 CC      = $(CROSS_COMPILE)gcc $(CFLAGS) -funsigned-char
6 STRIP   = $(CROSS_COMPILE)strip
7 HOST_CC = gcc $(CFLAGS) -funsigned-char
8
9 all: toybox
10
11 .PHONY: clean
12
13 include kconfig/Makefile
14
15 .config: Config.in toys/Config.in
16
17 # The long and roundabout sed is to make old versions of sed happy.  New ones
18 # have '\n' so can replace one line with two without all the branches and
19 # mucking about with hold space.
20 gen_config.h: .config
21         sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \
22           -e 't notset' -e 'b tryisset' -e ':notset' \
23           -e 'h' -e 's/.*/#define CFG_& 0/p' \
24           -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \
25           -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \
26           -e 'h' -e 's/.*/#define CFG_& 1/p' \
27           -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@
28
29 # Development targets
30 baseline: toybox_unstripped
31         @cp toybox_unstripped toybox_old
32
33 bloatcheck: toybox_old toybox_unstripped
34         @scripts/bloat-o-meter toybox_old toybox_unstripped
35
36 # Actual build
37
38 toyfiles = main.c toys/*.c lib/*.c
39 toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/lib.h toys.h
40         $(CC) $(CFLAGS) -I . $(toyfiles) -o toybox_unstripped \
41                 -ffunction-sections -fdata-sections -Wl,--gc-sections
42
43 toybox: toybox_unstripped
44         $(STRIP) toybox_unstripped -o toybox
45 clean::
46         rm -f toybox gen_config.h
47
48 distclean: clean
49         rm -f .config
50
51 help::
52         @echo  '  baseline        - Create busybox_old for use by bloatcheck.'
53         @echo  '  bloatcheck      - Report size differences between old and current versions'