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