f8a12831d58370e7195cf311d6dbc0eead7b7858
[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 install: $(srctree)/applets/install.sh busybox busybox.links
32         $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
33                 $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
34 ifeq ($(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
43 endif
44
45 uninstall: busybox.links
46         rm -f $(CONFIG_PREFIX)/bin/busybox
47         for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
48 ifneq ($(strip $(DO_INSTALL_LIBS)),n)
49         for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
50                 rm -f $(CONFIG_PREFIX)$$i; \
51         done
52 endif
53
54 # Not very elegant: copies testsuite to objdir...
55 # (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
56 .PHONY: check
57 .PHONY: test
58 ifeq ($(CONFIG_UNIT_TEST),y)
59 UNIT_CMD = ./busybox unit
60 endif
61 check test: busybox busybox.links
62         $(UNIT_CMD)
63         test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
64         bindir=$(objtree) srcdir=$(srctree)/testsuite \
65         $(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
66
67 .PHONY: release
68 release: distclean
69         cd ..; \
70         rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
71         cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
72         find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
73                 -name .svn \
74                 -print \
75                 -exec rm -r -f {} \; ; \
76         find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
77                 -name .git \
78                 -print \
79                 -exec rm -r -f {} \; ; \
80         find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
81                 -name .gitignore \
82                 -print \
83                 -exec rm -f {} \; ; \
84         find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
85                 -name .\#* \
86                 -print \
87                 -exec rm -f {} \; ; \
88         tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
89                 busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
90
91 .PHONY: checkhelp
92 checkhelp:
93         $(Q)$(srctree)/scripts/checkhelp.awk \
94                 $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
95
96 .PHONY: sizes
97 sizes: busybox_unstripped
98         $(NM) --size-sort $(<)
99
100 .PHONY: bloatcheck
101 bloatcheck: busybox_old busybox_unstripped
102         @$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
103         @$(CROSS_COMPILE)size busybox_old busybox_unstripped
104
105 .PHONY: baseline
106 baseline: busybox_unstripped
107         @mv busybox_unstripped busybox_old
108
109 .PHONY: objsizes
110 objsizes: busybox_unstripped
111         $(srctree)/scripts/objsizes
112
113 .PHONY: stksizes
114 stksizes: busybox_unstripped
115         $(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
116
117 .PHONY: bigdata
118 bigdata: busybox_unstripped
119         $(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
120
121 # Documentation Targets
122 .PHONY: doc
123 doc: docs/busybox.pod docs/BusyBox.txt docs/busybox.1 docs/BusyBox.html
124
125 # FIXME: Doesn't belong here
126        cmd_doc =
127  quiet_cmd_doc = $(Q)echo "  DOC     $(@F)"
128 silent_cmd_doc =
129 disp_doc       = $($(quiet)cmd_doc)
130
131 # sed adds newlines after "Options:" etc,
132 # this is needed in order to get good BusyBox.{1,txt,html}
133 docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
134                 include/usage.h \
135                 $(srctree)/docs/busybox_footer.pod \
136                 applets/usage_pod
137         $(disp_doc)
138         $(Q)-mkdir -p docs
139         $(Q)-( \
140             cat $(srctree)/docs/busybox_header.pod; \
141             echo; \
142             applets/usage_pod | sed 's/^[A-Za-z][A-Za-z ]*[a-z]:$$/&\n/'; \
143             cat $(srctree)/docs/busybox_footer.pod; \
144             ) > docs/busybox.pod
145
146 docs/BusyBox.txt: docs/busybox.pod
147         $(disp_doc)
148         $(Q)-mkdir -p docs
149         $(Q)-pod2text $< > $@
150
151 docs/busybox.1: docs/busybox.pod
152         $(disp_doc)
153         $(Q)-mkdir -p docs
154         $(Q)-pod2man --center=busybox --release="version $(KERNELVERSION)" $< > $@
155
156 docs/BusyBox.html: docs/busybox.net/BusyBox.html
157         $(disp_doc)
158         $(Q)-mkdir -p docs
159         $(Q)-rm -f docs/BusyBox.html
160         $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
161
162 docs/busybox.net/BusyBox.html: docs/busybox.pod
163         $(Q)-mkdir -p docs/busybox.net
164         $(Q)-pod2html --noindex $< > $@
165         $(Q)-rm -f pod2htm*
166
167 # documentation, cross-reference
168 # Modern distributions already ship synopsis packages (e.g. debian)
169 # If you have an old distribution go to http://synopsis.fresco.org/
170 syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
171 syn     = $(patsubst %.c, %.syn, $(syn_tgt))
172
173 comma:= ,
174 brace_open:= (
175 brace_close:= )
176
177 SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
178 SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
179 SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
180 #SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
181 #")
182 #SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
183
184 %.syn: %.c
185         synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
186
187 .PHONY: html
188 html: $(syn)
189         synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
190
191 -include $(srctree)/Makefile.local