blob: 0eced2982357880de3d70a6a134eaae7fd1baf8f [file] [log] [blame]
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +00001# This is completely unsupported.
Denis Vlasenkob8e653b2008-06-02 04:51:29 +00002#
3# Uasge: make -f scripts/Makefile.IMA
4#
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +00005# Fix COMBINED_COMPILE upstream (in the Kbuild) and propagate
6# the changes back
7srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
8objtree := $(CURDIR)
9src := $(srctree)
10obj := $(objtree)
11
Denys Vlasenko726ebba2011-03-06 23:09:42 +010012# Make generated files
13DUMMY := $(shell $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree) >&2)
14
15# Look for make include files relative to root of src
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000016MAKEFLAGS += --include-dir=$(srctree)
17
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000018default: busybox
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000019
Denis Vlasenkob8e653b2008-06-02 04:51:29 +000020include .config
21
22# Cross compiling and selecting different set of gcc/bin-utils
23ifeq ($(CROSS_COMPILE),)
24CROSS_COMPILE := $(subst ",,$(CONFIG_CROSS_COMPILER_PREFIX))
25endif
26
27ifneq ($(CROSS_COMPILE),)
28SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
29else
30SUBARCH := $(shell uname -m)
31endif
32SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
33 -e s/arm.*/arm/ -e s/sa110/arm/ \
34 -e s/s390x/s390/ -e s/parisc64/parisc/ \
35 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
36ARCH ?= $(SUBARCH)
37
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000038ifndef HOSTCC
39HOSTCC = cc
40endif
41AS = $(CROSS_COMPILE)as
42CC = $(CROSS_COMPILE)gcc
43LD = $(CC) -nostdlib
44CPP = $(CC) -E
45AR = $(CROSS_COMPILE)ar
46NM = $(CROSS_COMPILE)nm
47STRIP = $(CROSS_COMPILE)strip
48OBJCOPY = $(CROSS_COMPILE)objcopy
49OBJDUMP = $(CROSS_COMPILE)objdump
50
Denis Vlasenko1da86d22008-06-04 11:28:24 +000051CFLAGS := $(CFLAGS)
52CPPFLAGS += -D"KBUILD_STR(s)=\#s" #-Q
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000053
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000054# We need some generic definitions
55include $(srctree)/scripts/Kbuild.include
56
57include Makefile.flags
Bernhard Reutner-Fischer2af86042008-05-08 13:25:20 +000058
Bernhard Reutner-Fischer2af86042008-05-08 13:25:20 +000059-include $(srctree)/arch/$(ARCH)/Makefile
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000060ifdef CONFIG_FEATURE_COMPRESS_USAGE
61usage_stuff = include/usage_compressed.h
62endif
63
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000064ifndef BB_VER
65BB_VER:=""
66endif
67
Bernhard Reutner-Fischereecd5882008-04-11 12:42:23 +000068WHOLE_PROGRAM:=$(call cc-option,-fwhole-program,)
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000069
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000070# pull in the config stuff
Bernhard Reutner-Fischer64332bf2007-05-15 09:07:06 +000071lib-all-y := applets/applets.o
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000072lib-y:=
73include procps/Kbuild
74lib-all-y += $(patsubst %,procps/%,$(sort $(lib-y)))
75lib-y:=
76include networking/Kbuild
77lib-all-y += $(patsubst %,networking/%,$(sort $(lib-y)))
78lib-y:=
79include networking/udhcp/Kbuild
80lib-all-y += $(patsubst %,networking/udhcp/%,$(sort $(lib-y)))
81lib-y:=
82include networking/libiproute/Kbuild
83lib-all-y += $(patsubst %,networking/libiproute/%,$(sort $(lib-y)))
84lib-y:=
85include loginutils/Kbuild
86lib-all-y += $(patsubst %,loginutils/%,$(sort $(lib-y)))
87lib-y:=
88include archival/Kbuild
89lib-all-y += $(patsubst %,archival/%,$(sort $(lib-y)))
90lib-y:=
Denys Vlasenko833d4e72010-11-03 02:38:31 +010091include archival/libarchive/Kbuild
92lib-all-y += $(patsubst %,archival/libarchive/%,$(sort $(lib-y)))
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000093lib-y:=
94include applets/Kbuild
95lib-all-y += $(patsubst %,applets/%,$(sort $(lib-y)))
96lib-y:=
97include e2fsprogs/Kbuild
98lib-all-y += $(patsubst %,e2fsprogs/%,$(sort $(lib-y)))
99lib-y:=
100#include e2fsprogs/old_e2fsprogs/Kbuild
101#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/%,$(sort $(lib-y)))
102#lib-y:=
103#include e2fsprogs/old_e2fsprogs/ext2fs/Kbuild
104#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/ext2fs/%,$(sort $(lib-y)))
105#lib-y:=
106#include e2fsprogs/old_e2fsprogs/blkid/Kbuild
107#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/blkid/%,$(sort $(lib-y)))
108#lib-y:=
109#include e2fsprogs/old_e2fsprogs/uuid/Kbuild
110#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/uuid/%,$(sort $(lib-y)))
111#lib-y:=
112#include e2fsprogs/old_e2fsprogs/e2p/Kbuild
113#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/e2p/%,$(sort $(lib-y)))
114#lib-y:=
115include debianutils/Kbuild
116lib-all-y += $(patsubst %,debianutils/%,$(sort $(lib-y)))
117lib-y:=
118include runit/Kbuild
119lib-all-y += $(patsubst %,runit/%,$(sort $(lib-y)))
120lib-y:=
121include modutils/Kbuild
122lib-all-y += $(patsubst %,modutils/%,$(sort $(lib-y)))
123lib-y:=
124include miscutils/Kbuild
125lib-all-y += $(patsubst %,miscutils/%,$(sort $(lib-y)))
126lib-y:=
Denys Vlasenko726ebba2011-03-06 23:09:42 +0100127include mailutils/Kbuild
128lib-all-y += $(patsubst %,mailutils/%,$(sort $(lib-y)))
129lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000130include coreutils/libcoreutils/Kbuild
131lib-all-y += $(patsubst %,coreutils/libcoreutils/%,$(sort $(lib-y)))
132lib-y:=
133include coreutils/Kbuild
134lib-all-y += $(patsubst %,coreutils/%,$(sort $(lib-y)))
135lib-y:=
136include sysklogd/Kbuild
137lib-all-y += $(patsubst %,sysklogd/%,$(sort $(lib-y)))
138lib-y:=
139include shell/Kbuild
140lib-all-y += $(patsubst %,shell/%,$(sort $(lib-y)))
141lib-y:=
142include console-tools/Kbuild
143lib-all-y += $(patsubst %,console-tools/%,$(sort $(lib-y)))
144lib-y:=
145include findutils/Kbuild
146lib-all-y += $(patsubst %,findutils/%,$(sort $(lib-y)))
147lib-y:=
148include util-linux/Kbuild
149lib-all-y += $(patsubst %,util-linux/%,$(sort $(lib-y)))
150lib-y:=
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +0000151include util-linux/volume_id/Kbuild
152lib-all-y += $(patsubst %,util-linux/volume_id/%,$(sort $(lib-y)))
153lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000154include init/Kbuild
155lib-all-y += $(patsubst %,init/%,$(sort $(lib-y)))
156lib-y:=
157include libpwdgrp/Kbuild
158lib-all-y += $(patsubst %,libpwdgrp/%,$(sort $(lib-y)))
159lib-y:=
160include editors/Kbuild
161lib-all-y += $(patsubst %,editors/%,$(sort $(lib-y)))
162lib-y:=
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +0000163include printutils/Kbuild
164lib-all-y += $(patsubst %,printutils/%,$(sort $(lib-y)))
165lib-y:=
Bernhard Reutner-Fischere11b4a42007-03-09 08:46:31 +0000166include selinux/Kbuild
167lib-all-y += $(patsubst %,selinux/%,$(sort $(lib-y)))
168lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000169include scripts/Kbuild
170lib-all-y += $(patsubst %,scripts/%,$(sort $(lib-y)))
171lib-y:=
172include libbb/Kbuild
173lib-all-y += $(patsubst %,libbb/%,$(sort $(lib-y)))
174lib-y:=
175
Bernhard Reutner-Fischer1d690db2008-04-11 12:31:57 +0000176comma:=,
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100177busybox_unstripped.o: $(usage_stuff) include/applet_tables.h include/NUM_APPLETS.h include/autoconf.h
Denis Vlasenko93b82632008-04-11 11:27:29 +0000178 $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) \
Bernhard Reutner-Fischer1d690db2008-04-11 12:31:57 +0000179 $(patsubst %,-Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS)) \
Denis Vlasenko93b82632008-04-11 11:27:29 +0000180 -DGCC_COMBINE=1 \
181 --combine $(WHOLE_PROGRAM) \
Bernhard Reutner-Fischer493691a2007-02-02 16:11:24 +0000182 -funit-at-a-time -Wno-error -std=gnu99 \
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000183 -c -o busybox_unstripped.o \
184 $(lib-all-y:.o=.c)
185
186busybox: busybox_unstripped.o
187 $(srctree)/scripts/trylink \
188 busybox_unstripped \
Denis Vlasenko1da86d22008-06-04 11:28:24 +0000189 "$(CC) $(CFLAGS_busybox)" \
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000190 "$(CFLAGS)" \
191 "$(LDFLAGS)" \
192 "busybox_unstripped.o" \
193 "" \
194 "crypt m"
Bernhard Reutner-Fischer64332bf2007-05-15 09:07:06 +0000195 cp -f $(@)_unstripped $@
196 -$(STRIP) -s -R .note -R .comment -R .version $@
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000197
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000198# If .config is newer than include/autoconf.h, someone tinkered
199# with it and forgot to run make oldconfig.
200include/autoconf.h: .config
201 $(MAKE) -f $(srctree)/Makefile silentoldconfig
202
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100203# Override rules for host compile
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000204applets/usage: include/autoconf.h
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100205 $(HOSTCC) -Wall -O2 -I$(srctree)/include -o applets/usage applets/usage.c
Denis Vlasenko93b82632008-04-11 11:27:29 +0000206
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000207applets/applet_tables: include/autoconf.h
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100208 $(HOSTCC) -Wall -O2 -I$(srctree)/include -o applets/applet_tables applets/applet_tables.c