annotate Makefile @ 109:1c5fa783450b

Convert HOST_CC to HOSTCC to be more like uClibc build.
author Rob Landley <rob@landley.net>
date Mon, 12 Mar 2007 21:17:01 -0400
parents c3d1d74d5d8f
children 8b5ae5f607af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
45
e60d48d30ef0 Make some of gcc 4.1's dumber warnings go away.
Rob Landley <rob@landley.net>
parents: 42
diff changeset
4 CFLAGS = -Wall -Wundef -Wno-char-subscripts -Os
38
b707dfcd403c Reduce flag duplication and make kconfig use HOST_CC.
Rob Landley <rob@landley.net>
parents: 31
diff changeset
5 CC = $(CROSS_COMPILE)gcc $(CFLAGS) -funsigned-char
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
6 STRIP = $(CROSS_COMPILE)strip
109
1c5fa783450b Convert HOST_CC to HOSTCC to be more like uClibc build.
Rob Landley <rob@landley.net>
parents: 100
diff changeset
7 HOSTCC = gcc $(CFLAGS) -funsigned-char
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
8
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
9 all: toybox
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
10
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
11 .PHONY: clean
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
12
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
13 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
14
90
7c77c6ec17ee Add "make defconfig". Modify global options to start with CONFIG_TOYBOX_.
Rob Landley <rob@landley.net>
parents: 89
diff changeset
15 # defconfig is the "maximum sane config"; allyesconfig minus debugging and such.
7c77c6ec17ee Add "make defconfig". Modify global options to start with CONFIG_TOYBOX_.
Rob Landley <rob@landley.net>
parents: 89
diff changeset
16 defconfig: allyesconfig
91
b596b9b3b2af Missing comma, and slight simplification in defconfig sed invocation.
Rob Landley <rob@landley.net>
parents: 90
diff changeset
17 @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
18
19
414625f97667 Better dependencies, and feed the linker --gc-sections. (Which is not an
Rob Landley <rob@landley.net>
parents: 14
diff changeset
19 .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
20
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
21 # 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
22 # 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
23 # 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
24 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
25 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
26 -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
27 -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
28 -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
29 -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
30 -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
31 -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
32
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
33 # Development targets
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
34 baseline: toybox_unstripped
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
35 @cp toybox_unstripped toybox_old
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
36
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
37 bloatcheck: toybox_old toybox_unstripped
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
38 @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
39
94
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
40 # Get list of toys/*.c files from .config
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
41
100
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
42 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@')
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
43
94
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
44 # Compile toybox from source
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
45
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
46 toyfiles = main.c lib/*.c $(toysfiles)
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
47 toybox_unstripped: gen_config.h $(toyfiles) toys/toylist.h lib/*.h toys.h
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
48 $(CC) $(CFLAGS) -I . $(toyfiles) -o toybox_unstripped \
94
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 91
diff changeset
49 -ffunction-sections -fdata-sections -Wl,--gc-sections
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
50
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
51 toybox: toybox_unstripped
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
52 $(STRIP) toybox_unstripped -o toybox
89
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
53
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
54 instlist: toybox
109
1c5fa783450b Convert HOST_CC to HOSTCC to be more like uClibc build.
Rob Landley <rob@landley.net>
parents: 100
diff changeset
55 $(HOSTCC) -I . scripts/install.c -o instlist
89
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
56
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
57 install_flat: instlist
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
58 @mkdir -p $(PREFIX)/
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
59 @cp toybox $(PREFIX)/
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
60 @for i in `./instlist`; do ln -s toybox "$(PREFIX)/$$i"; done
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
61
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
62 clean::
89
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
63 rm -f toybox toybox_old 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
64
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
65 distclean: clean
42
72ff42c01d92 Teach clean and distclean to zap more files.
Rob Landley <rob@landley.net>
parents: 41
diff changeset
66 rm -f .config*
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
67
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
68 help::
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
69 @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
70 @echo ' bloatcheck - Report size differences between old and current versions'