/xen-3.4.0/xen/Makefile

https://github.com/amodj/Utopia · Makefile · 162 lines · 131 code · 26 blank · 5 comment · 10 complexity · ca031469bd8fad9759213e801893bde6 MD5 · raw file

  1. # This is the correct place to edit the build version.
  2. # All other places this is stored (eg. compile.h) should be autogenerated.
  3. export XEN_VERSION = 3
  4. export XEN_SUBVERSION = 4
  5. export XEN_EXTRAVERSION ?= .0$(XEN_VENDORVERSION)
  6. export XEN_FULLVERSION = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
  7. -include xen-version
  8. export XEN_WHOAMI ?= $(USER)
  9. export XEN_DOMAIN ?= $(shell ([ -x /bin/dnsdomainname ] && /bin/dnsdomainname) || ([ -x /bin/domainname ] && /bin/domainname || echo [unknown]))
  10. export BASEDIR := $(CURDIR)
  11. .PHONY: default
  12. default: build
  13. .PHONY: dist
  14. dist: install
  15. .PHONY: build install clean distclean cscope TAGS tags MAP
  16. build install debug clean distclean cscope TAGS tags MAP::
  17. $(MAKE) -f Rules.mk _$@
  18. .PHONY: _build
  19. _build: $(TARGET).gz
  20. .PHONY: _install
  21. _install: $(TARGET).gz
  22. [ -d $(DESTDIR)/boot ] || $(INSTALL_DIR) $(DESTDIR)/boot
  23. $(INSTALL_DATA) $(TARGET).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_FULLVERSION).gz
  24. ln -f -s $(notdir $(TARGET))-$(XEN_FULLVERSION).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_VERSION).$(XEN_SUBVERSION).gz
  25. ln -f -s $(notdir $(TARGET))-$(XEN_FULLVERSION).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_VERSION).gz
  26. ln -f -s $(notdir $(TARGET))-$(XEN_FULLVERSION).gz $(DESTDIR)/boot/$(notdir $(TARGET)).gz
  27. $(INSTALL_DATA) $(TARGET)-syms $(DESTDIR)/boot/$(notdir $(TARGET))-syms-$(XEN_FULLVERSION)
  28. .PHONY: _debug
  29. _debug:
  30. objdump -D -S $(TARGET)-syms > $(TARGET).s
  31. .PHONY: _clean
  32. _clean: delete-unfresh-files
  33. $(MAKE) -C tools clean
  34. $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean
  35. $(MAKE) -f $(BASEDIR)/Rules.mk -C common clean
  36. $(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean
  37. $(MAKE) -f $(BASEDIR)/Rules.mk -C xsm clean
  38. $(MAKE) -f $(BASEDIR)/Rules.mk -C crypto clean
  39. $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) clean
  40. rm -f include/asm *.o $(TARGET)* *~ core
  41. rm -f include/asm-*/asm-offsets.h
  42. [ -d tools/figlet ] && rm -f .banner*
  43. .PHONY: _distclean
  44. _distclean: clean
  45. rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out
  46. $(TARGET).gz: $(TARGET)
  47. gzip -f -9 < $< > $@.new
  48. mv $@.new $@
  49. $(TARGET): delete-unfresh-files
  50. $(MAKE) -C tools
  51. $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h
  52. [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
  53. $(MAKE) -f $(BASEDIR)/Rules.mk -C include
  54. $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s
  55. $(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h
  56. $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $(TARGET)
  57. # drivers/char/console.o contains static banner/compile info. Blow it away.
  58. # Don't refresh these files during e.g., 'sudo make install'
  59. .PHONY: delete-unfresh-files
  60. delete-unfresh-files:
  61. @if [ ! -r include/xen/compile.h -o -O include/xen/compile.h ]; then \
  62. rm -f include/xen/compile.h; \
  63. fi
  64. .banner: Makefile
  65. $(MAKE) -C tools
  66. @tools/figlet/figlet -d tools/figlet Xen $(XEN_FULLVERSION) 2>$@2 >$@1
  67. @cat $@1 $@2 >$@
  68. @rm -f $@1 $@2
  69. # compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
  70. include/xen/compile.h: include/xen/compile.h.in .banner
  71. @sed -e 's/@@date@@/$(shell LC_ALL=C date)/g' \
  72. -e 's/@@time@@/$(shell LC_ALL=C date +%T)/g' \
  73. -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \
  74. -e 's/@@domain@@/$(XEN_DOMAIN)/g' \
  75. -e 's/@@hostname@@/$(shell hostname)/g' \
  76. -e 's!@@compiler@@!$(shell $(CC) $(CFLAGS) -v 2>&1 | tail -1)!g' \
  77. -e 's/@@version@@/$(XEN_VERSION)/g' \
  78. -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
  79. -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
  80. -e 's!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g' \
  81. < include/xen/compile.h.in > $@.new
  82. @grep \" .banner >> $@.new
  83. @grep -v \" .banner
  84. @mv -f $@.new $@
  85. include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
  86. @(set -e; \
  87. echo "/*"; \
  88. echo " * DO NOT MODIFY."; \
  89. echo " *"; \
  90. echo " * This file was auto-generated from $<"; \
  91. echo " *"; \
  92. echo " */"; \
  93. echo ""; \
  94. echo "#ifndef __ASM_OFFSETS_H__"; \
  95. echo "#define __ASM_OFFSETS_H__"; \
  96. echo ""; \
  97. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  98. echo ""; \
  99. echo "#endif") <$< >$@
  100. SUBDIRS = xsm arch/$(TARGET_ARCH) common drivers
  101. define all_sources
  102. ( find include/asm-$(TARGET_ARCH) -name '*.h' -print; \
  103. find include -name 'asm-*' -prune -o -name '*.h' -print; \
  104. find $(SUBDIRS) -name '*.[chS]' -print )
  105. endef
  106. define set_exuberant_flags
  107. exuberant_flags=`$1 --version 2>/dev/null | grep -iq exuberant && \
  108. echo "-I __initdata,__exitdata,__acquires,__releases \
  109. -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
  110. --extra=+f --c-kinds=+px"`
  111. endef
  112. .PHONY: _TAGS
  113. _TAGS:
  114. set -e; rm -f TAGS; \
  115. $(call set_exuberant_flags,etags); \
  116. $(all_sources) | xargs etags $$exuberant_flags -a
  117. .PHONY: _tags
  118. _tags:
  119. set -e; rm -f tags; \
  120. $(call set_exuberant_flags,ctags); \
  121. $(all_sources) | xargs ctags $$exuberant_flags -a
  122. .PHONY: _cscope
  123. _cscope:
  124. $(all_sources) > cscope.files
  125. cscope -k -b -q
  126. .PHONY: _MAP
  127. _MAP:
  128. $(NM) -n $(TARGET)-syms | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' > System.map
  129. .PHONY: FORCE
  130. FORCE:
  131. %.o %.i: %.c FORCE
  132. $(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F)
  133. %.o %.s: %.S FORCE
  134. $(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F)
  135. %/: FORCE
  136. $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o