blob: 6f679c4e12b4cb7bc139104aa321f035db387261 [file] [log] [blame]
Denis Vlasenkoda8f43f2006-10-09 19:47:38 +00001# ==========================================================================
2# Build system
3# ==========================================================================
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00004
Denys Vlasenko6c5bf0d2010-06-06 00:53:45 +02005busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h
Bernhard Reutner-Fischer90786332013-06-10 17:08:22 +02006 $(Q)-$(SHELL) $^ > $@
7
8busybox.cfg.suid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h
9 $(Q)-SUID="yes" $(SHELL) $^ > $@
10busybox.cfg.nosuid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h
11 $(Q)-SUID="DROP" $(SHELL) $^ > $@
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000012
13.PHONY: install
Yann E. MORIN296381f2018-04-15 10:55:30 +020014ifeq ($(CONFIG_INSTALL_APPLET_DONT),y)
15INSTALL_OPTS:= --none
16endif
Bernhard Reutner-Fischer8bfd2152006-11-17 13:54:29 +000017ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
18INSTALL_OPTS:= --symlinks
19endif
20ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
21INSTALL_OPTS:= --hardlinks
22endif
Denis Vlasenko737d1312007-08-25 18:25:24 +000023ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y)
24ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y)
25INSTALL_OPTS:= --sw-sh-sym
26endif
27ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y)
28INSTALL_OPTS:= --sw-sh-hard
29endif
30ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
31INSTALL_OPTS:= --scriptwrapper
32endif
33endif
Clayton Shotwellb7ee7e12015-05-21 14:48:35 -050034ifeq ($(CONFIG_FEATURE_INDIVIDUAL),y)
35INSTALL_OPTS:= --binaries
36LIBBUSYBOX_SONAME:= 0_lib/libbusybox.so.$(BB_VER)
37endif
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000038install: $(srctree)/applets/install.sh busybox busybox.links
39 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
40 $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
41ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
42 @echo
43 @echo
44 @echo --------------------------------------------------
45 @echo You will probably need to make your busybox binary
46 @echo setuid root to ensure all configured applets will
47 @echo work properly.
48 @echo --------------------------------------------------
49 @echo
50endif
51
Yann E. MORINa47375d2017-12-28 23:49:49 +010052install-noclobber: INSTALL_OPTS+=--noclobber
53install-noclobber: install
54
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000055uninstall: busybox.links
56 rm -f $(CONFIG_PREFIX)/bin/busybox
57 for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
58ifneq ($(strip $(DO_INSTALL_LIBS)),n)
59 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
60 rm -f $(CONFIG_PREFIX)$$i; \
61 done
62endif
63
Denis Vlasenkob75a1c32008-04-10 19:59:20 +000064# Not very elegant: copies testsuite to objdir...
Denis Vlasenko80f647c2008-04-11 10:54:37 +000065# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
Denis Vlasenkob75a1c32008-04-10 19:59:20 +000066.PHONY: check
67.PHONY: test
Bartosz Golaszewski3ed81cf2014-06-22 16:30:41 +020068ifeq ($(CONFIG_UNIT_TEST),y)
69UNIT_CMD = ./busybox unit
70endif
Bernhard Reutner-Fischeraae82e02007-01-27 22:04:58 +000071check test: busybox busybox.links
Bartosz Golaszewski3ed81cf2014-06-22 16:30:41 +020072 $(UNIT_CMD)
Denis Vlasenko80f647c2008-04-11 10:54:37 +000073 test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
Denis Vlasenkob75a1c32008-04-10 19:59:20 +000074 bindir=$(objtree) srcdir=$(srctree)/testsuite \
75 $(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000076
Denis Vlasenko5fa71482006-12-12 22:31:15 +000077.PHONY: release
78release: distclean
79 cd ..; \
80 rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
Denis Vlasenko80f647c2008-04-11 10:54:37 +000081 cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000082 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
83 -name .svn \
84 -print \
Denis Vlasenko5e2db5e2006-12-12 23:46:31 +000085 -exec rm -r -f {} \; ; \
Denys Vlasenko603884b2010-03-28 20:26:40 +020086 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
87 -name .git \
88 -print \
89 -exec rm -r -f {} \; ; \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000090 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
Denys Vlasenko17f4aca2013-11-02 22:06:36 +010091 -name .gitignore \
92 -print \
93 -exec rm -f {} \; ; \
94 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000095 -name .\#* \
96 -print \
Denis Vlasenko5e2db5e2006-12-12 23:46:31 +000097 -exec rm -f {} \; ; \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000098 tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
Denis Vlasenko5e2db5e2006-12-12 23:46:31 +000099 busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
Denis Vlasenko5fa71482006-12-12 22:31:15 +0000100
Bernhard Reutner-Fischerd6bbf992006-11-22 09:39:48 +0000101.PHONY: checkhelp
102checkhelp:
103 $(Q)$(srctree)/scripts/checkhelp.awk \
104 $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000105
106.PHONY: sizes
107sizes: busybox_unstripped
108 $(NM) --size-sort $(<)
109
110.PHONY: bloatcheck
111bloatcheck: busybox_old busybox_unstripped
112 @$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
Denis Vlasenko931de892007-06-21 12:43:45 +0000113 @$(CROSS_COMPILE)size busybox_old busybox_unstripped
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000114
115.PHONY: baseline
116baseline: busybox_unstripped
117 @mv busybox_unstripped busybox_old
118
119.PHONY: objsizes
120objsizes: busybox_unstripped
Denis Vlasenko18684092006-10-05 17:11:08 +0000121 $(srctree)/scripts/objsizes
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000122
Denis Vlasenkod4fea902007-06-10 00:54:27 +0000123.PHONY: stksizes
124stksizes: busybox_unstripped
Denis Vlasenkoab801872007-12-02 08:35:37 +0000125 $(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
Denis Vlasenkod4fea902007-06-10 00:54:27 +0000126
Denis Vlasenko00252642006-11-30 20:41:28 +0000127.PHONY: bigdata
128bigdata: busybox_unstripped
Denis Vlasenkoeaad9102008-05-20 06:31:56 +0000129 $(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
Denis Vlasenko00252642006-11-30 20:41:28 +0000130
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000131# Documentation Targets
132.PHONY: doc
Denys Vlasenko57b68332010-10-24 02:09:32 +0200133doc: docs/busybox.pod docs/BusyBox.txt docs/busybox.1 docs/BusyBox.html
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000134
Bernhard Reutner-Fischera28a05b2008-08-21 21:15:28 +0000135# FIXME: Doesn't belong here
Mike Frysinger5f9f1502009-03-30 05:26:34 +0000136 cmd_doc =
137 quiet_cmd_doc = $(Q)echo " DOC $(@F)"
138silent_cmd_doc =
139disp_doc = $($(quiet)cmd_doc)
Bernhard Reutner-Fischera28a05b2008-08-21 21:15:28 +0000140
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200141# sed adds newlines after "Options:" etc,
142# this is needed in order to get good BusyBox.{1,txt,html}
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000143docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
Denys Vlasenkof0f94702010-06-06 01:53:38 +0200144 include/usage.h \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000145 $(srctree)/docs/busybox_footer.pod \
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200146 applets/usage_pod
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000147 $(disp_doc)
148 $(Q)-mkdir -p docs
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200149 $(Q)-( \
150 cat $(srctree)/docs/busybox_header.pod; \
Bernhard Reutner-Fischer64b6f7c2010-07-29 09:34:04 +0200151 echo; \
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200152 applets/usage_pod | sed 's/^[A-Za-z][A-Za-z ]*[a-z]:$$/&\n/'; \
153 cat $(srctree)/docs/busybox_footer.pod; \
154 ) > docs/busybox.pod
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000155
156docs/BusyBox.txt: docs/busybox.pod
157 $(disp_doc)
158 $(Q)-mkdir -p docs
159 $(Q)-pod2text $< > $@
160
Denys Vlasenko57b68332010-10-24 02:09:32 +0200161docs/busybox.1: docs/busybox.pod
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000162 $(disp_doc)
163 $(Q)-mkdir -p docs
Denys Vlasenko57b68332010-10-24 02:09:32 +0200164 $(Q)-pod2man --center=busybox --release="version $(KERNELVERSION)" $< > $@
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000165
166docs/BusyBox.html: docs/busybox.net/BusyBox.html
167 $(disp_doc)
168 $(Q)-mkdir -p docs
169 $(Q)-rm -f docs/BusyBox.html
170 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
171
172docs/busybox.net/BusyBox.html: docs/busybox.pod
173 $(Q)-mkdir -p docs/busybox.net
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200174 $(Q)-pod2html --noindex $< > $@
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000175 $(Q)-rm -f pod2htm*
176
177# documentation, cross-reference
178# Modern distributions already ship synopsis packages (e.g. debian)
179# If you have an old distribution go to http://synopsis.fresco.org/
Bernhard Reutner-Fischerbc95f572006-12-06 15:29:00 +0000180syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
181syn = $(patsubst %.c, %.syn, $(syn_tgt))
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000182
Bernhard Reutner-Fischerfeea1b92006-12-06 21:51:59 +0000183comma:= ,
184brace_open:= (
185brace_close:= )
186
187SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
188SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
189SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
190#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
191#")
192#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
193
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000194%.syn: %.c
Bernhard Reutner-Fischerfeea1b92006-12-06 21:51:59 +0000195 synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000196
197.PHONY: html
198html: $(syn)
199 synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
Mike Frysinger3c82e482007-05-02 22:07:03 +0000200
201-include $(srctree)/Makefile.local