blob: 1e3005864a66a24df1d484f71cc6ca0e458a9a5d [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)
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000052
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000053# We need some generic definitions
54include $(srctree)/scripts/Kbuild.include
55
56include Makefile.flags
Bernhard Reutner-Fischer2af86042008-05-08 13:25:20 +000057
Bernhard Reutner-Fischer2af86042008-05-08 13:25:20 +000058-include $(srctree)/arch/$(ARCH)/Makefile
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000059ifdef CONFIG_FEATURE_COMPRESS_USAGE
60usage_stuff = include/usage_compressed.h
61endif
62
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000063ifndef BB_VER
64BB_VER:=""
65endif
66
Bernhard Reutner-Fischereecd5882008-04-11 12:42:23 +000067WHOLE_PROGRAM:=$(call cc-option,-fwhole-program,)
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +000068
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000069# pull in the config stuff
Bernhard Reutner-Fischer64332bf2007-05-15 09:07:06 +000070lib-all-y := applets/applets.o
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000071lib-y:=
72include procps/Kbuild
73lib-all-y += $(patsubst %,procps/%,$(sort $(lib-y)))
74lib-y:=
75include networking/Kbuild
76lib-all-y += $(patsubst %,networking/%,$(sort $(lib-y)))
77lib-y:=
78include networking/udhcp/Kbuild
79lib-all-y += $(patsubst %,networking/udhcp/%,$(sort $(lib-y)))
80lib-y:=
81include networking/libiproute/Kbuild
82lib-all-y += $(patsubst %,networking/libiproute/%,$(sort $(lib-y)))
83lib-y:=
84include loginutils/Kbuild
85lib-all-y += $(patsubst %,loginutils/%,$(sort $(lib-y)))
86lib-y:=
87include archival/Kbuild
88lib-all-y += $(patsubst %,archival/%,$(sort $(lib-y)))
89lib-y:=
Denys Vlasenko833d4e72010-11-03 02:38:31 +010090include archival/libarchive/Kbuild
91lib-all-y += $(patsubst %,archival/libarchive/%,$(sort $(lib-y)))
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +000092lib-y:=
93include applets/Kbuild
94lib-all-y += $(patsubst %,applets/%,$(sort $(lib-y)))
95lib-y:=
96include e2fsprogs/Kbuild
97lib-all-y += $(patsubst %,e2fsprogs/%,$(sort $(lib-y)))
98lib-y:=
99#include e2fsprogs/old_e2fsprogs/Kbuild
100#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/%,$(sort $(lib-y)))
101#lib-y:=
102#include e2fsprogs/old_e2fsprogs/ext2fs/Kbuild
103#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/ext2fs/%,$(sort $(lib-y)))
104#lib-y:=
105#include e2fsprogs/old_e2fsprogs/blkid/Kbuild
106#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/blkid/%,$(sort $(lib-y)))
107#lib-y:=
108#include e2fsprogs/old_e2fsprogs/uuid/Kbuild
109#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/uuid/%,$(sort $(lib-y)))
110#lib-y:=
111#include e2fsprogs/old_e2fsprogs/e2p/Kbuild
112#lib-all-y += $(patsubst %,e2fsprogs/old_e2fsprogs/e2p/%,$(sort $(lib-y)))
113#lib-y:=
114include debianutils/Kbuild
115lib-all-y += $(patsubst %,debianutils/%,$(sort $(lib-y)))
116lib-y:=
Denys Vlasenkoab77e812017-08-18 19:15:29 +0200117include klibc-utils/Kbuild
118lib-all-y += $(patsubst %,klibc-utils/%,$(sort $(lib-y)))
119lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000120include runit/Kbuild
121lib-all-y += $(patsubst %,runit/%,$(sort $(lib-y)))
122lib-y:=
123include modutils/Kbuild
124lib-all-y += $(patsubst %,modutils/%,$(sort $(lib-y)))
125lib-y:=
126include miscutils/Kbuild
127lib-all-y += $(patsubst %,miscutils/%,$(sort $(lib-y)))
128lib-y:=
Denys Vlasenko726ebba2011-03-06 23:09:42 +0100129include mailutils/Kbuild
130lib-all-y += $(patsubst %,mailutils/%,$(sort $(lib-y)))
131lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000132include coreutils/libcoreutils/Kbuild
133lib-all-y += $(patsubst %,coreutils/libcoreutils/%,$(sort $(lib-y)))
134lib-y:=
135include coreutils/Kbuild
136lib-all-y += $(patsubst %,coreutils/%,$(sort $(lib-y)))
137lib-y:=
138include sysklogd/Kbuild
139lib-all-y += $(patsubst %,sysklogd/%,$(sort $(lib-y)))
140lib-y:=
141include shell/Kbuild
142lib-all-y += $(patsubst %,shell/%,$(sort $(lib-y)))
143lib-y:=
144include console-tools/Kbuild
145lib-all-y += $(patsubst %,console-tools/%,$(sort $(lib-y)))
146lib-y:=
147include findutils/Kbuild
148lib-all-y += $(patsubst %,findutils/%,$(sort $(lib-y)))
149lib-y:=
150include util-linux/Kbuild
151lib-all-y += $(patsubst %,util-linux/%,$(sort $(lib-y)))
152lib-y:=
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +0000153include util-linux/volume_id/Kbuild
154lib-all-y += $(patsubst %,util-linux/volume_id/%,$(sort $(lib-y)))
155lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000156include init/Kbuild
157lib-all-y += $(patsubst %,init/%,$(sort $(lib-y)))
158lib-y:=
159include libpwdgrp/Kbuild
160lib-all-y += $(patsubst %,libpwdgrp/%,$(sort $(lib-y)))
161lib-y:=
162include editors/Kbuild
163lib-all-y += $(patsubst %,editors/%,$(sort $(lib-y)))
164lib-y:=
Bernhard Reutner-Fischer119f87b2008-04-11 08:46:56 +0000165include printutils/Kbuild
166lib-all-y += $(patsubst %,printutils/%,$(sort $(lib-y)))
167lib-y:=
Bernhard Reutner-Fischere11b4a42007-03-09 08:46:31 +0000168include selinux/Kbuild
169lib-all-y += $(patsubst %,selinux/%,$(sort $(lib-y)))
170lib-y:=
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000171include scripts/Kbuild
172lib-all-y += $(patsubst %,scripts/%,$(sort $(lib-y)))
173lib-y:=
174include libbb/Kbuild
175lib-all-y += $(patsubst %,libbb/%,$(sort $(lib-y)))
176lib-y:=
177
Bernhard Reutner-Fischer1d690db2008-04-11 12:31:57 +0000178comma:=,
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100179busybox_unstripped.o: $(usage_stuff) include/applet_tables.h include/NUM_APPLETS.h include/autoconf.h
Denis Vlasenko93b82632008-04-11 11:27:29 +0000180 $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) \
Bernhard Reutner-Fischer1d690db2008-04-11 12:31:57 +0000181 $(patsubst %,-Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS)) \
Denis Vlasenko93b82632008-04-11 11:27:29 +0000182 -DGCC_COMBINE=1 \
183 --combine $(WHOLE_PROGRAM) \
Bernhard Reutner-Fischer493691a2007-02-02 16:11:24 +0000184 -funit-at-a-time -Wno-error -std=gnu99 \
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000185 -c -o busybox_unstripped.o \
186 $(lib-all-y:.o=.c)
187
188busybox: busybox_unstripped.o
189 $(srctree)/scripts/trylink \
190 busybox_unstripped \
Denis Vlasenko1da86d22008-06-04 11:28:24 +0000191 "$(CC) $(CFLAGS_busybox)" \
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000192 "$(CFLAGS)" \
193 "$(LDFLAGS)" \
194 "busybox_unstripped.o" \
195 "" \
196 "crypt m"
Bernhard Reutner-Fischer64332bf2007-05-15 09:07:06 +0000197 cp -f $(@)_unstripped $@
198 -$(STRIP) -s -R .note -R .comment -R .version $@
Bernhard Reutner-Fischerb5bb40f2007-01-23 01:29:04 +0000199
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000200# If .config is newer than include/autoconf.h, someone tinkered
201# with it and forgot to run make oldconfig.
202include/autoconf.h: .config
203 $(MAKE) -f $(srctree)/Makefile silentoldconfig
204
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100205# Override rules for host compile
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000206applets/usage: include/autoconf.h
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100207 $(HOSTCC) -Wall -O2 -I$(srctree)/include -o applets/usage applets/usage.c
Denis Vlasenko93b82632008-04-11 11:27:29 +0000208
Denis Vlasenko55e06c12008-04-12 13:46:39 +0000209applets/applet_tables: include/autoconf.h
Denys Vlasenkobff5f3f2011-03-06 23:48:24 +0100210 $(HOSTCC) -Wall -O2 -I$(srctree)/include -o applets/applet_tables applets/applet_tables.c