lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 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 | .PHONY: install |
| 9 | ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y) |
| 10 | INSTALL_OPTS:= --symlinks |
| 11 | endif |
| 12 | ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y) |
| 13 | INSTALL_OPTS:= --hardlinks |
| 14 | endif |
| 15 | ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y) |
| 16 | ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y) |
| 17 | INSTALL_OPTS:= --sw-sh-sym |
| 18 | endif |
| 19 | ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y) |
| 20 | INSTALL_OPTS:= --sw-sh-hard |
| 21 | endif |
| 22 | ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y) |
| 23 | INSTALL_OPTS:= --scriptwrapper |
| 24 | endif |
| 25 | endif |
| 26 | install: $(srctree)/applets/install.sh busybox busybox.links |
| 27 | $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \ |
| 28 | $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS) |
| 29 | ifeq ($(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 |
| 38 | endif |
| 39 | |
| 40 | uninstall: busybox.links |
| 41 | rm -f $(CONFIG_PREFIX)/bin/busybox |
| 42 | for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done |
| 43 | ifneq ($(strip $(DO_INSTALL_LIBS)),n) |
| 44 | for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \ |
| 45 | rm -f $(CONFIG_PREFIX)$$i; \ |
| 46 | done |
| 47 | endif |
| 48 | |
| 49 | INSTALLER=install-romfs.sh |
| 50 | ifdef CONFIG_UCLINUX |
| 51 | TARGETDIR=$(ROMFSDIR)/bin/ --nosubdir |
| 52 | else |
| 53 | TARGETDIR=$(ROMFSDIR)/ |
| 54 | endif |
| 55 | |
| 56 | # Before copying, remove all existing busybox links |
| 57 | romfs: $(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 |
| 71 | check 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 |
| 77 | release: 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 |
| 97 | checkhelp: |
| 98 | $(Q)$(srctree)/scripts/checkhelp.awk \ |
| 99 | $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./))) |
| 100 | |
| 101 | .PHONY: sizes |
| 102 | sizes: busybox_unstripped |
| 103 | $(NM) --size-sort $(<) |
| 104 | |
| 105 | .PHONY: bloatcheck |
| 106 | bloatcheck: 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 |
| 111 | baseline: busybox_unstripped |
| 112 | @mv busybox_unstripped busybox_old |
| 113 | |
| 114 | .PHONY: objsizes |
| 115 | objsizes: busybox_unstripped |
| 116 | $(srctree)/scripts/objsizes |
| 117 | |
| 118 | .PHONY: stksizes |
| 119 | stksizes: busybox_unstripped |
| 120 | $(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq |
| 121 | |
| 122 | .PHONY: bigdata |
| 123 | bigdata: busybox_unstripped |
| 124 | $(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] ' |
| 125 | |
| 126 | # Documentation Targets |
| 127 | .PHONY: doc |
| 128 | doc: 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)" |
| 133 | silent_cmd_doc = |
| 134 | disp_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} |
| 138 | docs/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 | |
| 151 | docs/BusyBox.txt: docs/busybox.pod |
| 152 | $(disp_doc) |
| 153 | $(Q)-mkdir -p docs |
| 154 | $(Q)-pod2text $< > $@ |
| 155 | |
| 156 | docs/busybox.1: docs/busybox.pod |
| 157 | $(disp_doc) |
| 158 | $(Q)-mkdir -p docs |
| 159 | $(Q)-pod2man --center=busybox --release="version $(KERNELVERSION)" $< > $@ |
| 160 | |
| 161 | docs/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 | |
| 167 | docs/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/ |
| 175 | syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs))) |
| 176 | syn = $(patsubst %.c, %.syn, $(syn_tgt)) |
| 177 | |
| 178 | comma:= , |
| 179 | brace_open:= ( |
| 180 | brace_close:= ) |
| 181 | |
| 182 | SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS)) |
| 183 | SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS)) |
| 184 | SYN_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 |
| 193 | html: $(syn) |
| 194 | synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^ |
| 195 | |
| 196 | -include $(srctree)/Makefile.local |