1# ==========================================================================
2# Build system
3# ==========================================================================
4
5busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/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
15install: $(srctree)/applets/install.sh busybox busybox.links
16	$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
17		$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
18ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
19	@echo
20	@echo
21	@echo --------------------------------------------------
22	@echo You will probably need to make your busybox binary
23	@echo setuid root to ensure all configured applets will
24	@echo work properly.
25	@echo --------------------------------------------------
26	@echo
27endif
28
29uninstall: busybox.links
30	rm -f $(CONFIG_PREFIX)/bin/busybox
31	for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
32ifneq ($(strip $(DO_INSTALL_LIBS)),n)
33	for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
34		rm -f $(CONFIG_PREFIX)$$i; \
35	done
36endif
37
38check test: busybox busybox.links
39	bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
40	$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
41
42.PHONY: release
43release: distclean
44	cd ..; \
45	rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
46	cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
47	find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
48		-name .svn \
49		-print \
50		-exec rm -r -f {} \; ; \
51	find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
52		-name .\#* \
53		-print \
54		-exec rm -f {} \; ; \
55	tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
56		busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
57
58.PHONY: checkhelp
59checkhelp:
60	$(Q)$(srctree)/scripts/checkhelp.awk \
61		$(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
62
63.PHONY: sizes
64sizes: busybox_unstripped
65	$(NM) --size-sort $(<)
66
67.PHONY: bloatcheck
68bloatcheck: busybox_old busybox_unstripped
69	@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
70	@$(CROSS_COMPILE)size busybox_old busybox_unstripped
71
72.PHONY: baseline
73baseline: busybox_unstripped
74	@mv busybox_unstripped busybox_old
75
76.PHONY: objsizes
77objsizes: busybox_unstripped
78	$(srctree)/scripts/objsizes
79
80.PHONY: stksizes
81stksizes: busybox_unstripped
82	$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH)
83
84.PHONY: bigdata
85bigdata: busybox_unstripped
86	$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
87
88# Documentation Targets
89.PHONY: doc
90doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
91
92docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
93		$(srctree)/include/usage.h \
94		$(srctree)/docs/busybox_footer.pod \
95		$(srctree)/docs/autodocifier.pl
96	$(disp_doc)
97	$(Q)-mkdir -p docs
98	$(Q)-( cat $(srctree)/docs/busybox_header.pod ; \
99	    $(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \
100	    cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod
101
102docs/BusyBox.txt: docs/busybox.pod
103	$(disp_doc)
104	$(Q)-mkdir -p docs
105	$(Q)-pod2text $< > $@
106
107docs/BusyBox.1: docs/busybox.pod
108	$(disp_doc)
109	$(Q)-mkdir -p docs
110	$(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
111		$< > $@
112
113docs/BusyBox.html: docs/busybox.net/BusyBox.html
114	$(disp_doc)
115	$(Q)-mkdir -p docs
116	$(Q)-rm -f docs/BusyBox.html
117	$(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
118
119docs/busybox.net/BusyBox.html: docs/busybox.pod
120	$(Q)-mkdir -p docs/busybox.net
121	$(Q)-pod2html --noindex $< > \
122	    docs/busybox.net/BusyBox.html
123	$(Q)-rm -f pod2htm*
124
125# documentation, cross-reference
126# Modern distributions already ship synopsis packages (e.g. debian)
127# If you have an old distribution go to http://synopsis.fresco.org/
128syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
129syn     = $(patsubst %.c, %.syn, $(syn_tgt))
130
131comma:= ,
132brace_open:= (
133brace_close:= )
134
135SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
136SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
137SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
138#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
139#")
140#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
141
142%.syn: %.c
143	synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
144
145.PHONY: html
146html: $(syn)
147	synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
148
149-include $(srctree)/Makefile.local
150