Mercurial > hg > toybox
annotate Makefile @ 188:6a12feedd893
Minor cleanups/tweaks to touch.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 30 Nov 2007 04:37:24 -0600 |
parents | 2d0de0d21e80 |
children | e83f92dc44a0 |
rev | line source |
---|---|
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
1 # Makefile for toybox. |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
2 # Copyright 2006 Rob Landley <rob@landley.net> |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
3 |
141
478d3c77068b
Move optimizer flags to OPTIMIZE, so "make CC=tcc OPTIMIZE=" is an option.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
4 CFLAGS := $(CFLAGS) -Wall -Wundef -Wno-char-subscripts |
119
8b5ae5f607af
Make it easier to specify which compiler to use.
Rob Landley <rob@landley.net>
parents:
109
diff
changeset
|
5 CCFLAGS = $(CFLAGS) -funsigned-char |
141
478d3c77068b
Move optimizer flags to OPTIMIZE, so "make CC=tcc OPTIMIZE=" is an option.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
6 OPTIMIZE = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections |
119
8b5ae5f607af
Make it easier to specify which compiler to use.
Rob Landley <rob@landley.net>
parents:
109
diff
changeset
|
7 CC = $(CROSS_COMPILE)gcc |
41
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
8 STRIP = $(CROSS_COMPILE)strip |
119
8b5ae5f607af
Make it easier to specify which compiler to use.
Rob Landley <rob@landley.net>
parents:
109
diff
changeset
|
9 HOSTCC = gcc |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
10 |
123
81a324ef9167
More cross compiling infrastructure.
Rob Landley <rob@landley.net>
parents:
119
diff
changeset
|
11 # A synonym. |
81a324ef9167
More cross compiling infrastructure.
Rob Landley <rob@landley.net>
parents:
119
diff
changeset
|
12 CROSS_COMPILE = $(CROSS) |
81a324ef9167
More cross compiling infrastructure.
Rob Landley <rob@landley.net>
parents:
119
diff
changeset
|
13 |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
14 all: toybox |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
15 |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
16 .PHONY: clean |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
17 |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
18 include kconfig/Makefile |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
19 |
90
7c77c6ec17ee
Add "make defconfig". Modify global options to start with CONFIG_TOYBOX_.
Rob Landley <rob@landley.net>
parents:
89
diff
changeset
|
20 # defconfig is the "maximum sane config"; allyesconfig minus debugging and such. |
133
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
21 #defconfig: allyesconfig |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
22 # @sed -i -r -e "s/^(CONFIG_TOYBOX_(DEBUG|FREE))=.*/# \1 is not set/" .config |
90
7c77c6ec17ee
Add "make defconfig". Modify global options to start with CONFIG_TOYBOX_.
Rob Landley <rob@landley.net>
parents:
89
diff
changeset
|
23 |
19
414625f97667
Better dependencies, and feed the linker --gc-sections. (Which is not an
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
24 .config: Config.in toys/Config.in |
414625f97667
Better dependencies, and feed the linker --gc-sections. (Which is not an
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
25 |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
26 # The long and roundabout sed is to make old versions of sed happy. New ones |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
27 # have '\n' so can replace one line with two without all the branches and |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
28 # mucking about with hold space. |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
29 gen_config.h: .config |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
30 sed -n -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
31 -e 't notset' -e 'b tryisset' -e ':notset' \ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
32 -e 'h' -e 's/.*/#define CFG_& 0/p' \ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
33 -e 'g' -e 's/.*/#define USE_&(...)/p' -e 'd' -e ':tryisset' \ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
34 -e 's/^CONFIG_\(.*\)=y.*/\1/' -e 't isset' -e 'd' -e ':isset' \ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
35 -e 'h' -e 's/.*/#define CFG_& 1/p' \ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
36 -e 'g' -e 's/.*/#define USE_&(...) __VA_ARGS__/p' $< > $@ |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
37 |
41
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
38 # Development targets |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
39 baseline: toybox_unstripped |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
40 @cp toybox_unstripped toybox_old |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
41 |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
42 bloatcheck: toybox_old toybox_unstripped |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
43 @scripts/bloat-o-meter toybox_old toybox_unstripped |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
44 |
133
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
45 # Get list of .c files to compile, including toys/*.c files from .config |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
46 toyfiles = main.c lib/*.c \ |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
47 $(shell scripts/cfg2files.sh < .config | sed 's@\(.*\)@toys/\1.c@') |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
48 |
184
2d0de0d21e80
Add a comment about a case that made me stop and think.
Rob Landley <rob@landley.net>
parents:
183
diff
changeset
|
49 # The following still depends on toys/help.h even when it's not there, so *.h |
2d0de0d21e80
Add a comment about a case that made me stop and think.
Rob Landley <rob@landley.net>
parents:
183
diff
changeset
|
50 # isn't sufficient by itself. |
2d0de0d21e80
Add a comment about a case that made me stop and think.
Rob Landley <rob@landley.net>
parents:
183
diff
changeset
|
51 |
183
93899f7c3e0c
Rebuild toybox when a header file changes
Charlie Shepherd <masterdriverz@gentoo.org>
parents:
158
diff
changeset
|
52 toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h toys/help.h toys/*.h lib/*.h toys.h |
141
478d3c77068b
Move optimizer flags to OPTIMIZE, so "make CC=tcc OPTIMIZE=" is an option.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
53 $(CC) $(CCFLAGS) -I . $(toyfiles) -o toybox_unstripped $(OPTIMIZE) |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
54 |
41
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
55 toybox: toybox_unstripped |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
56 $(STRIP) toybox_unstripped -o toybox |
89 | 57 |
139
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
133
diff
changeset
|
58 toys/help.c: toys/help.h |
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
133
diff
changeset
|
59 |
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
133
diff
changeset
|
60 toys/help.h: Config.in toys/Config.in scripts/config2help.py |
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
133
diff
changeset
|
61 scripts/config2help.py Config.in > toys/help.h |
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
133
diff
changeset
|
62 |
89 | 63 instlist: toybox |
119
8b5ae5f607af
Make it easier to specify which compiler to use.
Rob Landley <rob@landley.net>
parents:
109
diff
changeset
|
64 $(HOSTCC) $(CCFLAGS) -I . scripts/install.c -o instlist |
89 | 65 |
66 install_flat: instlist | |
67 @mkdir -p $(PREFIX)/ | |
68 @cp toybox $(PREFIX)/ | |
69 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done | |
70 | |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
71 clean:: |
150
beeab8a27a7d
Move toybox_old delete (for bloatcheck) from clean to distclean.
Rob Landley <rob@landley.net>
parents:
141
diff
changeset
|
72 rm -f toybox toybox_unstripped gen_config.h instlist |
14
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
73 |
f8e628f61f16
Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents:
7
diff
changeset
|
74 distclean: clean |
152
28d2042bcc13
Patch fromm Roberto Foglietta: distclean should remove toys/help.h
Rob Landley <rob@landley.net>
parents:
150
diff
changeset
|
75 rm -f toybox_old .config* toys/help.h |
41
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
76 |
133
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
77 test: tests |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
78 |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
79 tests: |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
80 scripts/testall.sh |
a459c6b39645
Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents:
123
diff
changeset
|
81 |
41
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
82 help:: |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
83 @echo ' baseline - Create busybox_old for use by bloatcheck.' |
a43bdc6f53af
Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents:
38
diff
changeset
|
84 @echo ' bloatcheck - Report size differences between old and current versions' |