blob: 353a4ac1bc3e433b36cdbf88473d577041510fff [file] [log] [blame]
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +00001# This is completely unsupported.
2# Fix COMBINED_COMPILE upstream (in the Kbuild) and propagate
3# the changes back
4srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
5objtree := $(CURDIR)
6src := $(srctree)
7obj := $(objtree)
8
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +00009# Look for make include files relative to root of kernel src
10MAKEFLAGS += --include-dir=$(srctree)
11
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000012default: busybox
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000013
14ifndef HOSTCC
15HOSTCC = cc
16endif
17AS = $(CROSS_COMPILE)as
18CC = $(CROSS_COMPILE)gcc
19LD = $(CC) -nostdlib
20CPP = $(CC) -E
21AR = $(CROSS_COMPILE)ar
22NM = $(CROSS_COMPILE)nm
23STRIP = $(CROSS_COMPILE)strip
24OBJCOPY = $(CROSS_COMPILE)objcopy
25OBJDUMP = $(CROSS_COMPILE)objdump
26
27CFLAGS := $(CFLAGS)
28CPPFLAGS+= -D"KBUILD_STR(s)=\#s" #-Q
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000029
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000030include .config
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000031# We need some generic definitions
32include $(srctree)/scripts/Kbuild.include
33
34include Makefile.flags
Bernhard Reutner-Fischer2af86042008-05-08 13:25:20 +000035
36SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
37 -e s/arm.*/arm/ -e s/sa110/arm/ \
38 -e s/s390x/s390/ -e s/parisc64/parisc/ \
39 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
40ARCH ?= $(SUBARCH)
41
42# Cross compiling and selecting different set of gcc/bin-utils
43-include $(srctree)/arch/$(ARCH)/Makefile
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000044ifdef CONFIG_FEATURE_COMPRESS_USAGE
45usage_stuff = include/usage_compressed.h
46endif
47
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000048ifndef BB_VER
49BB_VER:=""
50endif
51
Bernhard Reutner-Fischereecd5882008-04-11 12:42:23 +000052WHOLE_PROGRAM:=$(call cc-option,-fwhole-program,)
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000053
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000054# pull in the config stuff
Bernhard Reutner-Fischer64332bf2007-05-15 09:07:06 +000055lib-all-y := applets/applets.o
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000056lib-y:=
57include procps/Kbuild
58lib-all-y += $(patsubst %,procps/%,$(sort $(lib-y)))
59lib-y:=
60include networking/Kbuild
61lib-all-y += $(patsubst %,networking/%,$(sort $(lib-y)))
62lib-y:=
63include networking/udhcp/Kbuild
64lib-all-y += $(patsubst %,networking/udhcp/%,$(sort $(lib-y)))
65lib-y:=
66include networking/libiproute/Kbuild
67lib-all-y += $(patsubst %,networking/libiproute/%,$(sort $(lib-y)))
68lib-y:=
69include loginutils/Kbuild
70lib-all-y += $(patsubst %,loginutils/%,$(sort $(lib-y)))
71lib-y:=
72include archival/Kbuild
73lib-all-y += $(patsubst %,archival/%,$(sort $(lib-y)))
74lib-y:=
75include archival/libunarchive/Kbuild
76lib-all-y += $(patsubst %,archival/libunarchive/%,$(sort $(lib-y)))
77lib-y:=
78include applets/Kbuild
79lib-all-y += $(patsubst %,applets/%,$(sort $(lib-y)))
80lib-y:=
81include e2fsprogs/Kbuild
82lib-all-y += $(patsubst %,e2fsprogs/%,$(sort $(lib-y)))
83lib-y:=
84#include e2fsprogs/old_e2fsprogs/Kbuild
85#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/%,$(sort $(lib-y)))
86#lib-y:=
87#include e2fsprogs/old_e2fsprogs/ext2fs/Kbuild
88#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/ext2fs/%,$(sort $(lib-y)))
89#lib-y:=
90#include e2fsprogs/old_e2fsprogs/blkid/Kbuild
91#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/blkid/%,$(sort $(lib-y)))
92#lib-y:=
93#include e2fsprogs/old_e2fsprogs/uuid/Kbuild
94#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/uuid/%,$(sort $(lib-y)))
95#lib-y:=
96#include e2fsprogs/old_e2fsprogs/e2p/Kbuild
97#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/e2p/%,$(sort $(lib-y)))
98#lib-y:=
99include debianutils/Kbuild
100lib-all-y += $(patsubst %,debianutils/%,$(sort $(lib-y)))
101lib-y:=
102include runit/Kbuild
103lib-all-y += $(patsubst %,runit/%,$(sort $(lib-y)))
104lib-y:=
105include modutils/Kbuild
106lib-all-y += $(patsubst %,modutils/%,$(sort $(lib-y)))
107lib-y:=
108include miscutils/Kbuild
109lib-all-y += $(patsubst %,miscutils/%,$(sort $(lib-y)))
110lib-y:=
111include coreutils/libcoreutils/Kbuild
112lib-all-y += $(patsubst %,coreutils/libcoreutils/%,$(sort $(lib-y)))
113lib-y:=
114include coreutils/Kbuild
115lib-all-y += $(patsubst %,coreutils/%,$(sort $(lib-y)))
116lib-y:=
117include sysklogd/Kbuild
118lib-all-y += $(patsubst %,sysklogd/%,$(sort $(lib-y)))
119lib-y:=
120include shell/Kbuild
121lib-all-y += $(patsubst %,shell/%,$(sort $(lib-y)))
122lib-y:=
123include console-tools/Kbuild
124lib-all-y += $(patsubst %,console-tools/%,$(sort $(lib-y)))
125lib-y:=
126include findutils/Kbuild
127lib-all-y += $(patsubst %,findutils/%,$(sort $(lib-y)))
128lib-y:=
129include util-linux/Kbuild
130lib-all-y += $(patsubst %,util-linux/%,$(sort $(lib-y)))
131lib-y:=
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +0000132include util-linux/volume_id/Kbuild
133lib-all-y += $(patsubst %,util-linux/volume_id/%,$(sort $(lib-y)))
134lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000135include init/Kbuild
136lib-all-y += $(patsubst %,init/%,$(sort $(lib-y)))
137lib-y:=
138include libpwdgrp/Kbuild
139lib-all-y += $(patsubst %,libpwdgrp/%,$(sort $(lib-y)))
140lib-y:=
141include editors/Kbuild
142lib-all-y += $(patsubst %,editors/%,$(sort $(lib-y)))
143lib-y:=
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +0000144include printutils/Kbuild
145lib-all-y += $(patsubst %,printutils/%,$(sort $(lib-y)))
146lib-y:=
Bernhard Reutner-Fischere11b4a42007-03-09 08:46:31 +0000147include selinux/Kbuild
148lib-all-y += $(patsubst %,selinux/%,$(sort $(lib-y)))
149lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000150include scripts/Kbuild
151lib-all-y += $(patsubst %,scripts/%,$(sort $(lib-y)))
152lib-y:=
153include libbb/Kbuild
154lib-all-y += $(patsubst %,libbb/%,$(sort $(lib-y)))
155lib-y:=
156
Bernhard Reutner-Fischer1d690db2008-04-11 12:31:57 +0000157comma:=,
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000158busybox_unstripped.o: $(usage_stuff) include/applet_tables.h include/autoconf.h
Denis Vlasenko93b82632008-04-11 11:27:29 +0000159 $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) \
Bernhard Reutner-Fischer1d690db2008-04-11 12:31:57 +0000160 $(patsubst %,-Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS)) \
Denis Vlasenko93b82632008-04-11 11:27:29 +0000161 -DGCC_COMBINE=1 \
162 --combine $(WHOLE_PROGRAM) \
Bernhard Reutner-Fischer493691a2007-02-02 16:11:24 +0000163 -funit-at-a-time -Wno-error -std=gnu99 \
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000164 -c -o busybox_unstripped.o \
165 $(lib-all-y:.o=.c)
166
167busybox: busybox_unstripped.o
168 $(srctree)/scripts/trylink \
169 busybox_unstripped \
170 "$(CC)" \
171 "$(CFLAGS)" \
172 "$(LDFLAGS)" \
173 "busybox_unstripped.o" \
174 "" \
175 "crypt m"
Bernhard Reutner-Fischer64332bf2007-05-15 09:07:06 +0000176 cp -f $(@)_unstripped $@
177 -$(STRIP) -s -R .note -R .comment -R .version $@
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000178
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000179# If .config is newer than include/autoconf.h, someone tinkered
180# with it and forgot to run make oldconfig.
181include/autoconf.h: .config
182 $(MAKE) -f $(srctree)/Makefile silentoldconfig
183
184applets/usage: include/autoconf.h
Denis Vlasenko93b82632008-04-11 11:27:29 +0000185 $(HOSTCC) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I$(srctree)/include -o applets/usage applets/usage.c
186
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000187applets/applet_tables: include/autoconf.h
Denis Vlasenko93b82632008-04-11 11:27:29 +0000188 $(HOSTCC) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I$(srctree)/include -o applets/applet_tables applets/applet_tables.c
189
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000190include/usage_compressed.h: $(srctree)/include/usage.h applets/usage
191 $(srctree)/applets/usage_compressed include/usage_compressed.h applets
192
Denis Vlasenko93b82632008-04-11 11:27:29 +0000193include/applet_tables.h: $(srctree)/include/applets.h
194 applets/applet_tables include/applet_tables.h