Mercurial > hg > toybox
comparison Makefile @ 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 | cd4d5630c978 |
children | 163498bf547b |
comparison
equal
deleted
inserted
replaced
232:cd4d5630c978 | 233:d4176f3f3835 |
---|---|
1 # Makefile for toybox. | 1 # Makefile for toybox. |
2 # Copyright 2006 Rob Landley <rob@landley.net> | 2 # Copyright 2006 Rob Landley <rob@landley.net> |
3 | 3 |
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 | |
9 HOSTCC = gcc | |
10 | |
11 # A synonym. | |
12 CROSS_COMPILE = $(CROSS) | |
13 | |
14 all: toybox | 4 all: toybox |
15 | 5 |
16 .PHONY: clean distclean baseline bloatcheck install_flat test tests help | 6 toybox toybox_unstripped: |
7 scripts/make.sh | |
8 | |
9 .PHONY: clean distclean baseline bloatcheck install_flat test tests help \ | |
10 toybox toybox_unstripped | |
17 | 11 |
18 include kconfig/Makefile | 12 include kconfig/Makefile |
19 | 13 |
20 # defconfig is the "maximum sane config"; allyesconfig minus debugging and such. | 14 $(KCONFIG_TOP): generated/Config.in |
21 #defconfig: allyesconfig | 15 generated/Config.in: |
22 # @sed -i -r -e "s/^(CONFIG_TOYBOX_(DEBUG|FREE))=.*/# \1 is not set/" .config | 16 scripts/genconfig.sh |
23 | 17 |
24 .config: Config.in toys/Config.in | 18 HOSTCC:=cc |
25 | |
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. | |
29 generated/gen_config.h: .config | |
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' $< > $@ | |
37 | 19 |
38 # Development targets | 20 # Development targets |
39 baseline: toybox_unstripped | 21 baseline: toybox_unstripped |
40 @cp toybox_unstripped toybox_old | 22 @cp toybox_unstripped toybox_old |
41 | 23 |
42 bloatcheck: toybox_old toybox_unstripped | 24 bloatcheck: toybox_old toybox_unstripped |
43 @scripts/bloat-o-meter toybox_old toybox_unstripped | 25 @scripts/bloat-o-meter toybox_old toybox_unstripped |
44 | |
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@') | |
48 | |
49 # The following still depends on generated/help.h even when it's not there, so | |
50 # *.h isn't sufficient by itself. | |
51 | |
52 toybox_unstripped: generated/gen_config.h generated/help.h $(toyfiles) toys/toylist.h toys/*.h lib/*.h toys.h | |
53 $(CC) $(CCFLAGS) -I . $(toyfiles) -o toybox_unstripped $(OPTIMIZE) | |
54 | |
55 toybox: toybox_unstripped | |
56 $(STRIP) toybox_unstripped -o toybox | |
57 | |
58 toys/help.c: generated/help.h | |
59 | |
60 generated/help.h: Config.in toys/Config.in scripts/config2help.py | |
61 scripts/config2help.py Config.in > generated/help.h | |
62 | 26 |
63 instlist: toybox | 27 instlist: toybox |
64 $(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist | 28 $(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist |
65 | 29 |
66 install_flat: instlist | 30 install_flat: instlist |
67 @mkdir -p $(PREFIX)/ | 31 @mkdir -p $(PREFIX)/ |
68 @cp toybox $(PREFIX)/ | 32 @cp toybox $(PREFIX)/ |
69 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done | 33 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done |
70 | 34 |
71 clean:: | 35 clean:: |
72 rm -f toybox toybox_unstripped generated/gen_config.h instlist | 36 rm -f toybox toybox_unstripped generated/config.h generated/Config.in \ |
37 instlist | |
73 | 38 |
74 distclean: clean | 39 distclean: clean |
75 rm -f toybox_old .config* generated/help.h | 40 rm -f toybox_old .config* generated/help.h |
76 | 41 |
77 test: tests | 42 test: tests |
78 | 43 |
79 tests: | 44 tests: |
80 scripts/testall.sh | 45 scripts/testall.sh |
81 | 46 |
82 help:: | 47 help:: |
48 @echo ' toybox - Build toybox.' | |
83 @echo ' baseline - Create busybox_old for use by bloatcheck.' | 49 @echo ' baseline - Create busybox_old for use by bloatcheck.' |
84 @echo ' bloatcheck - Report size differences between old and current versions' | 50 @echo ' bloatcheck - Report size differences between old and current versions' |
51 @echo ' test - Run test suite against compiled commands.' | |
52 @echo ' clean - Delete temporary files.' | |
53 @echo ' distclean - Delete everything that isn't shipped.' | |
54 @echo ' install_flat - Install toybox into $PREFIX directory.' |