Makefile 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. # Makefile for busybox
  2. #
  3. # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #--------------------------------------------------------------
  20. # You shouldn't need to mess with anything beyond this point...
  21. #--------------------------------------------------------------
  22. noconfig_targets := menuconfig config oldconfig randconfig \
  23. defconfig allyesconfig allnoconfig clean distclean \
  24. release tags
  25. ifndef TOPDIR
  26. TOPDIR=$(CURDIR)/
  27. endif
  28. ifndef top_srcdir
  29. top_srcdir=$(CURDIR)
  30. endif
  31. ifndef top_builddir
  32. top_builddir=$(CURDIR)
  33. endif
  34. srctree=$(top_srcdir)
  35. vpath %/Config.in $(srctree)
  36. include $(top_builddir)/Rules.mak
  37. DIRS:=applets archival archival/libunarchive coreutils console-tools \
  38. debianutils editors findutils init miscutils modutils networking \
  39. networking/libiproute networking/udhcp procps loginutils shell \
  40. sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
  41. SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
  42. ifeq ($(strip $(CONFIG_SELINUX)),y)
  43. LIBRARIES += -lselinux
  44. endif
  45. CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in
  46. CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig
  47. ALL_DIRS:= $(DIRS) scripts/config
  48. ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS))
  49. ifeq ($(KBUILD_SRC),)
  50. ifdef O
  51. ifeq ("$(origin O)", "command line")
  52. KBUILD_OUTPUT := $(O)
  53. endif
  54. endif
  55. # That's our default target when none is given on the command line
  56. .PHONY: _all
  57. _all:
  58. ifneq ($(KBUILD_OUTPUT),)
  59. # Invoke a second make in the output directory, passing relevant variables
  60. # check that the output directory actually exists
  61. saved-output := $(KBUILD_OUTPUT)
  62. KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
  63. $(if $(wildcard $(KBUILD_OUTPUT)),, \
  64. $(error output directory "$(saved-output)" does not exist))
  65. .PHONY: $(MAKECMDGOALS)
  66. $(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile
  67. $(MAKE) -C $(KBUILD_OUTPUT) \
  68. top_srcdir=$(CURDIR) \
  69. top_builddir=$(KBUILD_OUTPUT) \
  70. TOPDIR=$(KBUILD_OUTPUT) \
  71. KBUILD_SRC=$(CURDIR) \
  72. -f $(CURDIR)/Makefile $@
  73. $(KBUILD_OUTPUT)/Rules.mak:
  74. @echo > $@
  75. @echo top_srcdir=$(CURDIR) >> $@
  76. @echo top_builddir=$(KBUILD_OUTPUT) >> $@
  77. @echo include $(top_srcdir)/Rules.mak >> $@
  78. $(KBUILD_OUTPUT)/Makefile:
  79. @echo > $@
  80. @echo top_srcdir=$(CURDIR) >> $@
  81. @echo top_builddir=$(KBUILD_OUTPUT) >> $@
  82. @echo KBUILD_SRC='$$(top_srcdir)' >> $@
  83. @echo include '$$(KBUILD_SRC)'/Makefile >> $@
  84. # Leave processing to above invocation of make
  85. skip-makefile := 1
  86. endif # ifneq ($(KBUILD_OUTPUT),)
  87. endif # ifeq ($(KBUILD_SRC),)
  88. ifeq ($(skip-makefile),)
  89. _all: all
  90. ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
  91. all: busybox busybox.links doc
  92. all_tree: $(ALL_MAKEFILES)
  93. $(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
  94. d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
  95. # In this section, we need .config
  96. -include $(top_builddir)/.config.cmd
  97. include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
  98. -include $(top_builddir)/.depend
  99. busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
  100. $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
  101. $(STRIPCMD) $@
  102. busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h
  103. - $(SHELL) $^ >$@
  104. install: $(top_srcdir)/applets/install.sh busybox busybox.links
  105. $(SHELL) $< $(PREFIX)
  106. ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
  107. @echo
  108. @echo
  109. @echo --------------------------------------------------
  110. @echo You will probably need to make your busybox binary
  111. @echo setuid root to ensure all configured applets will
  112. @echo work properly.
  113. @echo --------------------------------------------------
  114. @echo
  115. endif
  116. uninstall: busybox.links
  117. rm -f $(PREFIX)/bin/busybox
  118. for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
  119. install-hardlinks: $(top_srcdir)/applets/install.sh busybox busybox.links
  120. $(SHELL) $< $(PREFIX) --hardlinks
  121. check: busybox
  122. bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
  123. $(top_srcdir)/testsuite/runtest
  124. # Documentation Targets
  125. doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
  126. docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod
  127. -mkdir -p docs
  128. - ( cat $(top_srcdir)/docs/busybox_header.pod; \
  129. $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h; \
  130. cat $(top_srcdir)/docs/busybox_footer.pod ) > docs/busybox.pod
  131. docs/BusyBox.txt: docs/busybox.pod
  132. @echo
  133. @echo BusyBox Documentation
  134. @echo
  135. -mkdir -p docs
  136. -pod2text $< > $@
  137. docs/BusyBox.1: docs/busybox.pod
  138. - mkdir -p docs
  139. - pod2man --center=BusyBox --release="version $(VERSION)" \
  140. $< > $@
  141. docs/BusyBox.html: docs/busybox.net/BusyBox.html
  142. - mkdir -p docs
  143. -@ rm -f docs/BusyBox.html
  144. -@ cp docs/busybox.net/BusyBox.html docs/BusyBox.html
  145. docs/busybox.net/BusyBox.html: docs/busybox.pod
  146. -@ mkdir -p docs/busybox.net
  147. - pod2html --noindex $< > \
  148. docs/busybox.net/BusyBox.html
  149. -@ rm -f pod2htm*
  150. # The nifty new buildsystem stuff
  151. scripts/mkdep: $(top_srcdir)/scripts/mkdep.c
  152. $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
  153. scripts/split-include: $(top_srcdir)/scripts/split-include.c
  154. $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
  155. .depend: scripts/mkdep include/config.h
  156. rm -f .depend .hdepend;
  157. mkdir -p include/config;
  158. scripts/mkdep -I include -- \
  159. `find $(top_srcdir) -name \*.c -print | sed -e "s,^./,,"` >> .depend;
  160. scripts/mkdep -I include -- \
  161. `find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend;
  162. depend dep: .depend
  163. include/config/MARKER: depend scripts/split-include
  164. scripts/split-include include/config.h include/config
  165. @ touch include/config/MARKER
  166. include/config.h: .config
  167. @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
  168. $(MAKE) -C scripts/config conf; \
  169. fi;
  170. @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
  171. finished2:
  172. @echo
  173. @echo Finished installing...
  174. @echo
  175. else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
  176. all: menuconfig
  177. # configuration
  178. # ---------------------------------------------------------------------------
  179. $(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
  180. d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
  181. scripts/config/conf: scripts/config/Makefile Rules.mak
  182. $(MAKE) -C scripts/config conf
  183. -@if [ ! -f .config ] ; then \
  184. cp $(CONFIG_DEFCONFIG) .config; \
  185. fi
  186. scripts/config/mconf: scripts/config/Makefile Rules.mak
  187. $(MAKE) -C scripts/config ncurses conf mconf
  188. -@if [ ! -f .config ] ; then \
  189. cp $(CONFIG_DEFCONFIG) .config; \
  190. fi
  191. menuconfig: scripts/config/mconf
  192. @./scripts/config/mconf $(CONFIG_CONFIG_IN)
  193. config: scripts/config/conf
  194. @./scripts/config/conf $(CONFIG_CONFIG_IN)
  195. oldconfig: scripts/config/conf
  196. @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
  197. randconfig: scripts/config/conf
  198. @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
  199. allyesconfig: scripts/config/conf
  200. @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
  201. sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
  202. sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
  203. sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
  204. sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
  205. @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
  206. allnoconfig: scripts/config/conf
  207. @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
  208. defconfig: scripts/config/conf
  209. @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
  210. clean:
  211. - rm -f docs/busybox.dvi docs/busybox.ps \
  212. docs/busybox.pod docs/busybox.net/busybox.html \
  213. docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
  214. docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
  215. docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
  216. .config.old .hdepend busybox
  217. - rm -rf _install
  218. - find . -name .\*.flags -exec rm -f {} \;
  219. - find . -name \*.o -exec rm -f {} \;
  220. - find . -name \*.a -exec rm -f {} \;
  221. distclean: clean
  222. - rm -f scripts/split-include scripts/mkdep
  223. - rm -rf include/config include/config.h
  224. - find . -name .depend -exec rm -f {} \;
  225. rm -f .config .config.old .config.cmd
  226. - $(MAKE) -C scripts/config clean
  227. release: distclean #doc
  228. cd ..; \
  229. rm -rf $(PROG)-$(VERSION); \
  230. cp -a busybox $(PROG)-$(VERSION); \
  231. \
  232. find $(PROG)-$(VERSION)/ -type d \
  233. -name CVS \
  234. -print \
  235. -exec rm -rf {} \; ; \
  236. \
  237. find $(PROG)-$(VERSION)/ -type f \
  238. -name .\#* \
  239. -print \
  240. -exec rm -f {} \; ; \
  241. \
  242. tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
  243. tags:
  244. ctags -R .
  245. endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
  246. endif # ifeq ($(skip-makefile),)
  247. .PHONY: dummy subdirs release distclean clean config oldconfig \
  248. menuconfig tags check test depend buildtree