blob: 3561e57687ca32bf9d6019db4c273d8f950bf3be [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
Bernhard Reutner-Fischer8bfd2152006-11-17 13:54:29 +000014ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
15INSTALL_OPTS:= --symlinks
16endif
17ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
18INSTALL_OPTS:= --hardlinks
19endif
Denis Vlasenko737d1312007-08-25 18:25:24 +000020ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y)
21ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y)
22INSTALL_OPTS:= --sw-sh-sym
23endif
24ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y)
25INSTALL_OPTS:= --sw-sh-hard
26endif
27ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
28INSTALL_OPTS:= --scriptwrapper
29endif
30endif
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000031install: $(srctree)/applets/install.sh busybox busybox.links
32 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
33 $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
34ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
35 @echo
36 @echo
37 @echo --------------------------------------------------
38 @echo You will probably need to make your busybox binary
39 @echo setuid root to ensure all configured applets will
40 @echo work properly.
41 @echo --------------------------------------------------
42 @echo
43endif
44
45uninstall: busybox.links
46 rm -f $(CONFIG_PREFIX)/bin/busybox
47 for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
48ifneq ($(strip $(DO_INSTALL_LIBS)),n)
49 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
50 rm -f $(CONFIG_PREFIX)$$i; \
51 done
52endif
53
Denis Vlasenkob75a1c32008-04-10 19:59:20 +000054# Not very elegant: copies testsuite to objdir...
Denis Vlasenko80f647c2008-04-11 10:54:37 +000055# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
Denis Vlasenkob75a1c32008-04-10 19:59:20 +000056.PHONY: check
57.PHONY: test
Bernhard Reutner-Fischeraae82e02007-01-27 22:04:58 +000058check test: busybox busybox.links
Denis Vlasenko80f647c2008-04-11 10:54:37 +000059 test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
Denis Vlasenkob75a1c32008-04-10 19:59:20 +000060 bindir=$(objtree) srcdir=$(srctree)/testsuite \
61 $(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000062
Denis Vlasenko5fa71482006-12-12 22:31:15 +000063.PHONY: release
64release: distclean
65 cd ..; \
66 rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
Denis Vlasenko80f647c2008-04-11 10:54:37 +000067 cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000068 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
69 -name .svn \
70 -print \
Denis Vlasenko5e2db5e2006-12-12 23:46:31 +000071 -exec rm -r -f {} \; ; \
Denys Vlasenko603884b2010-03-28 20:26:40 +020072 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
73 -name .git \
74 -print \
75 -exec rm -r -f {} \; ; \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000076 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
77 -name .\#* \
78 -print \
Denis Vlasenko5e2db5e2006-12-12 23:46:31 +000079 -exec rm -f {} \; ; \
Denis Vlasenko5fa71482006-12-12 22:31:15 +000080 tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
Denis Vlasenko5e2db5e2006-12-12 23:46:31 +000081 busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
Denis Vlasenko5fa71482006-12-12 22:31:15 +000082
Bernhard Reutner-Fischerd6bbf992006-11-22 09:39:48 +000083.PHONY: checkhelp
84checkhelp:
85 $(Q)$(srctree)/scripts/checkhelp.awk \
86 $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000087
88.PHONY: sizes
89sizes: busybox_unstripped
90 $(NM) --size-sort $(<)
91
92.PHONY: bloatcheck
93bloatcheck: busybox_old busybox_unstripped
94 @$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
Denis Vlasenko931de892007-06-21 12:43:45 +000095 @$(CROSS_COMPILE)size busybox_old busybox_unstripped
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000096
97.PHONY: baseline
98baseline: busybox_unstripped
99 @mv busybox_unstripped busybox_old
100
101.PHONY: objsizes
102objsizes: busybox_unstripped
Denis Vlasenko18684092006-10-05 17:11:08 +0000103 $(srctree)/scripts/objsizes
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000104
Denis Vlasenkod4fea902007-06-10 00:54:27 +0000105.PHONY: stksizes
106stksizes: busybox_unstripped
Denis Vlasenkoab801872007-12-02 08:35:37 +0000107 $(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
Denis Vlasenkod4fea902007-06-10 00:54:27 +0000108
Denis Vlasenko00252642006-11-30 20:41:28 +0000109.PHONY: bigdata
110bigdata: busybox_unstripped
Denis Vlasenkoeaad9102008-05-20 06:31:56 +0000111 $(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
Denis Vlasenko00252642006-11-30 20:41:28 +0000112
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000113# Documentation Targets
114.PHONY: doc
Denys Vlasenko57b68332010-10-24 02:09:32 +0200115doc: docs/busybox.pod docs/BusyBox.txt docs/busybox.1 docs/BusyBox.html
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000116
Bernhard Reutner-Fischera28a05b2008-08-21 21:15:28 +0000117# FIXME: Doesn't belong here
Mike Frysinger5f9f1502009-03-30 05:26:34 +0000118 cmd_doc =
119 quiet_cmd_doc = $(Q)echo " DOC $(@F)"
120silent_cmd_doc =
121disp_doc = $($(quiet)cmd_doc)
Bernhard Reutner-Fischera28a05b2008-08-21 21:15:28 +0000122
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200123# sed adds newlines after "Options:" etc,
124# this is needed in order to get good BusyBox.{1,txt,html}
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000125docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
Denys Vlasenkof0f94702010-06-06 01:53:38 +0200126 include/usage.h \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000127 $(srctree)/docs/busybox_footer.pod \
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200128 applets/usage_pod
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000129 $(disp_doc)
130 $(Q)-mkdir -p docs
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200131 $(Q)-( \
132 cat $(srctree)/docs/busybox_header.pod; \
Bernhard Reutner-Fischer64b6f7c2010-07-29 09:34:04 +0200133 echo; \
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200134 applets/usage_pod | sed 's/^[A-Za-z][A-Za-z ]*[a-z]:$$/&\n/'; \
135 cat $(srctree)/docs/busybox_footer.pod; \
136 ) > docs/busybox.pod
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000137
138docs/BusyBox.txt: docs/busybox.pod
139 $(disp_doc)
140 $(Q)-mkdir -p docs
141 $(Q)-pod2text $< > $@
142
Denys Vlasenko57b68332010-10-24 02:09:32 +0200143docs/busybox.1: docs/busybox.pod
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000144 $(disp_doc)
145 $(Q)-mkdir -p docs
Denys Vlasenko57b68332010-10-24 02:09:32 +0200146 $(Q)-pod2man --center=busybox --release="version $(KERNELVERSION)" $< > $@
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000147
148docs/BusyBox.html: docs/busybox.net/BusyBox.html
149 $(disp_doc)
150 $(Q)-mkdir -p docs
151 $(Q)-rm -f docs/BusyBox.html
152 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
153
154docs/busybox.net/BusyBox.html: docs/busybox.pod
155 $(Q)-mkdir -p docs/busybox.net
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +0200156 $(Q)-pod2html --noindex $< > $@
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000157 $(Q)-rm -f pod2htm*
158
159# documentation, cross-reference
160# Modern distributions already ship synopsis packages (e.g. debian)
161# If you have an old distribution go to http://synopsis.fresco.org/
Bernhard Reutner-Fischerbc95f572006-12-06 15:29:00 +0000162syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
163syn = $(patsubst %.c, %.syn, $(syn_tgt))
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000164
Bernhard Reutner-Fischerfeea1b92006-12-06 21:51:59 +0000165comma:= ,
166brace_open:= (
167brace_close:= )
168
169SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
170SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
171SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
172#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
173#")
174#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
175
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000176%.syn: %.c
Bernhard Reutner-Fischerfeea1b92006-12-06 21:51:59 +0000177 synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000178
179.PHONY: html
180html: $(syn)
181 synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
Mike Frysinger3c82e482007-05-02 22:07:03 +0000182
183-include $(srctree)/Makefile.local