Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. # Makefile for OpenWrt
  2. #
  3. # Copyright (C) 2006 OpenWrt.org
  4. # Copyright (C) 2006 by Felix Fietkau <[email protected]>
  5. #
  6. # This is free software, licensed under the GNU General Public License v2.
  7. # See /LICENSE for more information.
  8. #
  9. RELEASE:=Kamikaze
  10. #VERSION:=2.0 # uncomment for final release
  11. #--------------------------------------------------------------
  12. # Just run 'make menuconfig', configure stuff, then run 'make'.
  13. # You shouldn't need to mess with anything beyond this point...
  14. #--------------------------------------------------------------
  15. all: world
  16. SHELL:=/usr/bin/env bash
  17. export LC_ALL=C
  18. export LANG=C
  19. export TOPDIR=${CURDIR}
  20. ifeq ($(KBUILD_VERBOSE),99)
  21. MAKE:=3>/dev/null $(MAKE)
  22. endif
  23. export IS_TTY=$(shell tty -s && echo 1 || echo 0)
  24. include $(TOPDIR)/include/verbose.mk
  25. OPENWRTVERSION:=$(RELEASE)
  26. ifneq ($(VERSION),)
  27. OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
  28. else
  29. REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
  30. ifneq ($(REV),)
  31. OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
  32. endif
  33. endif
  34. export OPENWRTVERSION
  35. ifneq ($(shell ./scripts/timestamp.pl -p tmp/.pkginfo package scripts include),tmp/.pkginfo)
  36. tmp/.pkginfo: FORCE
  37. endif
  38. ifneq ($(shell ./scripts/timestamp.pl -p tmp/.targetinfo target/linux scripts include),tmp/.targetinfo)
  39. tmp/.targetinfo: FORCE
  40. endif
  41. ifeq ($(FORCE),)
  42. .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
  43. world: tmp/.prereq-packages tmp/.prereq-target
  44. endif
  45. ifeq ($(IS_TTY),1)
  46. define progress
  47. printf "\033[M\r$(1)" >&2;
  48. endef
  49. endif
  50. define dumpinfo
  51. @mkdir -p tmp
  52. @echo -n Collecting $(2) info...
  53. @-for dir in $(1)/*/; do \
  54. [ -f "$${dir}/Makefile" ] || continue; \
  55. $(call progress,Collecting $(2) info: $${dir%%/}) \
  56. echo Source-Makefile: $${dir}Makefile; \
  57. $(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir 3>/dev/null || echo "ERROR: please fix $${dir}Makefile" >&2; \
  58. echo; \
  59. done > $@
  60. @($(call progress,Collecting $(2) info: done))
  61. @echo
  62. endef
  63. tmp/.pkginfo:
  64. $(call dumpinfo,package,package)
  65. tmp/.targetinfo:
  66. $(call dumpinfo,target/linux,target)
  67. tmpinfo-clean: FORCE
  68. @-rm -rf tmp/.pkginfo tmp/.targetinfo
  69. tmp/.config.in: tmp/.pkginfo
  70. @./scripts/gen_package_config.pl < $< > $@ || rm -f $@
  71. tmp/.config-target.in: tmp/.targetinfo
  72. @./scripts/gen_target_config.pl < $< > $@ || rm -f $@
  73. .config: ./scripts/config/conf tmp/.config.in tmp/.config-target.in
  74. @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
  75. @$< -D .config Config.in &> /dev/null
  76. scripts/config/mconf:
  77. @$(MAKE) -C scripts/config all
  78. scripts/config/conf:
  79. @$(MAKE) -C scripts/config conf
  80. config: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
  81. $< Config.in
  82. config-clean: FORCE
  83. $(NO_TRACE_MAKE) -C scripts/config clean
  84. defconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
  85. touch .config
  86. $< -D .config Config.in
  87. oldconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
  88. $< -o Config.in
  89. menuconfig: scripts/config/mconf tmp/.config.in tmp/.config-target.in FORCE
  90. $< Config.in
  91. package/%: tmp/.pkginfo tmp/.targetinfo FORCE
  92. $(MAKE) -C package $(patsubst package/%,%,$@)
  93. target/%: tmp/.pkginfo tmp/.targetinfo FORCE
  94. $(MAKE) -C target $(patsubst target/%,%,$@)
  95. tools/%: FORCE
  96. $(MAKE) -C tools $(patsubst tools/%,%,$@)
  97. toolchain/%: tmp/.targetinfo FORCE
  98. $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
  99. tmp/.prereq-build: include/prereq-build.mk
  100. @mkdir -p tmp
  101. @rm -f tmp/.host.mk
  102. @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  103. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  104. false; \
  105. }
  106. @touch $@
  107. tmp/.prereq-packages: include/prereq.mk tmp/.pkginfo .config
  108. @mkdir -p tmp
  109. @rm -f tmp/.host.mk
  110. @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
  111. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  112. false; \
  113. }
  114. @touch $@
  115. tmp/.prereq-target: include/prereq.mk tmp/.targetinfo .config
  116. @mkdir -p tmp
  117. @rm -f tmp/.host.mk
  118. @$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
  119. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  120. false; \
  121. }
  122. @touch $@
  123. prereq: tmp/.prereq-build tmp/.prereq-packages tmp/.prereq-target FORCE
  124. download: .config FORCE
  125. $(MAKE) tools/download
  126. $(MAKE) toolchain/download
  127. $(MAKE) package/download
  128. $(MAKE) target/download
  129. world: .config FORCE
  130. $(MAKE) tools/install
  131. $(MAKE) toolchain/install
  132. $(MAKE) target/compile
  133. $(MAKE) package/compile
  134. $(MAKE) package/install
  135. $(MAKE) target/install
  136. $(MAKE) package/index
  137. clean: FORCE
  138. rm -rf build_* bin tmp
  139. dirclean: clean
  140. rm -rf staging_dir_* toolchain_build_* tool_build
  141. distclean: dirclean config-clean
  142. rm -rf dl
  143. help:
  144. cat README
  145. doc:
  146. $(MAKE) -C docs/ openwrt.pdf
  147. docclean:
  148. $(MAKE) -C docs/ clean
  149. symlinks:
  150. scripts/feeds.sh $(CONFIG_SOURCE_FEEDS)
  151. .SILENT: clean dirclean distclean config-clean download world
  152. FORCE: ;
  153. .PHONY: FORCE help
  154. %: ;