blob: 03247002ef262e7c5e72be9bc3cb15c4ad2349d9 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# ==========================================================================
2# Build system
3# ==========================================================================
4
5busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h
6 $(Q)-$(SHELL) $^ >$@
7
8.PHONY: install
9ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
10INSTALL_OPTS:= --symlinks
11endif
12ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
13INSTALL_OPTS:= --hardlinks
14endif
15ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y)
16ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y)
17INSTALL_OPTS:= --sw-sh-sym
18endif
19ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y)
20INSTALL_OPTS:= --sw-sh-hard
21endif
22ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
23INSTALL_OPTS:= --scriptwrapper
24endif
25endif
26install: $(srctree)/applets/install.sh busybox busybox.links
27 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
28 $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
29ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
30 @echo
31 @echo
32 @echo --------------------------------------------------
33 @echo You will probably need to make your busybox binary
34 @echo setuid root to ensure all configured applets will
35 @echo work properly.
36 @echo --------------------------------------------------
37 @echo
38endif
39
40uninstall: busybox.links
41 rm -f $(CONFIG_PREFIX)/bin/busybox
42 for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
43ifneq ($(strip $(DO_INSTALL_LIBS)),n)
44 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
45 rm -f $(CONFIG_PREFIX)$$i; \
46 done
47endif
48
49INSTALLER=install-romfs.sh
50ifdef CONFIG_UCLINUX
51TARGETDIR=$(ROMFSDIR)/bin/ --nosubdir
52else
53TARGETDIR=$(ROMFSDIR)/
54endif
55
56# Before copying, remove all existing busybox links
57romfs: $(INSTALLER) busybox.links
58 mkdir -p $$ROMFSDIR/bin $$ROMFSDIR/etc
59 if [ -f "$$ROMFSDIR/bin/busybox" ]; then \
60 inode=`ls -i $$ROMFSDIR/bin/busybox | awk '{print $$1}'`; \
61 ls -iL "$$ROMFSDIR/bin" | grep "^ *$$inode" | awk '{print $$2}' | \
62 sed "s:^:$$ROMFSDIR/bin/:" | env -i xargs rm -f; \
63 fi
64 $(ROMFSINST) /bin/busybox
65 $(SHELL) $< $(TARGETDIR)
66
67# Not very elegant: copies testsuite to objdir...
68# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
69.PHONY: check
70.PHONY: test
71check test: busybox busybox.links
72 test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
73 bindir=$(objtree) srcdir=$(srctree)/testsuite \
74 $(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
75
76.PHONY: release
77release: distclean
78 cd ..; \
79 rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
80 cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
81 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
82 -name .svn \
83 -print \
84 -exec rm -r -f {} \; ; \
85 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
86 -name .git \
87 -print \
88 -exec rm -r -f {} \; ; \
89 find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
90 -name .\#* \
91 -print \
92 -exec rm -f {} \; ; \
93 tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
94 busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
95
96.PHONY: checkhelp
97checkhelp:
98 $(Q)$(srctree)/scripts/checkhelp.awk \
99 $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
100
101.PHONY: sizes
102sizes: busybox_unstripped
103 $(NM) --size-sort $(<)
104
105.PHONY: bloatcheck
106bloatcheck: busybox_old busybox_unstripped
107 @$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
108 @$(CROSS_COMPILE)size busybox_old busybox_unstripped
109
110.PHONY: baseline
111baseline: busybox_unstripped
112 @mv busybox_unstripped busybox_old
113
114.PHONY: objsizes
115objsizes: busybox_unstripped
116 $(srctree)/scripts/objsizes
117
118.PHONY: stksizes
119stksizes: busybox_unstripped
120 $(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
121
122.PHONY: bigdata
123bigdata: busybox_unstripped
124 $(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
125
126# Documentation Targets
127.PHONY: doc
128doc: docs/busybox.pod docs/BusyBox.txt docs/busybox.1 docs/BusyBox.html
129
130# FIXME: Doesn't belong here
131 cmd_doc =
132 quiet_cmd_doc = $(Q)echo " DOC $(@F)"
133silent_cmd_doc =
134disp_doc = $($(quiet)cmd_doc)
135
136# sed adds newlines after "Options:" etc,
137# this is needed in order to get good BusyBox.{1,txt,html}
138docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
139 include/usage.h \
140 $(srctree)/docs/busybox_footer.pod \
141 applets/usage_pod
142 $(disp_doc)
143 $(Q)-mkdir -p docs
144 $(Q)-( \
145 cat $(srctree)/docs/busybox_header.pod; \
146 echo; \
147 applets/usage_pod | sed 's/^[A-Za-z][A-Za-z ]*[a-z]:$$/&\n/'; \
148 cat $(srctree)/docs/busybox_footer.pod; \
149 ) > docs/busybox.pod
150
151docs/BusyBox.txt: docs/busybox.pod
152 $(disp_doc)
153 $(Q)-mkdir -p docs
154 $(Q)-pod2text $< > $@
155
156docs/busybox.1: docs/busybox.pod
157 $(disp_doc)
158 $(Q)-mkdir -p docs
159 $(Q)-pod2man --center=busybox --release="version $(KERNELVERSION)" $< > $@
160
161docs/BusyBox.html: docs/busybox.net/BusyBox.html
162 $(disp_doc)
163 $(Q)-mkdir -p docs
164 $(Q)-rm -f docs/BusyBox.html
165 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
166
167docs/busybox.net/BusyBox.html: docs/busybox.pod
168 $(Q)-mkdir -p docs/busybox.net
169 $(Q)-pod2html --noindex $< > $@
170 $(Q)-rm -f pod2htm*
171
172# documentation, cross-reference
173# Modern distributions already ship synopsis packages (e.g. debian)
174# If you have an old distribution go to http://synopsis.fresco.org/
175syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
176syn = $(patsubst %.c, %.syn, $(syn_tgt))
177
178comma:= ,
179brace_open:= (
180brace_close:= )
181
182SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
183SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
184SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
185#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
186#")
187#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
188
189%.syn: %.c
190 synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
191
192.PHONY: html
193html: $(syn)
194 synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
195
196-include $(srctree)/Makefile.local